-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Do not display error model #331
Comments
I second this. ResponseModel is not recognized :( |
Yes, the alternate response models & polymorphic types are not currently in the UI. Marking this as a feature... |
please reopen if still an issue |
I still see this same issue occurring with the latest pull from git. I see a model for the operation but not the response specific models. My json looked something like this: {
"swaggerVersion": "1.2",
"apis": [
{
"path": "/ping",
"description": "???",
"operations": [
{
"method": "GET",
"nickname": "ping",
"notes": "Ping the application.",
"parameters": [],
"type": "controllers.Ping",
"responseMessages": [
{
"code": 200,
"message": "Ok",
"responseModel": "controllers.Ping"
},
{
"code": 201,
"message": "Created",
"responseModel": "controllers.Ping"
},
{
"code": 500,
"message": "Test",
"responseModel": "controllers.Ping"
}
]
}
]
}
],
"apiVersion": "v1",
"info": {
"title": "Title",
"description": "Description"
},
"models": {
"controllers.Ping": {
"id": "controllers.Ping",
"properties": {
"status ": {
"type": "string"
},
"timestamp ": {
"type": "int64"
},
"version ": {
"type": "string"
}
},
"required": [
"status ",
"timestamp ",
"version "
]
}
},
"resourcePath": "http://localhost:9000"
} |
2.0 does not fix the problem. Using swagger 2.0 editor (http://editor.swagger.io/#/edit) with the default "Uber" sample seems to solve the problem (see screenshot): https://cloud.githubusercontent.com/assets/731020/5027847/f5439ff2-6b33-11e4-8db0-2cee479e3075.png But if I examine the produced JSON in the latest swagger-ui the result does only show the "default" response. The 200 response is missing. https://cloud.githubusercontent.com/assets/731020/5027890/53b95ca2-6b34-11e4-893c-8bc71a826722.png Here some other examples, which illustrate, that swagger-ui is unable to display the response models correctly:
This setup does show "default".
This setup shows "300". Do you see a pattern here? |
@neilyoung - now looking at the posted sample you have, the |
Thanks for the hint. But no, that doesn't help. BTW: The JSON is the unmodified export from the Swagger 2.0 editor sample Regards |
No, it is not a question of the syntax. It seems to simply just accept one model definition. Not to predict, which. |
I have a little more input. Maybe there is a higher sense :) If the response definition looks like this (don't care too much about sense or nonsense of definition):
Then the result looks like this: https://cloud.githubusercontent.com/assets/731020/5031043/7f154904-6b54-11e4-9587-5ba51ca358a9.png If I just change 300 to 200, 200 disappears from the response messages (although defined there) and appears somewhere above as "Response Class". Does that make sense? https://cloud.githubusercontent.com/assets/731020/5031092/ed4a0c2a-6b54-11e4-8936-9232cc36e798.png |
Yes, it makes sense. This is due to the current behavior that the 'first' 2XX response is considered as the 'main' response of the API call and it is displayed separately. This is related to the behavior in Swagger 1.2 and prior to it where operations had a distinct return type (unrelated to the responseMessages) as the 'successful' response, regardless of the http status code. We're considering if and how to modify this behavior - you can follow #674 on that. |
Thanks. Have made my +1 there :) |
Great. By the way, with regards to the |
the default response type is now set as the minimum 2xx type, or default if none exists. |
Hey all, this issue is actually not resolved from what I can tell ... ResponseModel for Swagger 1.2 are not rendered by swagger-ui (as OP reported). The code below (result of swagger-php, most recent dev-master as of today) does not result in an entry in the Response column. Tested with master as well as 2.0_develop branches. {
"basePath": "...",
"swaggerVersion": "1.2",
"apiVersion": "1.0",
"resourcePath": "/v1/products",
"apis": [
{
"path": "/v1/products/{tulip_id}",
"operations": [
{
"method": "GET",
"summary": "Find Product by Id",
"nickname": "getProductById",
"type": "string",
"parameters": [
{
...
}
],
"responseMessages": [
{
"code": 403,
"message": "Not authorized",
"responseModel": "ProblemJson"
}
],
"notes": "Returns the product with the matching unique tulip_id"
}
]
}
],
"models": {
"ProblemJson": {
"id": "ProblemJson",
"properties": {
"status": {
"description": "HTTP response status code",
"type": "integer"
},
"title": {
"description": "Title of the HTTP response code",
"type": "string"
},
"detail": {
"description": "Human-readable message to explain what happenend.",
"type": "string"
}
}
}
},
"produces": [
"application/json"
]
} Any chance of this getting resolved in the master branch? |
Hi,
The JSON generated when I indicate the error java class is correct, but it is not displayed in swagger-ui.
In Java code :
JSON generated :
The problem is that I don't have any information about ErrorResponse in swagger-ui. I just have the code "400' and the message.
Regards
The text was updated successfully, but these errors were encountered: