Forum Discussion

rahuldwivedi's avatar
rahuldwivedi
New Contributor
5 years ago

JTW token is not getting passed in Swagger-ui

JWT token is not getting passed under 'Authorization' feild. Here's the full post https://stackoverflow.com/questions/63119252/jtw-token-is-not-getting-passed-in-swagger-ui
  • HKosova's avatar
    5 years ago

    Hi rahuldwivedi,

    Make sure your API definition includes the "security" key on the root level or in operations. For example:

    swagger: '2.0'
    securityDefinitions:
      ApiKeyAuth:
        type: apiKey
        in: header
        name: Authorization
    security:  # <-------------
      - ApiKeyAuth: []

    Check out our OpenAPI 2.0: API Keys guide for more examples.

  • HKosova's avatar
    HKosova
    5 years ago

    Replace

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

    with

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

     

    Swagger Editor is a YAML editor, but you can also paste JSON and import JSON files. JSON will be automatically converted to YAML. Then after you fixed the errors you can use the "File > Convert and save as JSON" command to export back to JSON.