Description
Motivation
I am stealing this request entirely from this request which resulted in a change to the Go cli.
Given the following enum spec:
enum:
- HDD
- SSD
- NVME
type: string
The Swift client generator will generate an enum that does strict == comparisons, so if the specified API returns NVMe instead of NVME, the response will fail validation because "NVMe" != "NVME".
In my case specifically I needed it for state codes where someone may write "WA" or "Wa"
Proposed solution
The Java generator supports a useEnumCaseInsensitive
option; The Go generator supports a option via the x-go-enum-ci
extension.
When that option is enabled, the generator will use case-insensitive equality checks for string enums. Copying that feature into the Swift generator would enable generator users to opt in to case-insensitive comparisons for string enums.
Alternatives considered
Certainly can smooth this out by cleaning up server side implementation. Have tried a spec like
StateOrProvince:
type: object
oneOf:
- $ref: '#/components/schemas/KnownStateOrProvince'
- $ref: '#/components/schemas/UnknownStateOrProvince'
UnknownStateOrProvince:
type: string
KnownStateOrProvince:
type: string
enum:
- AL
- AK
- AZ
But while that fixes parsing it does not allow me to recognize "Wa" as .WA.
Additional information
No response