Forum Discussion

Dhinesh's avatar
Dhinesh
New Member
5 years ago

After I specified my field as required , still swagger request is sent without that field

/**
* @swagger
* paths:
*   tags:
*     - name: Email
* /order_email:
*   post:
*     tags:
*       - Emailendpoints
*     description: this endpoint is used to send email
*     consumes:
*       - application/json
*     parameters:
*       - name: body
*         in: body
*         schema:
*           type: object
*           required:
*             - order_id
*             - email
*           properties:
*             order_info_id:
*               type: integer
*               required: true
*             email:
*               type: string
*               required: true
*             host:
*               type: string
*     responses:
*       200:
*         description: User found and logged in successfully
*       401:
*         description: Bad username, not found in db
*       403:
*         description: Username and password don't match
*/

I'm using swagger jsdoc 

1 Reply

  • HKosova's avatar
    HKosova
    SmartBear Alumni (Retired)

    Try changing your annotations as follows. Note that "required" is not a property attribute, it's an object-level attribute that contains the list of required properties.

    *           type: object
    *           required:
    *             - order_info_id
    *             - email
    *           properties:
    *             order_info_id:
    *               type: integer
    *             email:
    *               type: string
    *             host:
    *               type: string