• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
    • Questions
    • Teachers
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

141
Views
Swagger JS Authorise button not being displayed

My Authorise button is not being displayed in swagger ui so I can't add JWT for given request

I have already added the required files added components in which security schemes has been passed but still authorise button

I want to test api with swager but don't have a place to pass JWT token.

Swagger in utils

const express = require("express");
const { type } = require("express/lib/response");
const app = express();
const swaggerJsDoc = require("swagger-jsdoc");

const swaggerOptions = {
  definition: {
    openapi: "3.0.1",
    info: {
        title: "APIs",
        version: "1.0.0",
    },
    servers: [
        {
            url: `http://localhost:5000`
        }
    ],
    component:{
    securitySchemes: {
        bearerAuth: {
          type: "http",
          name: 'Authorization',
          scheme: "bearer"
        },
    }
  }
},
apis: ["./routes/*.js"],
};


const swaggerDocs = swaggerJsDoc(swaggerOptions);

module.exports = { swaggerDocs };


server.js

app.use("/api-docs",swaggerUi.serve,swaggerUi.setup(swaggerDocs));

Route

/**
 * @swagger
 * /api/user/update:
 *  put:
 *    requestBody:
 *          description: Random
 *          required: true
 *          content:
 *            application/json:
 *               schema:
 *                 type: object
 *               properties:
 *                 email:
 *                  type: string
 *               password:
 *                 type: string
 *          
 *      
 *    description: Used to register
 *    security:
 *        -bearer: []
 *    responses:
 *       '201':
 *          description: A succesfull response
 */
router.put("/update", auth, UserController.updateUser);

almost 3 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error