BRIKEV / express-jsdoc-swagger

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

[BUG] Nested object schema definitions don't work #269

Open chladnefazole opened 2 months ago

chladnefazole commented 2 months ago

Describe the bug Nested object schema definitions don't work.

To Reproduce For example, I have interface:

export interface Example {
    id?: number,
    someObj: {
        prop1: number,
        prop2: number,
    }
}

I represent it like this:

/**
 * Object containing some stuff
 * @typedef {object} Example
 * @property {number} id - An ID
 * @property {object} someObj - Object containing properties
 * @property {number} someObj.prop1 - Property 1
 * @property {number} someObj.prop2 - Property 2
 */

Expected behavior example.someObj should show as an OBJECT containing some number properties.

Instead I get: image

ie. example.someObj is shown to have type number, and its description is not the one I set for it (Object containing properties), but instead it shows the description of someObj's last property (Property 2)

Desktop (please complete the following information):

markgarrigan commented 2 months ago

This works for me... Change your {object} in the Example definition to the actual definition of SomeObj

/**
 * @typedef {object} SomeObj
 * @property {number} id
 * @property {string} name
 * @property {number} age
 */

/**
 * @typedef {object} Example
 * @property {number} id
 * @property {string} name
 * @property {SomeObj} someObj
 */