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

Fail to have both allOf and anyOf as properties in schema #184

Closed
cdanger opened this issue May 30, 2018 · 2 comments
Closed

Fail to have both allOf and anyOf as properties in schema #184

cdanger opened this issue May 30, 2018 · 2 comments

Comments

@cdanger
Copy link

cdanger commented May 30, 2018

I tried the official workaround for re-using schemas with additionalProperties=false in draft 6.
In my case, the relevant part is:

{
	"$schema": "http://json-schema.org/draft-06/schema",
...
	"definitions": {
...
"Match": {
			"type": "object",
			"allOf": [
				{"properties": {
					"matchFunction": { "type": "string", "format": "uri" },
					"attributeValue": {
									"$ref": "common.schema.json#/definitions/AttributeValueType"
								}
				}},
				{
					"oneOf": [
						{
						"properties": {
								"attributeDesignator": { "$ref": "#/definitions/AttributeDesignator"}
						}
						,
							"required": [
								"attributeDesignator"
							]
						},
						{"properties": {
								"attributeSelector": {
							"$ref": "#/definitions/AttributeSelector"}
							},
							
							"required": [
								"attributeSelector"
							]
						},
						{
							"properties": {
								"variableRef": {
									"$ref": "#/definitions/VariableReference"
								}
							},
							"required": [
								"variableRef"
							]
						}
					]
				}
			],
			"anyOf": [
				{
            			"propertyNames": {"enum": ["matchFunction", "attributeValue"]}
        		},
        		{
            			"propertyNames": {"oneOf": [
            				{"enum": ["attributeDesignator"]}, {"enum": ["attributeSelector"]}, {"enum": ["variableRef"]} 
            				]} 
        		}
			]
		}
...
}
}

I get this error:

Caused by: org.everit.json.schema.SchemaException: #/definitions/Match: expected at most 1 of 'allOf', 'anyOf', 'oneOf', 2 found

Is this workaround supposed to work with the json-schema library ?

@erosb
Copy link
Contributor

erosb commented May 31, 2018

Hi, a bugfix is likely to come in the next release for using "allOf"/"anyOf"/"oneOf" in the same schema object, it was also reported in #174 .

@erosb
Copy link
Contributor

erosb commented Jun 7, 2018

The fix is available in the latest release: 1.9.0

@erosb erosb closed this as completed Jun 7, 2018
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