-
Notifications
You must be signed in to change notification settings - Fork 393
Description
I'm using this library through metosin/scjsv, which is a thin Clojure wrapper. I'm attempting to verify a minimal Swagger sample (petstore-minimal) against the Swagger JSON Schema. It appears that the problem is with additionalProperties: false and patternProperties set to something. When not using inline dereferencing, this validates. When using inline dereferencing, I get the following error out of scjsv:
[{:level "error",
:schema {:loadingURI "#", :pointer "/definitions/responses"},
:instance {:pointer "/paths/~1pets/get/responses"},
:domain "validation",
:keyword "additionalProperties",
:message
"object instance has properties which are not allowed by the schema: [\"200\"]",
:unwanted ["200"]}]That's surprising, because the definition that I was expecting (via here) was #/definitions/responses, which looks like this:
{
"responses": {
"type": "object",
"description": "Response objects names can either be any valid HTTP status code or 'default'.",
"minProperties": 1,
"additionalProperties": false,
"patternProperties": {
"^([0-9]{3})$|^(default)$": {
"$ref": "#/definitions/responseValue"
},
"^x-": {
"$ref": "#/definitions/vendorExtension"
}
},
"not": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^x-": {
"$ref": "#/definitions/vendorExtension"
}
}
}
}
}The property "200" is allowed by patternProperties.
I currently have no idea where the actual problem lies, and if this is even really a bug or not. I'll attempt to reduce the reproducing sample until I get something smaller.
I'd be happy to reproduce this in Java directly if it helps, but presumably the error message above looks sufficiently familiar to at least determine if this is even a bug :)
I use inline dereferencing so verification doesn't attempt to do network IO for schemas without external references (or with bogus external references) like:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://my.site/myschema#",
"definitions": {
"schema1": {
"id": "schema1",
"type": "integer"
},
"schema2": {
"type": "array",
"items": {
"$ref": "schema1"
}
}
}
}... so that the validator doesn't attempt to download things at validation time.