openapi-ts / openapi-typescript

Generate TypeScript types from OpenAPI 3 specs
https://openapi-ts.dev
MIT License
5.9k stars 471 forks source link

Enum extensions - format description as jsdoc instead of comments #1984

Open DavidDeSloovere opened 2 weeks ago

DavidDeSloovere commented 2 weeks ago

Description

Using the enum extension --enum, the description of enum values is now written as a // comment. It also doesn't handle new lines correctly.

enum ErrorCode {
  // User is not authorized
  Unauthorized = 100
  // User has no access to this resource
  AccessDenied = 200
  // Something went wrong line 1
This is line 2
This is line 3
  Unknown = 300
}

Proposal

The description could be written as jsdoc, improving DX when using the client. This could also handle new lines correctly.

enum ErrorCode {
  /** User is not authorized */
  Unauthorized = 100
  /** User has no access to this resource */
  AccessDenied = 200
  /** 
   * Something went wrong line 1
   * This is line 2
   * This is line 3 
   */
  Unknown = 300
}

Checklist

If you can give me some instruction on where to start and how to format jsdocs correctly, I could probably make this work.

gzm0 commented 1 week ago

Sounds very reasonable to me (@drwpow ?)