Skip to content

[Swift] Incorrect generation emun type for swift language #3934

@razalur

Description

@razalur
Description

Hello! I generate client for swift language. There is incorrect swift language syntax generated for enum type.

For example for this json code:

{
  "basePath": "/myPath",
  "definitions": {
    "SomeValue": {
      "properties": {
        "level": {
          "description": "word (1 = Simple1 , 2 = Simple2 , 3 = Simple3 , 4 = Simple4 )",
          "enum": [
            1,
            2,
            3,
            4
          ],
          "format": "int32",
          "type": "integer"
        }
      },
      "type": "object"
    }
  },
  "paths": {},
  "swagger": "2.0"
}

I've got this swift code for enum type "Level":

public enum Level: String { 
        case 1 = "1" 
        case 2 = "2"
        case 3 = "3"
        case 4 = "4"
    }

As you can see there are numbers after "case" keywords. But this is not correct syntax for swift (compiler error: "Expected identifier in enum 'case' declaration"). Unfortunately I can't change my json to avoid this. May be it is possible to change somehow the logic for swift code generation to get right solution?

Best regards,
Aleksey Razzhivaykin

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions