Surnet / swagger-jsdoc

Generates swagger/openapi specification based on jsDoc comments and YAML files.
MIT License
1.69k stars 228 forks source link

Square Bracket in JSDoc @param issue #329

Closed sephentos closed 1 year ago

sephentos commented 2 years ago

When using square brackets in @param to define optional parameters within JSDoc (e.g. @param {Request} [request]) the whole @swagger annotation will not get processed.

    /**
     * Description
     *
     * @private
     * @async
     * @param {Request} [request]
     * @param {JSONResponse} [response]
     * @memberof SftpgoController
     * @swagger
     * /v1/getToken:
     *  get:
     *   security: []
     *   tags:
     *    - getToken
     *   responses:
     *    '200':
     *     description: successful operation
     *     content:
     *      application/json:
     *       schema:
     *        type: object
     *        properties:
     *         success:
     *          type: boolean
     *         data:
     *          type: object
     *          items:
     *          properties:
     *           access_token:
     *            type: string
     *            example: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
     *           expires_at:
     *            type: string
     *            example: '2022-09-04T06:17:59Z'
     *           current_time:
     *            type: string
     *            example: '2022-09-04T06:17:59Z'
     */

No console logs are being printed, the /v1/getToken path is just completly missing.

Removing the square brackets (@param {Request} [request] -> @param {Request} request) makes it work again and the spec is available again.

Using swagger-jsdoc 6.2.5 with swagger-ui-express

daniloab commented 2 years ago

Hi @sephentos

Could you provide a repo example with this error?

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.