Timur
Timur

Reputation: 498

API documentation with swagger

I have a project on symfony4 with api-platform. Login process described in security.yaml here is it:

security:
encoders:
    App\Entity\User: bcrypt
providers:
    our_db_provider:
        entity:
            class: App\Entity\User
            property: email
firewalls:
    ....
    login:
        pattern: ^/login
        stateless: true
        anonymous: true
        json_login:
            check_path: /login
            success_handler: lexik_jwt_authentication.handler.authentication_success
            failure_handler: lexik_jwt_authentication.handler.authentication_failure
            username_path: email
        logout:
            path:   /logout
            target: /
    api:
        pattern: ^/
        stateless: true
        guard:
            authenticators:
            - lexik_jwt_authentication.jwt_token_authenticator
        ....

For all my models I have pretty built-in swagger-ui and also I can add some attributes for it. But how I can describe request for login? I've seen Swagger / Open API Supportthis doc but it is really I should provide raw array with description? May be it is better make it in some of yaml config for custom pages? And last question. Where I can find structure for this array?

Upvotes: 0

Views: 531

Answers (1)

Kévin Dunglas
Kévin Dunglas

Reputation: 3024

Because it's a custom entrypoint from the library point of view, you'll have to decorate the Swagger documentation generator as described in this documentation entry to add the definition of the login entrypoint: https://api-platform.com/docs/core/swagger/#overriding-the-swagger-documentation

There are currently no other solutions. Adding a new configuration option to allow injecting some YAML would be nice (PR welcome!)

Upvotes: 1

Related Questions