jack13
jack13

Reputation: 67

Swagger bearerAuth token block request from UI

I am using the swagger UI interface to test my node js requests. I added the Authentication for those requests but when I try them in swagger I have the following issue: If I add a bearerAuth token in the swagger UI When I click on execute in one of my requests, they are not executed. If I don't put a bearerAuth token my request plays as intended.

To add a token I added those options :

const openApi = OpenAPI({
    schema,
    info: {
      title: '**** API',
      version: '1.0.0',
    },
    components: {
      securitySchemes: {
        bearerAuth: {
          type: 'http',
          scheme: 'bearer',
          bearerFormat: 'JWT',
        },
      },
    },
    security: {
      bearerAuth: [],
    },
  });

Upvotes: 1

Views: 980

Answers (1)

Helen
Helen

Reputation: 97540

security must be an array:

    security: [
      { bearerAuth: [] }
    ],

Upvotes: 4

Related Questions