forked from loafle/openapi-generator-original
Possible Ruby Enum Fix (#6131)
This commit is contained in:
parent
1f133e8ecd
commit
b9b1b7647b
@ -1,4 +1,13 @@
|
|||||||
class {{classname}}
|
class {{classname}}
|
||||||
{{#allowableValues}}{{#enumVars}}
|
{{#allowableValues}}{{#enumVars}}
|
||||||
{{{name}}} = {{{value}}}.freeze{{/enumVars}}{{/allowableValues}}
|
{{{name}}} = {{{value}}}.freeze{{/enumVars}}{{/allowableValues}}
|
||||||
|
|
||||||
|
# Builds the enum from string
|
||||||
|
# @param [String] The enum value in the form of the string
|
||||||
|
# @return [String] The enum value
|
||||||
|
def build_from_hash(value)
|
||||||
|
consantValues = {{classname}}.constants.select{|c| c.to_s == value}
|
||||||
|
raise "Invalid ENUM value #{value} for class #{{{classname}}}" if consantValues.empty?
|
||||||
|
value
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user