问题
I am trying to find what is making the following JSON invalid. The strange thing is that it passes off as valid JSON in this website but is invalid in this one
Here's the schema:
http://pastebin.com/QPxEPjMT
The error logged on the second schema validation website is as follows:
Error when resolving schema reference '#/definitions/identifiable'.
Path 'definitions.subscription.allOf[0]', line 19, position 17.
Can someone clarify whether my schema is incorrect or this is about some ambiguous rule in the JSON Schema itself?
回答1:
You do not have the schema defined for the object of type 'identifiable' on the root definitions level:
{
...
"definitions": {
...
"identifiable": {
"$schema": "http://json-schema.org/draft-04/schema#",
"id": "http://api.sprint.com/schema/identifiable#",
"title": "Identifiable Schema",
"type": "object",
"properties": {
"id": {
"type": "string",
"description": "READ ONLY. The id of the resource."
}
},
"required": [
"id"
],
"additionalProperties": true
...
}
...
}
But you have it defined inside your definition of the object of type 'subscriptions'. So, the reference you have in the scheme is pointing to:
[root]/definitions/identifiable
but you have it on:
[root]/definitions/subscriptions/definitions/identifiable
Please, fix your reference. BTW, both of sites are marking your schema invalid.
来源:https://stackoverflow.com/questions/38034478/json-formatting-ref-error