express-jsdoc-swagger icon indicating copy to clipboard operation
express-jsdoc-swagger copied to clipboard

Syntax for specifying JSON object fields and nested objects in one place

Open ciprian1234 opened this issue 3 years ago • 3 comments

Currently I believe if we want to specify JSON body fields of a POST/PUT request we need to create a separate object with @typedef keyword. Its would be nice to support following syntax.

/**
 * POST /item
 * @summary Create item
 * @param {object} request.body.required - object info
 * @param {string} request.body.field1.required - field1 info (required)
 * @param {string} request.body.field2 - field2 info
 * @param {object} request.body.field3.required - field3 info (required)
 * @param {string} request.body.field3.subfield1 - field3.subfield1 info
 * @param {string} request.body.field3.subfield2.required - field3.subfield2 info (required)
 *
 */

So in this case the POST /item endpoint should expect an object like this

{
  field1: 'data', // required field  
  field2: 'data',  
  field3: {  
    subfield1: 'data',  
    subfield2: 'data', // required field  
  },  
};

ciprian1234 avatar Mar 31 '22 08:03 ciprian1234

I agree this is a big missing feature right now. As it stands now, any large-ish API's docs will be bloated with typedefs of the request bodies. Specifying them inline would fix the issue.

wbw20 avatar Apr 10 '22 18:04 wbw20

Any update on this?

sjmunoz avatar May 03 '23 06:05 sjmunoz

Upvote. I also came here to open an issue like this

madilekci-avena avatar Mar 07 '24 13:03 madilekci-avena