JsonType duplicatedType = typesWithNoDuplicates. List typesWithNoDuplicates = new List ( ) TODO: This is currently O(n*n) because it iterates through List on every loop iteration. Private IList HandleDuplicateClasses ( IList types ) / Checks if there are any duplicate classes in the input, and merges its corresponding properties (TEST CASE 7) Singularize (inputIsKnownToBePlural : false ) ) if (!(item.Value is JObject)) throw new NotSupportedException("Arrays of non-objects are not supported yet.") Take (MAX_JSON_ARRAY_ITEMS ) ) Įlse if (value is JObject jObject ) //TODO J2C : ONLY LOOP OVER 50 OBJECT AND NOT THE WHOLE THINGįoreach ( KeyValuePair jsonObjectProperty in jObject ) Object )Ĭonst int MAX_JSON_ARRAY_ITEMS = 50 // Take like 30 items from the array this will increase the chance of getting all the objects accuralty while not analyzing all the data foreach (KeyValuePair field in jsonFields)įoreach ( KeyValuePair field in jsonFields ) Remove support for nested classes for now until code is cleaned Add (propName, commonType ) įieldExamples = new List ( ) commonType = commonType.MaybeMakeNullable(this) Įlse commonType = commonType. TryGetValue (propName, out fieldType ) ) JsonType currentType = new JsonType ( this, prop. Private void GenerateClass (JObject examples, JsonType type )ĭictionary jsonFields = new Dictionary ( ) ĭictionary > fieldExamples = new Dictionary > ( ) įoreach (JProperty prop in obj. StringBuilder builder = new StringBuilder ( ) ĬodeWriter. JsonType rootType = new JsonType ( this, examples ) ToArray ( ) ĮrrorMessage = "Exception: " + ex. All ( el => el is JObject ) ) )Įxamples = jArray. Using ( JsonTextReader reader = new JsonTextReader (sr ) ) Using ( StringReader sr = new StringReader (jsonInput ) ) Public StringBuilder GenerateClasses ( string jsonInput, out string errorMessage ) SigSpec for SignalR Core: Specification and code generator for SignalR Core.Using Xamasoft.VisualJsonEditor, a JSON schema based file editor for Windows.The NJsonSchema.CodeGeneration can be used to generate C# or TypeScript code from a JSON schema:Įxport enum Gender Final notes The JsonSchema class can be used as follows: Some code generators can directly be used via the Apimundo service. The project is developed and maintained by Rico Suter and other contributors. NSwag also provides command line tools to use the NJsonSchema's JSON Schema generator (command types2swagger). NET which generates client code for Web API services. NJsonSchema is heavily used in NSwag, a Swagger API toolchain for.
0 Comments
Leave a Reply. |