-
Notifications
You must be signed in to change notification settings - Fork 762
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
A $ref needs to be wrapped inside a schema which is not according to spec. #402
Comments
Also, when using https://github.com/apigee-127/swagger-tools to validate the swagger file, the validator also does not like having the "schema" wrapper present. |
I think you're right... @webron knows the spec better than I (better than anyone?) but there seems to be an inconsistency of what works and what's in the spec. |
@ralphvanetten - that's not the way to define it, but without seeing what |
It is the example from swagger-api/swagger-ui#1228 :
The suggestion given in that issue is to wrap the |
Are you trying to define maps with |
No, perhaps its a poor choice for those names, but |
Okay, just wanted to make sure. This how {
"type": "object",
"title": "Information about a person",
"properties": {
"externalId1": {
"$ref": "#/definitions/map1"
},
"externalId2": {
"title": "second",
"type": "array",
"items": {
"$ref": "#/definitions/map2"
}
}
}
} |
So |
Ah, yes, I tried it and as soon as you add |
You add anything when there's |
The parser may read it somehow, but most parsers would ignore it. The way to add the description would be in the referenced object. |
Ok, I thought the So something like:
is not correct and not otherwise possible? |
If you use |
Isn't this a bit of a flaw in the (swagger) spec? I have a fairly large object used by many other objects. Using |
It's not a flaw in the Swagger spec. It's a limitation of JSON Reference which is used by JSON Schema which is used by Swagger. Not much we can do about it besides contest the JSON Reference spec, I wouldn't get my hopes up actually affecting it. |
I looked at the JSON reference spec. again and according to the spec it is fine to have other properties besides
https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03#section-3 So it seems the spec leaves room for adding a |
Nope. |
OK while it would be very convenient that |
Going by the above discussion is it legal to have a $ref along with other fields 'type' and 'description' etc? I have "BatchOrdersPromotions_3": {
"type": "object",
"properties": {
"promotionId": {
"description": "The unique id of the promotion.",
"type": "string"
},
"promotionEffectivePeriod": {
"type": "object",
"$ref": "#/definitions/BatchOrdersPromotionEffectivePeriod_5"
}
}
} In the above snippet is it legal to have field "type":"object" with the property promotionEffectivePeriod since it is a $ref? If that is legal, is it required that the "promotionEffectivePeriod" have properties of itself since it is defined as "object" type. I could not find any references in the spec. |
It's legal in terms of whether it's valid to write it that way or not. In terms of meaning - the |
This is a followup to swagger-api/swagger-ui#1228
I have
which does not work. The answer was to wrap it inside a "schema" and then it works:
However, after looking into the spec of both swagger and JSON schema, there is no reference anywhere the "schema" wrapper is required.
As far as I can tell, my version without the "schema" wrapper is correct.
The example here https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#simple-model does not use the "schema" wrapper.
Am I missing something?
The text was updated successfully, but these errors were encountered: