Skip to content
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

add parameters on router #2104

Closed
epolar opened this issue Nov 12, 2019 · 4 comments
Closed

add parameters on router #2104

epolar opened this issue Nov 12, 2019 · 4 comments

Comments

@epolar
Copy link

epolar commented Nov 12, 2019

My Code:

//	---
//	swagger:route POST /auth/verify/code sendSms
//
//	parameters:
//	- name: request
//	  in: body
//	  schema: $ref: '#/definitions/SendVerifyCode'
//
//	responses:
//		204: description: send success

run: swagger generate spec -o swagger.yml -m
output: operation (sendSms): invalid route/operation schema provided

Code:

//	---
//	swagger:route POST /auth/verify/code sendSms
//
//	parameters:
//	+ name: request
//	  in: body
//	  schema: $ref: '#/definitions/SendVerifyCode'
//
//	responses:
//		204: description: send success

generate success, but cat swagger.yml:

...
  /auth/verify/code:
    post:
      operationId: sendSms
      parameters:
      - in: body
        name: request
      responses:
        "204":
          description: ' send success'
...

parameters schema is missing.
What can I add parameters link to model?

@epolar
Copy link
Author

epolar commented Nov 12, 2019

//	---
//	swagger:route POST /auth/verify/code sendSms
//
//	parameters:
//	+ name: request
//	  in: body
//	  type: SendVerifyCode
//
//	responses:
//		204: description: send success

use + instead of a - resolve my problem

@epolar epolar closed this as completed Nov 12, 2019
@FM1337
Copy link

FM1337 commented Jan 31, 2022

Uh what? So y'all literally have it documented like

    // - text/html
    // parameters:
    // - name: tags
    //   in: query
    //   description: tags to filter by
    //   required: false
    //   type: array

On your docs, but it doesn't actually work unless you use a + instead of a -, I just spent 2 hours trying to figure this out, please update your docs.

@karl-gustav
Copy link

karl-gustav commented Apr 14, 2023

Not only that, but in standard VS code (with standard go extension) it will auto format the +to a -😡

If anybody is interested this is the pace in the code that requires the +: go-swagger/route_params.go#L91

@karl-gustav
Copy link

karl-gustav commented Apr 14, 2023

My workaround is to use - +name instead of + name. E.g.:

// swagger:route GET /users/{id} User GetUsers
// ---
// Some text...
//
// Parameters:
//   - +name: id
//     in: path
//     type: string
//     required: true
//
// Responses:
//   - 200: UserResponse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants