premieroctet / next-crud

Full-featured CRUD routes for Next.js

Home Page:https://next-crud.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow Swagger security configuration

MinDBreaK opened this issue · comments

The current configuration of swagger does not allow the specification of the authentication methods.

Would it be possible to have a key to add the configuration. Maybe with the possibility to set regex to path that are affected by the authentication mechanism ? We have multiples endpoints that have different authentications (Oauth, JWT, Bearer)

The reference is here https://swagger.io/docs/specification/authentication/

I think something like :

{
    "name": {
        "options": [Options],
        "path": /Regex/
   } 
}

would translate to

components:
      securitySchemes:
          [name]:
              ...Options
security:
  [...names]

This would allow to use any authentication mechanism on all endpoints. However we would lose flexibility provided OpenApi.

A solution to avoid this would be to add a type-hinted callback that enforce the OpenApi schema (maybe with https://www.npmjs.com/package/openapi-types ?) but allows the mutation of the generated schema ?

I would be more in favor of a flexible way to do it, but might be a little bit more complicated