Open elliott-beach opened 6 years ago
Mongoose mode doesn't descend into arrays. An object within an array of will have type mixed, unlike in the default JSON mode which will infer the type of the object within the array. Is this intentional?
mixed
Repro: Using example.json:
example.json
{ "array":[{ "value1": "a", "value2": "b" }] }
With the default mode (json):
β> ~/m/p/so-app generate-schema example.json { "$schema": "http://json-schema.org/draft-04/schema#", "type": "object", "properties": { "array": { "type": "array", "items": { "type": "object", "properties": { "value1": { "type": "string" }, "value2": { "type": "string" } } } } } }
With mongoose-mode:
β> ~/m/p/so-app generate-schema -m example.json { "array": { "type": [ "Mixed" ] } }
I noticed this while idly investigating the asker's problem in this old StackOverflow question: https://stackoverflow.com/questions/39362065/how-to-create-a-mongoose-schema-from-json.
Mongoose mode doesn't descend into arrays. An object within an array of will have type
mixed
, unlike in the default JSON mode which will infer the type of the object within the array. Is this intentional?Repro: Using
example.json
:With the default mode (json):
With mongoose-mode:
I noticed this while idly investigating the asker's problem in this old StackOverflow question: https://stackoverflow.com/questions/39362065/how-to-create-a-mongoose-schema-from-json.