Home > Software engineering >  Swagger 3.0 - cannot add parameters to query parameter
Swagger 3.0 - cannot add parameters to query parameter

Time:12-17

I have node express application and am using swagger-jsdoc & swagger-ui-express

Inside router I place this code:

/**
 * @swagger
 * /get:
 *  get:
 *      tags: [ /api/roba/get ]
 *      summary: Vraca informacije o robi po datom id-u
 *      description: Vraca informacije o robi po datom id-u
 *      parameters:
 *          - name: robaid
 *      responses:
 *          400:
 *              description: Nije prosledjen parametar robaid
 */

And it does work normally, however when I try adding description or anything else under - name it doesn't display that endpoint.

I get error YAMLSemanticError: Implicit map keys need to be on a single line at line 7, column 18: - name: robaid

Code that does not work (I tried only with required or description thinking one of these do not work but not working):

/**
 * @swagger
 * /get:
 *  get:
 *      tags: [ /api/roba/get ]
 *      summary: Vraca informacije o robi po datom id-u
 *      description: Vraca informacije o robi po datom id-u
 *      parameters:
 *          - name: robaid
 *          required: true
 *          description: Some description
 *      responses:
 *          400:
 *              description: Nije prosledjen parametar robaid
 */

CodePudding user response:

You are seeing the issue as the indentation isn't correct on lines of required and description, you can try the code below:

/**
 * @swagger
 * /get:
 *  get:
 *      tags: [ /api/roba/get ]
 *      summary: Vraca informacije o robi po datom id-u
 *      description: Vraca informacije o robi po datom id-u
 *      parameters:
 *          - name: robaid
 *            required: true
 *            description: Some description
 *      responses:
 *          400:
 *              description: Nije prosledjen parametar robaid
 */

Hope it helps!

  • Related