typeconv icon indicating copy to clipboard operation
typeconv copied to clipboard

TS -> OAPI single example

Open accordionpeas opened this issue 3 years ago • 1 comments

Hello,

Firstly, thank you for this fantastic project.

I have noticed a small bug when converting from TS to OAPI and using the @example annotation.

If I have the following TS:

type MyType = {
  /**
   * My description
   * @example: test1
   * @example: test2
   */
  myProp: string
}

Then the examples are correctly converted to:

"examples": [
  "test1",
  "test2"
]

However, if there is only 1 example annotation e.g.

type MyType = {
  /**
   * My description
   * @example: test1
   */
  myProp: string
}

Then it is incorrectly converted to:

"examples": "test1"

It should either still be an array with 1 item, or:

"example": "test1"

Thanks very much!

accordionpeas avatar Nov 03 '22 10:11 accordionpeas

This should depend on the version of OpenAPI Spec that is being generated. In v3.1.0, example is deprecated. However, in v3.0.0 examples is not even valid, there is only example.

gregbacchus avatar Jun 06 '24 03:06 gregbacchus