Surnet / swagger-jsdoc

Generates swagger/openapi specification based on jsDoc comments and YAML files.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Square Bracket in JSDoc @param issue

sephentos opened this issue · comments

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

Hi @sephentos

Could you provide a repo example with this error?

commented

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.