openapi-typescript icon indicating copy to clipboard operation
openapi-typescript copied to clipboard

Please add support for x-enumNames and x-enumDescriptions in upcoming v 7

Open alex-aveva opened this issue 2 years ago • 3 comments

Description

The most popular (and de-facto standard) .NET Core OpenAPI NSwag package uses the following:

  • x-enumNames for x-enum-varnames
  • x-enumDescriptions for x-enum-descriptions

Proposal

Adapting the code can be as simple as shown below:

https://github.com/drwpow/openapi-typescript/blob/43b1b69bc26ee333d0fed1f4aa702496c485dc01/packages/openapi-typescript/src/transform/schema-object.ts#L128

        name: schemaObject["x-enum-varnames"]?.[i] ?? schemaObject["x-enumNames"]?.[i],
        description: schemaObject["x-enum-descriptions"]?.[i] ?? schemaObject["x-enumDescriptions"]?.[i],

Checklist

alex-aveva avatar Oct 30 '23 22:10 alex-aveva

I’d be open to this! This is an easy add.

Also if you do submit a PR, then make sure to update the corresponding docs that mention x-enum-varnames as well.

drwpow avatar Oct 30 '23 23:10 drwpow

That's great, I'll create a PR!

alex-aveva avatar Oct 30 '23 23:10 alex-aveva

I think this issue can be closed. Support for these was originally added in c947515.

duncanbeevers avatar Jul 24 '24 17:07 duncanbeevers