-
-
Notifications
You must be signed in to change notification settings - Fork 6.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
[BUG] [Ruby] enum with value 'end' causes runtime syntax error #11350
Comments
Workaround: Put the following in a shell script:
Then add that as a postprocess step:
Then postprocess your ruby client libraries:
|
With 7.2 you need to use the following postprocess.sh file
|
thanks for sharing the workaround. I've filed #17537 to add enum name mapping feature to the Ruby generators so one can map |
Thanks @wing328 I look forward to testing this when 7.3.0 is released. Cheers! |
Bug Report Checklist
Description
I have an openapi template with an enum with a value of
end
. While code generation succeeds, the generated code is not compatible with ruby (tested under 2.7.0, 3.0.2 gave me a different error).openapi-generator version
Not a regression as far as I know. I didn't see any closed bugs describing the issue.
OpenAPI declaration file content or url
Here's the script code (it is pulled from the readme):
Generation Details
Steps to reproduce
ruby -Iruby/lib script.rb
You get the error message:
Looking at user_action_phase.rb:
If you change
END = "end".freeze
toEND1 = "end".freeze
then ruby can execute.I tried looking at the templates to modify how the enum was generated but couldn't figure out how to change it with just a template. I also looked at changing the value in the openapi yaml file, but enums don't support any metadata (the value that is passed to the endpoint needs to be
end
, unfortunately).Related issues/PRs
I didn't see any related issues.
https://stackoverflow.com/questions/66465888/how-to-define-enum-mapping-in-openapi has some suggestions, but it doesn't look like x-enum-varnames is supported: https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/ruby.md
Suggest a fix
Maybe I could use
RUBY_POST_PROCESS_FILE
to postprocess the file? I'm not familiar with the ruby codegen process, but https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractRubyCodegen.java looks like it hasend
as a reserved word. Maybe there's an enum processing in https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java#L670 that needs to be modified? Or allowableValues needs to handle uppercase? I'm speculating here.The text was updated successfully, but these errors were encountered: