[ruby-nextgen] Fix enumUnknownDefaultCase mapping and numeric enum constant casing (#24996)
PR
1mo ago+46+46+01234567890123456789-4-4-0123456789
Fixes #24996
When enumUnknownDefaultCase=true is enabled for ruby-nextgen:
RubyNextgenClientCodegen#toEnumVarNamepreviously skipped.toUpperCase(Locale.ROOT)in the numeric (Integer/Float) branch, emittingunknown_default_open_api = 11184809in lowercase (which Ruby evaluates as a local variable instead of a constant, raisingNameErrorinself.all).partial_model_enum_class.mustachedid not defineself.build(value), soPolymorphism.coerce_modelnever mapped unknown values toUNKNOWN_DEFAULT_OPEN_API.
Changes
- Uppercase
varNamein the numeric branch ofRubyNextgenClientCodegen#toEnumVarName. - Emit
self.build(value)inpartial_model_enum_class.mustachewhenenumUnknownDefaultCaseis enabled. - Add unit tests in
RubyNextgenClientCodegenTest.
PR checklist
- Read the contribution guidelines.
- Samples for
ruby-nextgen(bin/configs/ruby-nextgen.yaml,bin/configs/ruby-nextgen-qdrant.yaml) do not enableenumUnknownDefaultCaseand are unaffected. - Mention Ruby technical committee members: @cliffano @zlx @autopp @n-rodriguez
Summary by cubic
Fixes #24996. When enumUnknownDefaultCase=true, the generated ruby-nextgen client emitted numeric enum members like unknown_default_open_api = 11184809 in lowercase, which Ruby treats as a local variable instead of a constant and raises NameError in self.all. Unknown values also never mapped to UNKNOWN_DEFAULT_OPEN_API because self.build(value) was missing.
- Numeric enum member names are now uppercased so they become valid Ruby constants.
partial_model_enum_class.mustachenow emitsself.build(value)whenenumUnknownDefaultCaseis enabled, mapping unknown values to the unknown default member and passingnilthrough unchanged.connection.mustachedeserializes arrays of enums throughbuildso unknown members in array responses map correctly, and skips array handling when the payload is not an array.- Adds unit tests for generated method output, constant casing, and array enum deserialization.