Skip to content

Supprt for const keyword #252

@d-kimuson

Description

@d-kimuson

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: OAI/OpenAPI-Specification#1313 (comment)

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: OpenAPITools/openapi-generator#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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions