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
How to write comment when API accepts json body? #970
My web app accepts json body instead of individual parameters, so I want to be able to submit a single json body. From the documentation it is not clear how to write comments for this purpose. I don't know how I should use swagger:model or swagger:parameter here. Can you provide me a sample commented code for this example please:-
type test struct{
test1 string `json:"test1"`
test2 string `json:"test2"`
}
I know this is a very old issue - but I do wonder how this would work with a linter that removes deadcode. Defining a struct just so that you can define a body for swagger will result into a working swagger doc but the linter will not like it. Of course we can mark this with //nolint.
Would'nt it be nice if we could put in: body above the type test struct { part?
Activity
casualjim commentedon Mar 23, 2017
stefanhendriks commentedon Nov 23, 2021
I know this is a very old issue - but I do wonder how this would work with a linter that removes
deadcode. Defining a struct just so that you can define abodyfor swagger will result into a working swagger doc but the linter will not like it. Of course we can mark this with//nolint.Would'nt it be nice if we could put
in: bodyabove thetype test struct {part?casualjim commentedon Nov 23, 2021
You can use
body:testin the swagger routego-swagger/fixtures/goparsing/classification/operations_body/todo_operation_body.go
Lines 47 to 50 in 43c2774