mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-16 08:31:26 +00:00
50 lines
1.5 KiB
Plaintext
50 lines
1.5 KiB
Plaintext
module {{moduleName}}
|
|
{{#models}} # {{description}}
|
|
{{#model}} class {{classname}} < BaseObject
|
|
attr_accessor {{#vars}}:{{{name}}}{{#hasMore}}, {{/hasMore}}{{/vars}}{{newline}}
|
|
# attribute mapping from ruby-style variable name to JSON key
|
|
def self.attribute_map
|
|
{
|
|
{{#vars}}
|
|
# {{description}}
|
|
:'{{{name}}}' => :'{{{baseName}}}'{{#hasMore}},{{/hasMore}}
|
|
{{/vars}}
|
|
}
|
|
end
|
|
|
|
# attribute type
|
|
def self.swagger_types
|
|
{
|
|
{{#vars}}:'{{{name}}}' => :'{{{datatype}}}'{{#hasMore}},{{/hasMore}}
|
|
{{/vars}}
|
|
}
|
|
end
|
|
|
|
def initialize(attributes = {})
|
|
return if !attributes.is_a?(Hash) || attributes.empty?
|
|
|
|
# convert string to symbol for hash key
|
|
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
|
|
|
|
{{#vars}}
|
|
if attributes[:'{{{baseName}}}']
|
|
{{#isContainer}}if (value = attributes[:'{{{baseName}}}']).is_a?(Array)
|
|
self.{{{name}}} = value
|
|
end{{/isContainer}}{{^isContainer}}self.{{{name}}} = attributes[:'{{{baseName}}}']{{/isContainer}}
|
|
end
|
|
{{/vars}}
|
|
end
|
|
{{#vars}}{{#isEnum}}
|
|
def {{{name}}}=({{{name}}})
|
|
allowed_values = [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]
|
|
if {{{name}}} && !allowed_values.include?({{{name}}})
|
|
fail "invalid value for '{{{name}}}', must be one of #{allowed_values}"
|
|
end
|
|
@{{{name}}} = {{{name}}}
|
|
end
|
|
{{/isEnum}}{{/vars}}
|
|
end
|
|
{{/model}}
|
|
{{/models}}
|
|
end
|