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

Unable to generate Swagger spec with more than one security header using "AND" logic. #2294

Open
utkarsh-var opened this issue May 19, 2020 · 1 comment
Labels
auth API authentication generate spec Related to spec generation from code needs testing Needs more testing for issue confirmation/qualification scanner

Comments

@utkarsh-var
Copy link

Problem statement

I'm unable to generate the Swagger specification for making more than one security header required for authentication. For example, I'm using x_client_id and access_token for authenticating the request, but I'm not able to generate the Swagger specs for it.

The issues here mentions that the go swagger has the support for AND logic in the Security headers, but I'm not able to find the documentation for the same.

I'm using the following comments for generating the Swagger specs:-

//  security:
//   - x_client_id:
//      access_token:
//
//  SecurityDefinitions:
//  x_client_id:
//    type: apiKey
//    name: x_client_id
//    in: header
//  access_token:
//    type: apiKey
//    name: Authorization
//    in: header

It generates the following Swagger specs:-

security:
- x_client_id: []
- access_token: []
securityDefinitions:
  access_token:
    in: header
    name: Authorization
    type: apiKey
  x_client_id:
    in: header
    name: x_client_id
    type: apiKey

The expected output should be:-

security:
- x_client_id: []
  access_token: []
securityDefinitions:
  access_token:
    in: header
    name: Authorization
    type: apiKey
  x_client_id:
    description: Use the client id provided by the API
    in: header
    name: x_client_id
    type: apiKey

Environment

swagger version: 2.0
go version: go1.14.2
OS: macOS 10.14.5

@fredbi fredbi added auth API authentication generate spec Related to spec generation from code labels Jun 27, 2020
@fredbi
Copy link
Contributor

fredbi commented Jun 27, 2020

@utkarsh-var The issue you are referring to relates to server generation. Spec generation works differently.

@fredbi fredbi added the needs testing Needs more testing for issue confirmation/qualification label Jun 27, 2020
@fredbi fredbi added the scanner label Dec 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auth API authentication generate spec Related to spec generation from code needs testing Needs more testing for issue confirmation/qualification scanner
Projects
None yet
Development

No branches or pull requests

2 participants