Closed e-gauthier closed 9 months ago
Description
Passing a JSON array with multiple types to JsonSchema.FromSampleJson return only the first element of the array a JsonSchema.
JsonSchema.FromSampleJson
Executing this line JsonSchema.FromSampleJson([1, { "a": "b"}, "value"] )
JsonSchema.FromSampleJson([1, { "a": "b"}, "value"] )
Actual result :
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "array", "items": { "type": "integer" } }
Expected Result :
{ "$schema": "http://json-schema.org/draft-04/schema#", "type": "array", "items": { "anyOf": [ { "type": "integer" }, { "type": "object" }, { "type": "string" } ] } }
The problem may be there. https://github.com/RicoSuter/NJsonSchema/blob/master/src/NJsonSchema/Generation/SampleJsonSchemaGenerator.cs#:~:text=schema.Item%20%3D%20itemSchemas.First()%3B
Description
Passing a JSON array with multiple types to
JsonSchema.FromSampleJson
return only the first element of the array a JsonSchema.Executing this line
JsonSchema.FromSampleJson([1, { "a": "b"}, "value"] )
Actual result :
Expected Result :
The problem may be there. https://github.com/RicoSuter/NJsonSchema/blob/master/src/NJsonSchema/Generation/SampleJsonSchemaGenerator.cs#:~:text=schema.Item%20%3D%20itemSchemas.First()%3B