markitosgv/JWTRefreshTokenBundle

support for NelmioApiDocBundle lost in version 1.0.0

Segaja opened this issue · 3 comments

Before updating to 1.0.0 using this bundle resulted in some routes being exposed as documentation to https://github.com/nelmio/NelmioApiDocBundle .

Now after the update these entries are gone from the apidoc. is that intentional?

It wasn’t ever explicitly supported, it just worked because the API doc bundle includes Symfony routes pointing to a valid controller. With the newer code using the authenticator system, there isn’t a controller to pick up on anymore.

You can add an entry to the API doc bundle’s config to get your login route to be documented. See lexik/LexikJWTAuthenticationBundle#361 (comment) and nelmio/NelmioApiDocBundle#1865 (comment) for more on that.

Hello @mbabker , thanks for that information. Sad that this doesn't happen automatically, but I'm fine doing it myself. Is there some place in the code where I can see what the required fields are and the possible return values in order to add them correctly to the documentation?

Never mind my previous point. For now I added

            /token/refresh:
                post:
                    summary: Get a new token by usage of the long living `refresh_token`.
                    description: THis endpoints takes a refresh token to generate a new `token` and return it with the still valid `refresh_token`.
                    requestBody:
                        required: true
                        content:
                            application/json:
                                schema:
                                    type: object
                                    properties:
                                        refresh_token:
                                            type: string
                    responses:
                        '200':
                            description: successful token refresh
                            content:
                                application/json:
                                    schema:
                                        type: object
                                        properties:
                                            token:
                                                type: string
                                            refresh_token:
                                                type: string
                        '401':
                            description: invalid `refresh_token`
                            content:
                                application/json:
                                    schema:
                                        type: object
                                        properties:
                                            code:
                                                type: int
                                            message:
                                                type: string
                                    examples:
                                        invalid_refresh_token:
                                            summary: Invalid refresh token
                                            value: {"code": 401, "message": "JWT Refresh Token Not Found" }

to config/packages/nelmio_api_doc.yaml, which should be enough.

Thanks for all the help.