quicktype-vscode icon indicating copy to clipboard operation
quicktype-vscode copied to clipboard

Incorrect variable names generated for Swift

Open aswathr opened this issue 3 years ago • 0 comments

Trying to generate object models result in weird behaviour for Swift. For example, I expect the following JSON:

{  
    "teamId": "$ùp@n0v@",
    "teamspaceId": 12345,
    "team_name": "supernova"
}

to generate a model like:

struct Untitled2 {
    let teamId: String
    let teamspaceId: Int
    let team_name: String
}

however, I get this:

struct Untitled2 {
    let teamID: String        // The 'd' in teamId is automatically uppercased
    let teamspaceID: Int         // Same as above
    let teamName: String        // The underscore is removed here and the var name is automatically camel-cased
}

Ok, so I checked the web version of quick type and it seems to generate the CodingKeys along with the code, which is neat, but it seems to be missing in the vs-code version

aswathr avatar Apr 11 '21 17:04 aswathr