BRIKEV / express-jsdoc-swagger

Swagger OpenAPI 3.x generator
https://brikev.github.io/express-jsdoc-swagger-docs/#/
MIT License
216 stars 30 forks source link

[BUG] Optional keys of json body cannot be specified using .form syntax #199

Open hmsgit opened 2 years ago

hmsgit commented 2 years ago

Description Json object type required body may contain optional keys. This should be documentable both using the interface notation and form options.

To Reproduce

/**
 * @param {object} request.body.required - Body of the request - application/json
 * @param {string} key.form.required - Key
 * @param {number} value.form.required - Value
 * @param {string} otherThing.form.optional - Other meta info. // or otherThing.form
 */

Expected behavior Above should make otherThing as optional in the schema: { key: string, value: number, otherThing?: string} Currently they all are required when specified with form.

However, it works when the form data is moved to Body type and then included as:

/**
 * @param {SomeRequestBody} request.body.required - ...
 */

where SomeRequestBody is defined as

/**
 * SomeRequestBody type
 * @typedef {object} SomeRequestBody
 * @property {string} key.required - Some key
 * @property {string} value.required - Some value
 * @property {string} otherThing - Other meta info
 */

Desktop (please complete the following information):

musqdp commented 2 years ago

any updates?