swift-openapi-generator
swift-openapi-generator copied to clipboard
Converting strings into Swift safe names can lead to conflicts
An example of a schema that today the generator produces non-compiling Swift code for, as both enum cases are named _1.
type: string
enum:
- "+1"
- "-1"
Some ideas of solving this:
- word-ify common symbols, so instead of turning
+into_, turn it intoplus, ending up withplus1andminus1here
It's likely that no solution will completely solve this problem, as it's always going to be possible to create a conflict, as not all characters that are valid as an OpenAPI name are valid as Swift identifiers, so some mapping is necessary.