-
Notifications
You must be signed in to change notification settings - Fork 17
feature request: Add support for int enums #279
Copy link
Copy link
Open
Description
Motivation
When translating from OpenAPI to Smithy, schemas that define enums with an integer type (e.g. type: integer + enum: [...]) are currently mapped to plain enum in Smithy which is incorrect.
Expected behavior
Given an OpenAPI schema like:
Status:
type: integer
enum: [0, 1, 2]
x-enum-varnames:
- PENDING
- ACTIVE
- ARCHIVEDThe generated Smithy model should be:
intEnum Status {
PENDING = 0
ACTIVE = 1
ARCHIVED = 2
}Current behavior
The same schema is currently translated into:
enum Status {
PENDING
ACTIVE
ARCHIVED
}Why x-enum-varnames?
OpenAPI itself does not support named integer enums directly.
The common convention (used by OpenAPI Generator, Swagger Codegen, etc.) is to combine:
type: integer
enum: [...]
x-enum-varnames: [...] (vendor extension to preserve symbolic names)This provides both wire values (integers) and stable names for code generation.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels