Skip to content

APIKey authorization header is missing when using SwaggerHub v2 definitions #8

@shrickus

Description

@shrickus

I'm trying to connect to some server-side code generated from SwaggerHub, using swagger v2.0 syntax. While the server code seems to work fine, the client node only receives 403 denied responses, since the client never sends the X-API-Key in the request header. I believe this is a bug in this code that I just commented on (the scheme object has undefined "keyname" and "passAs" properties).

  switch(scheme.type) {
    case 'apiKey':
        node.swaggerClient.clientAuthorizations.add(scheme.name,
            new SwaggerClient.ApiKeyAuthorization(scheme.keyname, password, scheme.passAs));
        break;

The relevant securityDefinitions section of the swagger.json file looks like this:

  "securityDefinitions" : {
    "BasicAuth" : {
      "type" : "basic"
    },
    "ApiKeyAuth" : {
      "type" : "apiKey",
      "name" : "X-API-Key",
      "in" : "header"
    },
  },

Since every endpoint is using the same security key, the global security object is defined as:

  "security" : [ {
    "ApiKeyAuth" : [ ]
  } ],

Please let me know what is missing -- or how I can debug this missing header key!
__
Steve

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions