-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Can't generate description for object type in its definition. #708
Comments
Parsed by go parser, struct has only one line of comment as shown below, and now swag has not use that comment line as default description.
|
Sorry, tried comments as
Nothing happens, the result is the same - there is no description in swagger file. "handlers.CommonResponse": {
"type": "object",
"properties": {
"errors": {
"description": "Contextual errors map",
"type": "object",
"$ref": "#/definitions/handlers.Errors"
}, But it must be in: "handlers.Errors": {
"type": "object",
"description": "Contextual errors map",
"properties": {
"dataLayerName": {
"type": "string",
"example": "can't be empty"
}, If i add description manually here, then swagger UI shows me this description as on the screenshot above. |
@sdghchj, as I understand, it's not implemented now, right? |
Yes |
Description is bind to field, not a struct. If you use it as
, If
, If
, |
I'm offer next solution of this problem in code: |
@KuboOrk Thanks for figuring it out. Unfortunately, this is not the way we are accepting code contributions. |
Can I solve this task and contribute it the right way? |
@KuboOrk This is an Open Source project. All the contributions are welcome. |
- moved "if" statement out of the method - renamed fillDefinition → fillDefinitionDescription
- increase code readability by union conditions - moved result variable declaration inside function body
Describe the bug
Can't generate description for object type in its definition.
To Reproduce
Trying to add comments/annotations everywhere for my Errors struct but can't achieve expected behavior.
Expected behavior
Visually it will look like on screenshot in Swagger UI Models if "description" will be there(added it manually):
Actual behavior
But got it without
"description": "Contextual errors map"
:And in Swagger UI there is no description like on screenshot above.
Your swag version
latest master v1.6.6-0.20200519063744-e07798f56b23
Your go version
1.12.17
Desktop:
The text was updated successfully, but these errors were encountered: