swagger-api / swagger-api/swagger-codegen
[Swift4] Class name conflicts not handled
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I have one of my swagger models named 'Locale' which has custom properties. I cannot change this definition as it was used in our backend and android code for years. In the generated swift4 client file, CodableHelper there is a DateFormatter object created, and locale is set on it. The problem is that swift is using my custom Locale class instead of the one from Foundation here.
Swagger-codegen version
swagger-codegen-cli-2.3.0-20171207.164637-326.jar
Swagger declaration file content or url
Command line used for generation
java -jar swagger-codegen-cli-2.3.0-20171207.164637-326.jar generate -l swift4 -i file.yaml -o client
Steps to reproduce
Use a model like Locale which is named same as a Foundation class that is used
Related issues/PRs
Suggest a fix/enhancement
If a class name is the same as Foundation, use the Foundation namespace prefix while using it: e.g.
formatter.locale = Foundation.Locale(identifier: "en_US_POSIX")
instead of
formatter.locale = Locale(identifier: "en_US_POSIX")
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The generated Swift4 client’s CodableHelper file is the reproduction point; start by tracing the Swift4 template that emits its DateFormatter locale reference. Generate a client from a model named Locale using the command in the issue, and confirm the output uses the Foundation-qualified type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100