Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

missing support for allOf/anyOf/oneOf/etc... for types #4

Open
vapier opened this issue Oct 20, 2016 · 1 comment
Open

missing support for allOf/anyOf/oneOf/etc... for types #4

vapier opened this issue Oct 20, 2016 · 1 comment

Comments

@vapier
Copy link

vapier commented Oct 20, 2016

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'}]}
@thorsten-klein
Copy link

thorsten-klein commented Feb 19, 2018

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" }
		]
	}
}

}
##############################################################

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants