swift-openapi-generator icon indicating copy to clipboard operation
swift-openapi-generator copied to clipboard

Enum and OpenAPIGenerator

Open iDevPro opened this issue 8 months ago • 3 comments

Question

Hello, how to build enum Int raw value but named cases like:

enum SizeValue: Int {
    case mini = 10
    case mid = 30
    case max = 100
}

with OpenAPI 3.x and swift-openapi-generator ;) Thx for answer :)

iDevPro avatar Jun 11 '25 21:06 iDevPro

Hi @iDevPro,

the OpenAPI specification doesn't support naming raw enum cases, so there isn't much that Swift OpenAPI Generator can do.

I recommend just adding a large comment for the schema itself and documenting the raw values there, which will get included in the doc comment above the generated enum.

czechboy0 avatar Jun 11 '25 21:06 czechboy0

I found some answer, but not applicable yet in this generator :)

Image

iDevPro avatar Jun 13 '25 10:06 iDevPro

Yeah those are vendor extensions. These aren't part of the specification, they're just extra annotations that specific tools might look for.

czechboy0 avatar Jun 13 '25 10:06 czechboy0