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

Non-Object Components for Enums

Open ogunoz opened this issue 3 years ago • 0 comments

The types of the components are always assumed to be object. Generally, enums are allowed to be components and they can have integer or string types.

Example enum component:

"SomeType":{"title":"SomeType","enum":["TYPE_1","TYPE_2","TYPE_3"],"type":"string","description":"An enumeration."} 

Assumption is made here in transforms/components/index.js (line 82 -> type:'object')

return {
    [typedef.name]: {
      ...combineSchema(elements),
      description: schema.description,
      ...(requiredProperties.length ? {
        required: formatRequiredProperties(requiredProperties),
      } : {}),
      type: 'object',
      properties: formatProperties(propertyValues, options),
    },
  };

Would be great if @typedef {string} creates a string type

ogunoz avatar Dec 04 '21 00:12 ogunoz