You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Can't generate description for object type in its definition. #708
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.
// Contextual errors maptypeErrorsstruct {
DataLayerNamestring`json:"dataLayerName,omitempty" example:"can't be empty"`
}
typeErrorsResponsestruct {
// Contextual errors mapErrors*Errors`json:"errors,omitempty"`// List of important notificationsNotification []string`json:"notification,omitempty" example:"some important notification, other important notification"`
}
type ErrorsResponse struct {
// Contextual errors map
Errors *Errors `json:"errors,omitempty"`
// List of important notifications
Notification []string `json:"notification,omitempty" example:"some important notification, other important notification"`
}
,
you will see description Contextual errors map for field Errors in definition of ErrorsResponse.
If
type Errors struct {
// Contextual errors map
DataLayerName string `json:"dataLayerName,omitempty" example:"can't be empty"`
}
,
you will see description Contextual errors map for field DataLayerName in definition of Errors.
If
// Contextual errors map
type Errors struct {
DataLayerName string `json:"dataLayerName,omitempty" example:"can't be empty"`
}
Activity
sdghchj commentedon May 23, 2020
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.
Terminator637 commentedon May 23, 2020
Sorry, tried comments as
Nothing happens, the result is the same - there is no description in swagger file.
In fact, it is, but in the wrong place:
But it must be in:
If i add description manually here, then swagger UI shows me this description as on the screenshot above.
Terminator637 commentedon May 23, 2020
@sdghchj, as I understand, it's not implemented now, right?
sdghchj commentedon May 23, 2020
Yes
sdghchj commentedon May 29, 2020
Description is bind to field, not a struct.
If you use it as
,
you will see description
Contextual errors mapfor fieldErrorsin definition of ErrorsResponse.If
,
you will see description
Contextual errors mapfor fieldDataLayerNamein definition of Errors.If
,
You can't see it.
KuboOrk commentedon Jan 18, 2022
I'm offer next solution of this problem in code:
patch.zip (file inside archive can be applyed by command
git apply)ubogdan commentedon Jan 18, 2022
@KuboOrk Thanks for figuring it out. Unfortunately, this is not the way we are accepting code contributions.
KuboOrk commentedon Jan 19, 2022
Can I solve this task and contribute it the right way?
ubogdan commentedon Jan 19, 2022
@KuboOrk This is an Open Source project. All the contributions are welcome.
feat: add generation of type description to schema (swaggo#708)
feat: delete doubling swagger doc example (swaggo#708)
delete unused return in "fillDefinition" (swaggo#708)
updated test by parsing struct commit (swaggo#708)
updated test sample by parsing struct commit (swaggo#708)
Refactoring (swaggo#708):
Refactoring (swaggo#708):
Corrected swagger documentation (swaggo#708)
Deleted empty row afte method signature (swaggo#708)
feat: add generation of type description to schema (#708) (#1106)