cancel
Showing results for 
Search instead for 
Did you mean: 

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

New Member

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 1
Highlighted
Moderator

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

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

Helen Kosova
SmartBear Technical Writer
________________________

 Join SmartBear Connect next April in Boston to meet with software development, API and testing experts from around the world! Get your ticket today!