Skip to content

Added Parameters section to swagger:route #1405

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

Merged
merged 5 commits into from
Feb 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/swagger/swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ It aims to represent the contract of your API with a language agnostic descripti
log.Fatal(err)
}

genpar, err := parser.AddCommand("generate", "genererate go code", "generate go code for the swagger spec file", &commands.Generate{})
genpar, err := parser.AddCommand("generate", "generate go code", "generate go code for the swagger spec file", &commands.Generate{})
if err != nil {
log.Fatalln(err)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ func ServeAPI(host, basePath string, schemes []string) error {

Schemes: http, https, ws, wss

Parameters:
+ name: request
description: The request model.
in: body
type: petModel
unknown: invalid key that will not get parsed. Added to increase coverage.
+ name: id
description: The pet id
in: path
required: true
allowEmpty: false

Responses:
default: body:genericError
200: body:someResponse
Expand Down Expand Up @@ -92,6 +104,8 @@ func ServeAPI(host, basePath string, schemes []string) error {
// api_key:
// oauth: orders:read, https://www.googleapis.com/auth/userinfo.email
//
// Parameters:
//
// Responses:
// default: body:genericError
// 200: body:someResponse
Expand All @@ -116,6 +130,18 @@ func ServeAPI(host, basePath string, schemes []string) error {
// api_key:
// oauth: read, write
//
// Parameters:
// + name: id
// description: The order id
// in: invalidIn
// required: false
// allowEmpty: true
// noValue (to increase coverage, line without colon, split result will be 1)
// + name: request
// description: The request model.
// in: body
// type: orderModel
//
// Responses:
// default: body:genericError
// 200: body:someResponse
Expand Down Expand Up @@ -196,6 +222,76 @@ func ServeAPI(host, basePath string, schemes []string) error {
// 422: body:validationError
mountItem("DELETE", basePath+"/orders/:id", nil)


// swagger:route POST /param-test params testParams
//
// Allow some params with constraints.
//
// Consumes:
// application/json
// application/x-protobuf
//
// Produces:
// application/json
// application/x-protobuf
//
// Schemes: http, https, ws, wss
//
// Security:
// api_key:
// oauth: read, write
//
// Parameters:
// + name: someNumber
// description: some number
// in: path
// required: true
// allowEmpty: true
// type: number
// max: 20
// min: 10
// default: 15
// + name: someQuery
// description: some query values
// in: query
// type: array
// minLength: 5
// maxLength: 20
// + name: someBoolean
// in: path
// description: some boolean
// type: boolean
// default: true
// + name: constraintsOnInvalidType
// description: test constraints on invalid types
// in: query
// type: bool
// min: 1
// max: 10
// minLength: 1
// maxLength: 10
// format: abcde
// default: false
// + name: noType
// description: test no type
// min: 1
// max: 10
// minLength: 1
// maxLength: 10
// default: something
// + name: request
// description: The request model.
// in: body
// type: string
// enum: apple, orange, pineapple, peach, plum
// default: orange
//
// Responses:
// default: body:genericError
// 200: body:someResponse
// 422: body:validationError
mountItem("POST", basePath+"/param-test", nil)

return nil
}

Expand Down
104 changes: 52 additions & 52 deletions generator/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading