Search code examples
node.jsexpressapi-doc

How can we point that field is optional / mandate in apidocjs?


We are working on expressJS and apidocJS, not able to define the optional fields in the table. we would like to update the fields are mandate or not so that users can identify the params requirements.

sample code :

 * @apiParam {String} name The User Name.
 * @apiParam {String} email The Email Id.
 * @apiParam {String} password The Users High security Password.
 * @apiParam {String} privilegeRole The Users Privilege Role.

Solution

  • * @apiParam {String} [optional_field] This field is optional.
    * @apiParam {String} required_field This is required.
    

    The square bracket in the field name will say it is optional in apidoc

    [field] - Fieldname with brackets define the Variable as optional.