Re-use jsdoc's @typedef into swagger-jsdoc

Viewed 259

Context :

  • node.js
  • Open Api 3
  • express, swagger-jsdoc

I use jsdoc's @typdef to have Intellisens autocompleting with VSCode :

/** @typedef {number} Id */

/**
 * @typedef Data
 * @property {Id} requestId
 */

/** @type {Data} */
const data = { id: 42 };

Issue :

I've just installed swagger-jsdoc and set it up into express.

Now i would like to re-use the @typedef Data and @typedef Id created above into swagger route description as following :

/**
 * @swagger
 * 
 * /cats:
 *      get:
 *          description: Search any cat from all parameters in query
 *          produces:
 *              - application/json
 *          parameters:
 *              - name : requestId
 *                in: query
 *                required: false
 *                type: Id <========================== HERE
 *         responses:
 *              200:
 *                  description: cats
 *                  schema:
 *                      type: Data <================== HERE
 */
 router.get('/cats', catsFilter);

This sample is not working.

Do you know a way to re-use jsdoc's @typedef into swagger-jsdoc ?

0 Answers
Related