-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
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] Default values for ENUMs are using strings instead of the enum #652
Labels
Milestone
Comments
I wonder if this could be related to my issue 😦 |
4 tasks
grEvenX
added a commit
to grEvenX/openapi-generator
that referenced
this issue
Jul 26, 2018
This fixes an issue that makes the swift 4 api client fail to compile when using enums with a default value. The fix changes the toDefaultValue method to check if the property is of enum type, and then returns a properly formatted value. Looking into the code, I wonder why toEnumDefaultValue is not being used here, which seems to be the case for the java implementation.
@wing328 What's needed to "tag'n bag" this issue? :) |
wing328
pushed a commit
that referenced
this issue
Sep 9, 2018
This fixes an issue that makes the swift 4 api client fail to compile when using enums with a default value. The fix changes the toDefaultValue method to check if the property is of enum type, and then returns a properly formatted value. Looking into the code, I wonder why toEnumDefaultValue is not being used here, which seems to be the case for the java implementation.
jaumard
pushed a commit
to jaumard/openapi-generator
that referenced
this issue
Sep 21, 2018
…#656) This fixes an issue that makes the swift 4 api client fail to compile when using enums with a default value. The fix changes the toDefaultValue method to check if the property is of enum type, and then returns a properly formatted value. Looking into the code, I wonder why toEnumDefaultValue is not being used here, which seems to be the case for the java implementation.
This was resolved in pull-request #656 and released in v3.3.0 |
A-Joshi
pushed a commit
to ihsmarkitoss/openapi-generator
that referenced
this issue
Feb 27, 2019
…#656) This fixes an issue that makes the swift 4 api client fail to compile when using enums with a default value. The fix changes the toDefaultValue method to check if the property is of enum type, and then returns a properly formatted value. Looking into the code, I wonder why toEnumDefaultValue is not being used here, which seems to be the case for the java implementation.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
OpenAPI 3.0.0 has support for strings in
enum
format. The Swift4 generator maps these intoenum
in the Swift code which works fine. However if you provide adefault
value in the OpenAPI document, the values for the properties of enum types are set as strings instead of the enum which again causes the compiler to fail.openapi-generator version
3.1.2
OpenAPI declaration file content or url
https://gist.github.com/grEvenX/76d508f2933456894492c38410b1ac49
Command line used for generation
docker run --rm -v $(pwd)/generated:/out openapitools/openapi-generator-cli:latest generate -i https://gist.githubusercontent.com/grEvenX/76d508f2933456894492c38410b1ac49/raw/6e3a93cc3bc219815769a21fdcad84628ab0af59/example.yaml -g swift4 -o /out/swift4
Steps to reproduce
generated/swift4/OpenAPIClient/Classes/OpenAPIs/Models/NewPet.swift
Suggest a fix/enhancement
The generated model contains the line:
The correct value that should be assigned to
animal
in this case is:The text was updated successfully, but these errors were encountered: