Skip to content

OpenAPI security #321

Closed
Closed
@Azzerty23

Description

@Azzerty23

Is your feature request related to a problem? Please describe.
As I'm transitioning from FastAPI to Zenstack, I'm used to have the generated Swagger UI with authentication built-in. For endpoints requiring auth, there is a padlock to identify them. I would love to have the same within Zenstack.

Describe the solution you'd like
Ideally, I would like an automatic addition of an empty security field in the generated schema when the model/operation (endpoint) doesn't require any authentication (e.g. for a model with the @@allow('create', true) attribute).

Describe alternatives you've considered
Add manually a security field in @@openapi.meta attribute.
E.g:

    @@openapi.meta({
        description: 'A user of the pet store',
        create: {
            description: 'I would like to disable Swagger UI authentication for this operation',
            security: []   <--- here
        },
    })

Additional context

  1. When I add this in the generated specification :

Capture d’écran 2023-03-31 à 15 12 12

  1. It removes the authentication check :
    Capture d’écran 2023-03-31 à 15 12 28

Working example : https://github.com/Azzerty23/petstore-openapi-zenstack

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions