-
Notifications
You must be signed in to change notification settings - Fork 6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Swift4] Class name conflicts not handled #7148
Comments
What about automatically renaming |
The problem with that is fields are usually named after classes and Json deserialization would stop working if the java(backend) and swift models have different names |
Without breaking serialization/deserialization, the field can be named differently independent of how the model is named. I know other generators (e.g. Ruby, PHP, Java) can handle this but not sure about Swift4. Disclaimer: no expert in Swift |
I'm not sure either. If this approach works, that should be fine too |
I'll file a PR after 2.3.0 release, which is scheduled this week. |
Has there been any progress with this issue? I seem to be having the same issue with a model named "Notification" in my swagger doc. |
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")
The text was updated successfully, but these errors were encountered: