-
Notifications
You must be signed in to change notification settings - Fork 762
Response Examples Clashing With "allOf"? #459
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
Comments
UPDATE: After removing the example attached to the response object, I was still experiencing this strange behavior. It appears that the first "allOf" in a schema--including a $ref--becomes the new reference for the model in the $ref, regardless of whether or not an example is present. |
OK currently, the |
For the record, here's the JSON after running your sample through the resolver: {
"definitions": {
"media": {
"description": "Media model",
"required": [
"id"
],
"properties": {
"id": {
"description": "Media's id",
"format": "int32",
"type": "integer",
"x-resolved-from": "#/definitions/media"
},
"name": {
"description": "Media's name",
"type": "string",
"x-resolved-from": "#/definitions/media"
},
"description": {
"description": "Media's description",
"type": "string",
"x-resolved-from": "#/definitions/media"
},
"caption": {
"description": "Media's caption",
"type": "string",
"x-resolved-from": "#/definitions/media"
},
"user_id": {
"description": "Media's user_id",
"format": "int32",
"type": "integer",
"x-resolved-from": "#/definitions/media"
},
"created_at": {
"description": "Media's created_at",
"type": "string",
"x-resolved-from": "#/definitions/media"
},
"updated_at": {
"description": "Media's updated_at",
"type": "string",
"x-resolved-from": "#/definitions/media"
},
"owner_id": {
"description": "Media's owner_id",
"format": "int32",
"type": "integer",
"x-resolved-from": "#/definitions/media"
},
"owner_type": {
"description": "Media's owner_type",
"type": "string",
"x-resolved-from": "#/definitions/media"
},
"src": {
"description": "Media's src",
"type": "string",
"x-resolved-from": "#/definitions/media"
},
"extra_media_prop2": {
"properties": {
"nilla": {
"type": "string"
},
"wafers": {
"type": "string"
}
},
"type": "object",
"x-resolved-from": "self"
},
"extra_media_prop1": {
"default": 10,
"format": "int32",
"type": "integer",
"x-resolved-from": "self"
}
},
"type": "object"
},
"new_model": {
"required": [
"prop4"
],
"properties": {
"prop1": {
"format": "int32",
"type": "integer"
},
"prop2": {
"items": {
"type": "string"
},
"type": "array"
},
"prop3": {
"$ref": "#/definitions/media"
},
"prop4": {
"properties": {
"prop4_1": {
"type": "boolean"
},
"prop4_2": {
"type": "string"
}
},
"type": "object"
},
"prop5": {
"items": {
"properties": {
"prop5_1": {
"items": {
"type": "string"
},
"type": "array"
},
"prop5_2": {
"type": "string"
}
},
"type": "object"
},
"type": "array"
},
"prop6": {
"x-composed": true,
"$ref": "#/definitions/media",
"properties": {
"prop6_1": {
"type": "string",
"x-resolved-from": "self"
}
},
"type": "object"
}
},
"type": "object"
},
"new_model2": {
"x-composed": true,
"x-resolved-from": [
"#/definitions/media"
],
"description": "Media model",
"required": [
"id"
],
"properties": {
"id": {
"description": "Media's id",
"format": "int32",
"type": "integer",
"x-resolved-from": "#/definitions/media"
},
"name": {
"description": "Media's name",
"type": "string",
"x-resolved-from": "#/definitions/media"
},
"description": {
"description": "Media's description",
"type": "string",
"x-resolved-from": "#/definitions/media"
},
"caption": {
"description": "Media's caption",
"type": "string",
"x-resolved-from": "#/definitions/media"
},
"user_id": {
"description": "Media's user_id",
"format": "int32",
"type": "integer",
"x-resolved-from": "#/definitions/media"
},
"created_at": {
"description": "Media's created_at",
"type": "string",
"x-resolved-from": "#/definitions/media"
},
"updated_at": {
"description": "Media's updated_at",
"type": "string",
"x-resolved-from": "#/definitions/media"
},
"owner_id": {
"description": "Media's owner_id",
"format": "int32",
"type": "integer",
"x-resolved-from": "#/definitions/media"
},
"owner_type": {
"description": "Media's owner_type",
"type": "string",
"x-resolved-from": "#/definitions/media"
},
"src": {
"description": "Media's src",
"type": "string",
"x-resolved-from": "#/definitions/media"
},
"extra_media_prop2": {
"properties": {
"nilla": {
"type": "string"
},
"wafers": {
"type": "string"
}
},
"type": "object",
"x-resolved-from": "self"
},
"extra_media_prop1": {
"default": 10,
"format": "int32",
"type": "integer",
"x-resolved-from": "self"
}
},
"type": "object"
}
}
} |
Alright, it's good to know the current constraints of the feature. However, I removed the definition of the nested "allOf" property so that only the root reference in |
I didn't know this, and it might explain why I could never get composition/polymorphism working correctly (at least not in the UI). We have our definitions in separate files, so it would be useful if we could use composition in other places.
But that would be under the |
@fehguy When you mentioned running the example through the resolver, which resolver are you referring to. A ModelResolver? I'm experiencing a similar issue to this one and am curious... |
Hi, the swagger-js has a class called |
added resolution of inline property `allOf` constructs per #459
fixed in 83667b8 |
Firstly, I apologize for the amount of info in this issue, but I couldn't get around it. 😄
It seems that the fairly new PR merge that added "allOf" support on schemas has broken some rendering when mixed with Response Object examples. Here are the pertinent global definitions on the swagger object:
It should be noted that
new_model.prop6
uses "allOf", referencing themedia
definition, and thatnew_model2
uses "allOf" with the same reference, but specified on the root schema (not a property's schema defined in a parent schema).And here are the responses for the path I am working with (I've been experimenting so pay no attention to the fact that a 204 response has an associated schema haha):
The example renders correctly in the Response Class view in the UI. However, the example is also showing up--INSTEAD OF the
media
definition--fornew_model.prop3
andnew_model.prop6
(though,new_model.prop6.prop6_1
is absent). Interestingly, the correctmedia
definition is getting rendered correctly for the 422 response, which usesnew_model2
. My suspicion is that "allOf" was implemented correctly when specified on a schema at the top level, but incorrectly in nested schemas. Removing the example from the response results in the correctmedia
definition showing up everywhere as expected/defined.Here are the rendered Model Schemas for reference:
The text was updated successfully, but these errors were encountered: