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

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

Open
shrickus opened this issue Sep 5, 2018 · 0 comments

Comments

@shrickus
Copy link

shrickus commented Sep 5, 2018

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

@shrickus shrickus changed the title APIKey authorization disconnect when using SwaggerHub v2 definitions APIKey authorization header is missing when using SwaggerHub v2 definitions Sep 5, 2018
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

1 participant