openapi2aspida icon indicating copy to clipboard operation
openapi2aspida copied to clipboard

Supprt for `const` keyword

Open d-kimuson opened this issue 2 years ago • 0 comments

Description

From OpenAPI 3.1, the const keyword was added as a way to represent a single literal value. What was written with "enum": ["val"], "type": "string" can now be written with "const": "val", "type": "string".

ref: https://github.com/OAI/OpenAPI-Specification/issues/1313#issuecomment-533637768

The OpenAPI generation tool I use writes out single literal values as const (specifically ElysiaJS's swagger plugin) and openapi2aspida does not generate the proper type, so I created a feature request.

A feature request has been added to a similar tool, openapi-generator.

ref: https://github.com/OpenAPITools/openapi-generator/issues/10445

Describe the solution you'd like

Describe alternatives you've considered

We can work around it by writing a single value to be passed to the enum as before, but there is no workaround if, like me, we have not written the specification manually and the code generation tool writes it out in this form. It may be possible to force substitution, but it is tough.

Additional context

d-kimuson avatar Jan 07 '24 08:01 d-kimuson