js2model
js2model copied to clipboard
missing support for allOf/anyOf/oneOf/etc... for types
from the spec: http://json-schema.org/latest/json-schema-validation.html#anchor75
js2model doesn't like this example:
$ cat test.json
{
"id": "http://some.site.somewhere/entry-schema#",
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"required": [ "storage" ],
"properties": {
"storage": {
"oneOf": [
{ "type": "string" },
{ "type": "integer" }
]
}
}
}
$ ~/js2model/src/js2model -o output test.json -l cpp
2016-10-20 16:48:22,730: tr.jsonschema.JsonSchema2Model: WARNING:
Unknown schema type in {u'oneOf': [{u'type': u'string'}, {u'type': u'integer'}]}
Is there any update regarded to this issue? I am also trying to combine schemas (see https://spacetelescope.github.io/understanding-json-schema/reference/combining.html), escpecially in combination with definitions.
Note: For me the example above is generatable, but the C++ type of property "storage" is "int", which is not correct...
I have another example, which does not compile for me:
############################################################## {
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"pet": {
"id": "http://foo.bar/schemas/pet.json",
"type": "object",
"properties": {
"name": { "type": "string" },
"age": { "type": "number" }
},
"additionalProperties": false,
"required": ["name", "age"]
}
},
"type": "object",
"properties": {
"cat": {
"anyOf": [
{ "type": "string", "maxLength": 5 },
{ "$ref": "#/definitions/pet" }
]
},
"dog": {
"anyOf": [
{ "type": "string", "maxLength": 5 },
{ "$ref": "#/definitions/pet" }
]
}
}
} ##############################################################