-
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
Query Params based on user defined struct #518
Comments
I think this is a useful feature |
Feature added, try latest master branch. |
@sdghchj can you provide an example? This don't work: type Params struct {
test string
anotherTest int32
}
// ListAccounts godoc
// @Summary List accounts
// @Description get accounts
// @Tags accounts
// @Accept json
// @Produce json
// @Param params query Params false "..."
// @Success 200 {array} Account
// @Router /accounts [get]
func test() {} |
Something similar to this is working for me: // QueryListOptions represents the query parameters for a list of resources.
type QueryListOptions struct {
// The page number to return.
Page int `json:"page" minimum:"1" validate:"optional" example:"1"`
// The number of items to return per page.
PageSize int `json:"page_size" minimum:"1" maximum:"20" validate:"optional" example:"10"`
}
// @Summary Some Endpoint
// @Produce json
// @Param request query QueryListOptions false "Query Params"
func someHandler() {
} |
I don't see this in the docs, unless I'm mistaken. Would you like a PR? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is your feature request related to a problem? Please describe.
We have many endpoints sharing the same huge set of query parameters. I tried to declare it like this:
// @param params query model.FilterParams false "..."
However this doesn't work. So we have to copy/paste about 30 lines of params over 15 different endpoints. Is it possible to implement @param to use a user defined struct?
Describe the solution you'd like
// @param params query model.FilterParams false "..."
Describe alternatives you've considered
I see no alternative :-)
The text was updated successfully, but these errors were encountered: