-
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
UI Shows Single Example Response Model Only #767
Comments
This may be related to #671 |
@webron, any idea on this one? |
@codehatcher - any chance you can share your full spec? |
Here is an example, I tried to truncate some of it. {
"swagger": "2.0",
"info": {
"title": "title",
"description": "descriptor",
"version": "0.1"
},
"host": "localhost:3000",
"consumes": [
"application/json",
"application/x-www-form-urlencoded"
],
"produces": [
"application/json"
],
"basePath": "/api",
"paths": {
"/v1/auths/facebook": {
"post": {
"x-swagger-router-controller": "auths",
"operationId": "facebook",
"tags": ["auths"],
"description": "Facebook authentication",
"parameters": [
{
"in": "body",
"name": "body",
"description": "Facebook Token",
"required": true,
"schema": {
"$ref": "#/definitions/FacebookToken"
}
}
],
"security": [
{
"facebookAuth": []
}
],
"responses": {
"default": {
"description": "Invalid request.",
"schema": {
"$ref": "#/definitions/Error"
}
},
"200": {
"description": "Successful request.",
"schema": {
"uid": "string",
"token": "string",
"username": "string"
}
}
}
}
}
},
"securityDefinitions": {
"basicAuth": {
"type": "basic"
},
"tokenAuth": {
"type": "apiKey",
"description": "Built in token auth",
"name": "access_token",
"in": "query"
},
"facebookAuth": {
"type": "apiKey",
"description": "Facebook token auth using passport-facebook-token",
"name": "access_token",
"in": "query"
}
},
"definitions": {
"Review": {
"properties": {
"company": {
"type": "string"
},
"description": {
"type": "string"
},
"rating": {
"type": "number"
},
"images": {
"type": "array",
"items": {
"type": "string"
}
},
"datetime": {
"type": "number"
},
"location": {
"type": "string"
},
"_id": {
"type": "string"
},
"submitter": {
"type": "string"
}
},
"required": ["company", "description"]
},
"FacebookToken": {
"properties": {
"access_token": {
"type": "string"
}
}
},
"UserRegistration": {
"properties": {
"username": {
"type": "string"
},
"password": {
"type": "string"
}
}
},
"Ok": {
"properties": {
"message": {
"type": "string"
}
},
"required": ["message"]
},
"Error": {
"properties": {
"message": {
"type": "string"
}
},
"required": ["message"]
}
}
} |
For the "200" response, the value is not a valid schema. |
If I change it to the following for the sake of a valid schema "responses": {
"default": {
"description": "Invalid request.",
"schema": {
"$ref": "#/definitions/Error"
}
},
"200": {
"description": "Successful request.",
"schema": {
"$ref": "#/definitions/Error"
}
}
} |
Actually, it appears above the operation as the response. See #674 for more details. |
This was due to an invalid schema and not an issue. |
No problem, thank you for the update. |
@webron, I'm nervous about being back here because chances are something is wrong with my response body, but here goes. I am having the same problem as above but I believe my response object is correct. I verified it with the swagger-editor. "responses": {
"400": {
"description": "Successful request.",
"schema": {
"$ref": "#/definitions/Error"
}
},
"200": {
"description": "Successful request.",
"schema": {
"title": "Success",
"required": ["token"],
"properties": {
"token": {
"type": "string"
}
}
}
}
}
|
Yup, now you've hit #705, which will apply to any inline schema definitions. Generally speaking, I'd advise not using inline schema definitions (unless they are primitives/arrays) even when they do get supported by the UI. |
Haha ok, thanks for the speedy response! |
As long as you keep opening issues late at night for you, you'll hit my early morning, and there's nothing like replying issues early in the morning ;) |
haha |
For code such as this
Only the default is shown but not for "200". See screenshot below.
The text was updated successfully, but these errors were encountered: