swagger-api / swagger-play

Apache License 2.0
330 stars 181 forks source link

Add support for apiKey securityDefinitionsObject #108

Closed boosh closed 5 years ago

boosh commented 7 years ago

This annotation doesn't produce valid output:

@Api(
  value = "/users",
  produces = "application/json",
  consumes = "application/json",
  authorizations = Array(new Authorization(value="apiKey"))
)

It should produce an accompanying securityDefinition object something like:

    "securityDefinitions" :  { 
      "apiKey": {
        "type": "apiKey",
        "name": "X-Auth-Token",
        "in": "header" 
      }
    },

Instead it just produces the following:

"security" : [ {
          "apiKey" : [ ]
        } ]

See the docs here.

Does the library not support API key security definitions (and if so please can it be added) or am I doing something wrong? If I post the above output into the swagger UI it complains there's no security definition for apiKey. The docs show it should take an in parameter and a name.

How can I annotate my API classes so that swagger-play generates the correct security definitions for an X-Auth-Token security header token?

There's an example of adding an API key definition here.

snhariharan commented 5 years ago

Any plans of getting this merged?

frantuma commented 5 years ago

192 introduces handling of both api key and oauth2 security definition support in play 2.6