We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Context: Server sends & expects int values for enum types, we want to use enum names in the Elm code.
Adding x-enum-varnames seems to be the recommended approach, but that leads to malformed Elm code being output.
x-enum-varnames
E.g., in src/Api/Data.elm:
src/Api/Data.elm
Expected:
intFromYesNoNa : YesNoNa -> Int intFromYesNoNa model = case model of YesNoNaUnknown -> 0 YesNoNaYes -> 1 YesNoNaNo -> 2 YesNoNaNa -> 999
Actual:
intFromYesNoNa : YesNoNa -> Int intFromYesNoNa model = case model of YesNoNaUnknown -> Unknown YesNoNaYes -> Yes YesNoNaNo -> No YesNoNaNa -> Na
5.0.0-SNAPSHOT, from nixpkgs (commit f75c8753d80959f6bf63237748e799849c74179f). Doesn't seem like a regression.
5.0.0-SNAPSHOT
f75c8753d80959f6bf63237748e799849c74179f
{ "openapi": "3.0.1", "info": {"title": "Hippo API", "version": "v1"}, "paths": {"/foo": {"get": {"tags": [], "summary": "x", "responses": {"200": {"description": "Success", "content": {"application/json": {"schema": {"$ref": "#/components/schemas/YesNoNa"}}}}}}}}, "components": { "schemas": { "YesNoNa": { "enum": [0, 1, 2, 999], "x-enum-varnames": ["Unknown", "Yes", "No", "Na"], "x-enum-descriptions": ["Unknown", "Yes", "No", "N/A"], "type": "integer" } } } }
$ openapi-generator-cli generate -i ./enumnames.json -g elm
elm make src/Api/Data.elm
or, using the latest master:
$ docker pull openapitools/openapi-generator-cli:latest $ docker run -v /home/rkb/projects/namedenums/:/host -it openapitools/openapi-generator-cli:latest generate -i /host/enumnames.json -g elm -o /host/dckr $ elm make dckr/src/Api/Data.elm
#5794
Looks like #917 added enum names support to the Java generator, with an updateEnumVarsWithExtensions() method
updateEnumVarsWithExtensions()
The text was updated successfully, but these errors were encountered:
👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
Sorry, something went wrong.
No branches or pull requests
Bug Report Checklist
Description
Context: Server sends & expects int values for enum types, we want to use enum names in the Elm code.
Adding
x-enum-varnames
seems to be the recommended approach, but that leads to malformed Elm code being output.E.g., in
src/Api/Data.elm
:Expected:
Actual:
openapi-generator version
5.0.0-SNAPSHOT
, from nixpkgs (commitf75c8753d80959f6bf63237748e799849c74179f
).Doesn't seem like a regression.
OpenAPI declaration file content or url
Generation Details
Steps to reproduce
elm make src/Api/Data.elm
or, using the latest master:
Related issues/PRs
#5794
Suggest a fix
Looks like #917 added enum names support to the Java generator, with an
updateEnumVarsWithExtensions()
methodThe text was updated successfully, but these errors were encountered: