swagger-ui-express persistAuthorization not working

Viewed 365

I have a very simple sample code using swagger-ui-express:

const express = require("express");
app = express();
app.listen(3000);

const swaggerUi = require('swagger-ui-express');

var options = {
    swaggerOptions: {
        persistAuthorization: true
    }
};

app.use('/doc',
    swaggerUi.serve, swaggerUi.setup(
        {
            "swagger": "2.0",
            "info": {
                "title": "Simple API overview",
                "version": "v2"
            },
            securityDefinitions: {
                BearerAuth: {
                    type: 'apiKey',
                    in: 'header',
                    name: 'Authorization'
                },
            },
        }
        ,
        options
    )
);

I am not able to mak persistAuthorization work, after entering anything in the authorization field, when refreshing the web page the authorization is deleted.

The code follows the documentation in https://www.npmjs.com/package/swagger-ui-express

And the persistAuthorization option is documented in https://swagger.io/docs/open-source-tools/swagger-ui/usage/configuration/

0 Answers
Related