1

I want to have an authorization scheme where both authorization1 header and authorization2 headers are required.

So the resulting json should look like:

"security": [
    {
      "authorization1": [ "[]"],
      "authorization2": [ "[]"],
    }
  ]
}

I have the following annotation in the go code:

// Package Backend API Server.
//
//     Schemes: https
//     BasePath: /api/v1
//     Version: 1.0.0
//
//     Consumes:
//     - application/json
//
//     Produces:
//     - application/json
//
//     Security:
//     - authorization1: []
//       authorization2: []
//
//    SecurityDefinitions:
//    authorization1:
//      type: apiKey
//      name: Authorization1
//      in: header
//    authorization2:
//      type: apiKey
//      name: Authorization2
//      in: header
//
// swagger:meta

Running

swagger generate spec -m -o ./public/swagger.json

gives me the following security section

the output of the security section is

"security": [
    {
      "authorization1": [ "[]"]
    },
    {
      "authorization2": [ "[]"]
    }
  ]
}

This causes an or between the headers rather than and. when i look at the swagger ui i get the following dialog

When looking at code generation from spec, this is already handled. https://github.com/go-swagger/go-swagger/issues/1089

so it should also work the other way around.

what do i wrong ?

David Michael Gang
  • 7,107
  • 8
  • 53
  • 98

0 Answers0