Coder Social home page Coder Social logo

Comments (2)

crbast avatar crbast commented on May 26, 2024 5

HeyπŸ‘‹πŸΌ,
I have a functional solution but not perfect:

  1. Add this code in config/swagger.js in the securityDefinitions section.
bearerAuth: {
   type: 'apiKey',
   in: 'header',
   name: 'Authorization'
},
  1. In the same file add this code to the options section.
securitySchemes: {
   bearerAuth: {
      type: 'http',
      scheme: 'bearer',
      bearerFormat: 'JWT'
   }
},

PS : You can change bearerAuth by JWT

  1. Add a new security element to your documentation.
    ex:
* /api/auth:
*  post:
*      tags:
*          - Auth
*      security:
*          - bearerAuth: []
*      summary: Auth JWT login
*      . . .
  1. In swagger : Before the token add Bearer. Ex: Bearer <your-token>

image

Have a nice day!

swagger.zip -> full file config/swagger.js

from adonis-swagger.

AndersonGuilherme avatar AndersonGuilherme commented on May 26, 2024

how to configure swagger with JWT to make requests with a token?

from adonis-swagger.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.