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

Converting strings into Swift safe names can lead to conflicts

Open czechboy0 opened this issue 2 years ago • 0 comments

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 into plus, ending up with plus1 and minus1 here

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.

czechboy0 avatar May 25 '23 09:05 czechboy0