Skip to content

[SWIFT4] Bug when generating a client from a declaration containing reserved words #6919

@nascob

Description

@nascob
Description

I am trying to generate a Swift 4 client from a declaration that has a response attribute named throw. I believe since that is a reserved word in Swift and it has not been escaped - the generated client does not compile.

Swagger-codegen version

I have tried with the current stable version for mac: 2.2.3, 2.3.0 (SNAPSHOT) and 3.0.0 (SNAPSHOT)

Swagger declaration file content or url

OpenDotaApi Swagger file https://api.opendota.com/api

Command line used for generation

swagger-codegen generate -l swift4 -i https://api.opendota.com/api

Steps to reproduce
  1. Run the generation command above.
  2. Inspect SwaggerClient/Swaggers/Models/InlineResponse200.swift (line 94)
Related issues/PRs

I did not find any.

Suggest a fix/enhancement

It seems like there's no escape/prefix for reserved words in Swift generation. A simple fix would be prefixing it by an underscore symbol.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions