Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

224
Vistas
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);

over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda