apigee-127 / swagger-node-runner

The heart of Swagger-Node
MIT License
102 stars 123 forks source link

Setting global security definitions does not work. #106

Open randomcatgamer opened 7 years ago

randomcatgamer commented 7 years ago

Using the global security definition does not work.

...
securityDefinitions:
   APIKeyHeader:
     type: apiKey
     in: header
     name: X-jwttoken
security:
        - APIKeyHeader: []
...
/someendpoint:
    x-swagger-router-controller: someendpoint
    get:
      description: a description
      operationId: someendpointMethod
      produces:
        - application/json
      parameters:
        - name: X-jwttoken
          in: header
          description: jwt wso2 token
          required: false
          type: string
      responses:
        '200':
          description: Success

The error I get is: __Cannot read property 'type' of undefined","stacktrace":"TypeError: Cannot read property 'type' of undefined
at getScopeOrAPIKey (D:\devcat\dev_workspace\workspace\backend-marketplace-productactivation\node_modules\swagger-node-runner\fittings\swagger_security.js:80:25) at andCheck (D:\devcat\dev_workspace\workspace\backend-marketplace-productactivation\node_modules\swagger-node-runner\fittings\swaggersecurity.js:51:43)

If I put the security definition within each of my paths (instead of global) it works.

Also, with swagger-node-mw 0.1.0 the global definition works.

benishak commented 6 years ago

I have the same issue

I get this error

{"message":"Cannot read property 'type' of undefined"}
benishak commented 6 years ago

@theganyo do you mind having look into this?

theganyo commented 6 years ago

Hey Ben. I see you're pushing for a new Sway release. If that can happen, it would solve everything in one fell swoop, so that would be best.

benishak commented 6 years ago

Yes hopefully that happens soon! Thanks.