mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-17 15:54:36 +00:00
41 lines
1.1 KiB
Plaintext
41 lines
1.1 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)
|
|
@{{{name}}} = value
|
|
end{{/isContainer}}{{^isContainer}}@{{{name}}} = attributes[:'{{{baseName}}}']{{/isContainer}}
|
|
end
|
|
{{/vars}}
|
|
end
|
|
end
|
|
{{/model}}
|
|
{{/models}}
|
|
end
|