ts-json-schema-generator icon indicating copy to clipboard operation
ts-json-schema-generator copied to clipboard

JsDoc support parameter descriptions

Open NojusM opened this issue 1 year ago • 2 comments

The ts-json-schema-generator currently supports comments placed above properties, converting them into the corresponding description in the schema. However, it does not support adding descriptions for properties directly in the root JsDoc or inline. It would be a significant improvement to include either of these features, as the current approach of adding comments above each property can make TypeScript types harder to read and maintain.

Current situation

Works

Root comment

/** List of favorite fruit */
export type FruitList {
  apple: number
  tomato: number
  pear: number
}

Property comment above

/** List of favorite fruit */
export type FruitList {
  apple: number
  /** It's a fruit? */
  tomato: number
  /** Must not be more than 1000 */
  pear: number
}

Doesn't work, but would be amazing if it did

Description of properties in root comment

/** 
List of favorite fruit 
@tomato It's a fruit?
@pear Must not be more than 1000
*/
export type FruitList {
  apple: number
  tomato: number
  pear: number
}

Inline comments

/** List of favorite fruit */
export type FruitList {
  apple: number
  tomato: number /** It's a fruit? */
  pear: number /** Must not be more than 1000 */
}

NojusM avatar Aug 22 '24 15:08 NojusM