[Ruby] Add auto-generated rubocop config file (#7637)

* add rubocop to ruby api client

* add new files

* fix ruby generator test case
This commit is contained in:
William Cheng 2018-02-12 14:08:02 +08:00 committed by GitHub
parent 86697fedb2
commit aa6b217bb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
78 changed files with 920 additions and 1025 deletions

View File

@ -252,6 +252,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore")); supportingFiles.add(new SupportingFile("gitignore.mustache", "", ".gitignore"));
supportingFiles.add(new SupportingFile("Rakefile.mustache", "", "Rakefile")); supportingFiles.add(new SupportingFile("Rakefile.mustache", "", "Rakefile"));
supportingFiles.add(new SupportingFile("Gemfile.mustache", "", "Gemfile")); supportingFiles.add(new SupportingFile("Gemfile.mustache", "", "Gemfile"));
supportingFiles.add(new SupportingFile("rubocop.mustache", "", ".rubocop.yml"));
// test files should not be overwritten // test files should not be overwritten
writeOptional(outputFolder, new SupportingFile("rspec.mustache", "", ".rspec")); writeOptional(outputFolder, new SupportingFile("rspec.mustache", "", ".rspec"));
@ -411,7 +412,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
} else if (p instanceof StringProperty) { } else if (p instanceof StringProperty) {
StringProperty sp = (StringProperty) p; StringProperty sp = (StringProperty) p;
if (sp.getDefault() != null) { if (sp.getDefault() != null) {
return "\"" + escapeText(sp.getDefault()) + "\""; return "'" + escapeText(sp.getDefault()) + "'";
} }
} }
@ -565,7 +566,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
if ("Integer".equals(datatype) || "Float".equals(datatype)) { if ("Integer".equals(datatype) || "Float".equals(datatype)) {
return value; return value;
} else { } else {
return "\"" + escapeText(value) + "\""; return "'" + escapeText(value) + "'";
} }
} }
@ -658,7 +659,7 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
if (example == null) { if (example == null) {
example = p.paramName + "_example"; example = p.paramName + "_example";
} }
example = "\"" + escapeText(example) + "\""; example = "'" + escapeText(example) + "'";
} else if ("Integer".equals(type)) { } else if ("Integer".equals(type)) {
if (example == null) { if (example == null) {
example = "56"; example = "56";
@ -675,17 +676,17 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
if (example == null) { if (example == null) {
example = "/path/to/file"; example = "/path/to/file";
} }
example = "File.new(\"" + escapeText(example) + "\")"; example = "File.new('" + escapeText(example) + "')";
} else if ("Date".equals(type)) { } else if ("Date".equals(type)) {
if (example == null) { if (example == null) {
example = "2013-10-20"; example = "2013-10-20";
} }
example = "Date.parse(\"" + escapeText(example) + "\")"; example = "Date.parse('" + escapeText(example) + "')";
} else if ("DateTime".equals(type)) { } else if ("DateTime".equals(type)) {
if (example == null) { if (example == null) {
example = "2013-10-20T19:20:30+01:00"; example = "2013-10-20T19:20:30+01:00";
} }
example = "DateTime.parse(\"" + escapeText(example) + "\")"; example = "DateTime.parse('" + escapeText(example) + "')";
} else if (!languageSpecificPrimitives.contains(type)) { } else if (!languageSpecificPrimitives.contains(type)) {
// type is a model class, e.g. User // type is a model class, e.g. User
example = moduleName + "::" + type + ".new"; example = moduleName + "::" + type + ".new";

View File

@ -2,7 +2,7 @@
{{> api_info}} {{> api_info}}
=end =end
require "uri" require 'uri'
module {{moduleName}} module {{moduleName}}
{{#operations}} {{#operations}}
@ -13,27 +13,34 @@ module {{moduleName}}
@api_client = api_client @api_client = api_client
end end
{{#operation}} {{#operation}}
{{newline}} {{#summary}}
# {{{summary}}} # {{{summary}}}
{{/summary}}
{{#notes}}
# {{{notes}}} # {{{notes}}}
{{/notes}}
{{#allParams}}{{#required}} # @param {{paramName}} {{description}} {{#allParams}}{{#required}} # @param {{paramName}} {{description}}
{{/required}}{{/allParams}} # @param [Hash] opts the optional parameters {{/required}}{{/allParams}} # @param [Hash] opts the optional parameters
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}} {{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}{{#defaultValue}} (default to {{{.}}}){{/defaultValue}}
{{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}] {{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}]
def {{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {}) def {{operationId}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {})
{{#returnType}}data, _status_code, _headers = {{/returnType}}{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts) {{#returnType}}data, _status_code, _headers = {{/returnType}}{{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts)
{{#returnType}}return data{{/returnType}}{{^returnType}}return nil{{/returnType}} {{#returnType}}data{{/returnType}}{{^returnType}}nil{{/returnType}}
end end
{{#summary}}
# {{summary}} # {{summary}}
{{/summary}}
{{#notes}}
# {{notes}} # {{notes}}
{{/notes}}
{{#allParams}}{{#required}} # @param {{paramName}} {{description}} {{#allParams}}{{#required}} # @param {{paramName}} {{description}}
{{/required}}{{/allParams}} # @param [Hash] opts the optional parameters {{/required}}{{/allParams}} # @param [Hash] opts the optional parameters
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}} {{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}
{{/required}}{{/allParams}} # @return [Array<({{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}, Fixnum, Hash)>] {{#returnType}}{{{returnType}}} data{{/returnType}}{{^returnType}}nil{{/returnType}}, response status code and response headers {{/required}}{{/allParams}} # @return [Array<({{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}, Fixnum, Hash)>] {{#returnType}}{{{returnType}}} data{{/returnType}}{{^returnType}}nil{{/returnType}}, response status code and response headers
def {{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {}) def {{operationId}}_with_http_info({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: {{classname}}.{{operationId}} ..." @api_client.config.logger.debug 'Calling API: {{classname}}.{{operationId}} ...'
end end
{{#allParams}} {{#allParams}}
{{#required}} {{#required}}
@ -53,7 +60,7 @@ module {{moduleName}}
{{^required}} {{^required}}
{{#isEnum}} {{#isEnum}}
{{#collectionFormat}} {{#collectionFormat}}
if @api_client.config.client_side_validation && opts[:'{{{paramName}}}'] && !opts[:'{{{paramName}}}'].all?{|item| [{{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}].include?(item)} if @api_client.config.client_side_validation && opts[:'{{{paramName}}}'] && !opts[:'{{{paramName}}}'].all? { |item| [{{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}].include?(item) }
fail ArgumentError, 'invalid value for "{{{paramName}}}", must include one of {{#allowableValues}}{{#values}}{{{this}}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}' fail ArgumentError, 'invalid value for "{{{paramName}}}", must include one of {{#allowableValues}}{{#values}}{{{this}}}{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}'
end end
{{/collectionFormat}} {{/collectionFormat}}
@ -110,7 +117,7 @@ module {{moduleName}}
{{/hasValidation}} {{/hasValidation}}
{{/allParams}} {{/allParams}}
# resource path # resource path
local_var_path = "{{{path}}}"{{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s){{/pathParams}} local_var_path = '{{{path}}}'{{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s){{/pathParams}}
# query parameters # query parameters
query_params = {} query_params = {}
@ -150,12 +157,12 @@ module {{moduleName}}
form_params = {} form_params = {}
{{#formParams}} {{#formParams}}
{{#required}} {{#required}}
form_params["{{baseName}}"] = {{#collectionFormat}}@api_client.build_collection_param({{{paramName}}}, :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}} form_params['{{baseName}}'] = {{#collectionFormat}}@api_client.build_collection_param({{{paramName}}}, :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}{{{paramName}}}{{/collectionFormat}}
{{/required}} {{/required}}
{{/formParams}} {{/formParams}}
{{#formParams}} {{#formParams}}
{{^required}} {{^required}}
form_params["{{baseName}}"] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if !opts[:'{{paramName}}'].nil? form_params['{{baseName}}'] = {{#collectionFormat}}@api_client.build_collection_param(opts[:'{{{paramName}}}'], :{{{collectionFormat}}}){{/collectionFormat}}{{^collectionFormat}}opts[:'{{{paramName}}}']{{/collectionFormat}} if !opts[:'{{paramName}}'].nil?
{{/required}} {{/required}}
{{/formParams}} {{/formParams}}

View File

@ -25,7 +25,7 @@ module {{moduleName}}
@config = config @config = config
@user_agent = "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/#{VERSION}/ruby{{/httpUserAgent}}" @user_agent = "{{#httpUserAgent}}{{{.}}}{{/httpUserAgent}}{{^httpUserAgent}}Swagger-Codegen/#{VERSION}/ruby{{/httpUserAgent}}"
@default_headers = { @default_headers = {
'Content-Type' => "application/json", 'Content-Type' => 'application/json',
'User-Agent' => @user_agent 'User-Agent' => @user_agent
} }
end end
@ -131,7 +131,7 @@ module {{moduleName}}
# @param [String] mime MIME # @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json # @return [Boolean] True if the MIME is application/json
def json_mime?(mime) def json_mime?(mime)
(mime == "*/*") || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil? (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
end end
# Deserialize the response to the given return type. # Deserialize the response to the given return type.
@ -195,12 +195,12 @@ module {{moduleName}}
when /\AArray<(.+)>\z/ when /\AArray<(.+)>\z/
# e.g. Array<Pet> # e.g. Array<Pet>
sub_type = $1 sub_type = $1
data.map {|item| convert_to_type(item, sub_type) } data.map { |item| convert_to_type(item, sub_type) }
when /\AHash\<String, (.+)\>\z/ when /\AHash\<String, (.+)\>\z/
# e.g. Hash<String, Integer> # e.g. Hash<String, Integer>
sub_type = $1 sub_type = $1
{}.tap do |hash| {}.tap do |hash|
data.each {|k, v| hash[k] = convert_to_type(v, sub_type) } data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
end end
else else
# models, e.g. Pet # models, e.g. Pet
@ -222,7 +222,7 @@ module {{moduleName}}
encoding = nil encoding = nil
request.on_headers do |response| request.on_headers do |response|
content_disposition = response.headers['Content-Disposition'] content_disposition = response.headers['Content-Disposition']
if content_disposition and content_disposition =~ /filename=/i if content_disposition && content_disposition =~ /filename=/i
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1] filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
prefix = sanitize_filename(filename) prefix = sanitize_filename(filename)
else else
@ -321,7 +321,7 @@ module {{moduleName}}
return nil if accepts.nil? || accepts.empty? return nil if accepts.nil? || accepts.empty?
# use JSON when present, otherwise use all of the provided # use JSON when present, otherwise use all of the provided
json_accept = accepts.find { |s| json_mime?(s) } json_accept = accepts.find { |s| json_mime?(s) }
return json_accept || accepts.join(',') json_accept || accepts.join(',')
end end
# Return Content-Type header based on an array of content types provided. # Return Content-Type header based on an array of content types provided.
@ -332,7 +332,7 @@ module {{moduleName}}
return 'application/json' if content_types.nil? || content_types.empty? return 'application/json' if content_types.nil? || content_types.empty?
# use JSON when present, otherwise use the first one # use JSON when present, otherwise use the first one
json_content_type = content_types.find { |s| json_mime?(s) } json_content_type = content_types.find { |s| json_mime?(s) }
return json_content_type || content_types.first json_content_type || content_types.first
end end
# Convert object (array, hash, object, etc) to JSON string. # Convert object (array, hash, object, etc) to JSON string.
@ -342,7 +342,7 @@ module {{moduleName}}
return model if model.nil? || model.is_a?(String) return model if model.nil? || model.is_a?(String)
local_body = nil local_body = nil
if model.is_a?(Array) if model.is_a?(Array)
local_body = model.map{|m| object_to_hash(m) } local_body = model.map { |m| object_to_hash(m) }
else else
local_body = object_to_hash(model) local_body = object_to_hash(model)
end end

View File

@ -43,11 +43,11 @@ describe {{moduleName}}::ApiClient do
end end
end end
describe "params_encoding in #build_request" do describe 'params_encoding in #build_request' do
let(:config) { {{moduleName}}::Configuration.new } let(:config) { {{moduleName}}::Configuration.new }
let(:api_client) { {{moduleName}}::ApiClient.new(config) } let(:api_client) { {{moduleName}}::ApiClient.new(config) }
it "defaults to nil" do it 'defaults to nil' do
expect({{moduleName}}::Configuration.default.params_encoding).to eq(nil) expect({{moduleName}}::Configuration.default.params_encoding).to eq(nil)
expect(config.params_encoding).to eq(nil) expect(config.params_encoding).to eq(nil)
@ -55,18 +55,18 @@ describe {{moduleName}}::ApiClient do
expect(request.options[:params_encoding]).to eq(nil) expect(request.options[:params_encoding]).to eq(nil)
end end
it "can be customized" do it 'can be customized' do
config.params_encoding = :multi config.params_encoding = :multi
request = api_client.build_request(:get, '/test') request = api_client.build_request(:get, '/test')
expect(request.options[:params_encoding]).to eq(:multi) expect(request.options[:params_encoding]).to eq(:multi)
end end
end end
describe "timeout in #build_request" do describe 'timeout in #build_request' do
let(:config) { {{moduleName}}::Configuration.new } let(:config) { {{moduleName}}::Configuration.new }
let(:api_client) { {{moduleName}}::ApiClient.new(config) } let(:api_client) { {{moduleName}}::ApiClient.new(config) }
it "defaults to 0" do it 'defaults to 0' do
expect({{moduleName}}::Configuration.default.timeout).to eq(0) expect({{moduleName}}::Configuration.default.timeout).to eq(0)
expect(config.timeout).to eq(0) expect(config.timeout).to eq(0)
@ -74,88 +74,88 @@ describe {{moduleName}}::ApiClient do
expect(request.options[:timeout]).to eq(0) expect(request.options[:timeout]).to eq(0)
end end
it "can be customized" do it 'can be customized' do
config.timeout = 100 config.timeout = 100
request = api_client.build_request(:get, '/test') request = api_client.build_request(:get, '/test')
expect(request.options[:timeout]).to eq(100) expect(request.options[:timeout]).to eq(100)
end end
end end
describe "#deserialize" do describe '#deserialize' do
it "handles Array<Integer>" do it "handles Array<Integer>" do
api_client = {{moduleName}}::ApiClient.new api_client = {{moduleName}}::ApiClient.new
headers = {'Content-Type' => 'application/json'} headers = { 'Content-Type' => 'application/json' }
response = double('response', headers: headers, body: '[12, 34]') response = double('response', headers: headers, body: '[12, 34]')
data = api_client.deserialize(response, 'Array<Integer>') data = api_client.deserialize(response, 'Array<Integer>')
expect(data).to be_instance_of(Array) expect(data).to be_instance_of(Array)
expect(data).to eq([12, 34]) expect(data).to eq([12, 34])
end end
it "handles Array<Array<Integer>>" do it 'handles Array<Array<Integer>>' do
api_client = {{moduleName}}::ApiClient.new api_client = {{moduleName}}::ApiClient.new
headers = {'Content-Type' => 'application/json'} headers = { 'Content-Type' => 'application/json' }
response = double('response', headers: headers, body: '[[12, 34], [56]]') response = double('response', headers: headers, body: '[[12, 34], [56]]')
data = api_client.deserialize(response, 'Array<Array<Integer>>') data = api_client.deserialize(response, 'Array<Array<Integer>>')
expect(data).to be_instance_of(Array) expect(data).to be_instance_of(Array)
expect(data).to eq([[12, 34], [56]]) expect(data).to eq([[12, 34], [56]])
end end
it "handles Hash<String, String>" do it 'handles Hash<String, String>' do
api_client = {{moduleName}}::ApiClient.new api_client = {{moduleName}}::ApiClient.new
headers = {'Content-Type' => 'application/json'} headers = { 'Content-Type' => 'application/json' }
response = double('response', headers: headers, body: '{"message": "Hello"}') response = double('response', headers: headers, body: '{"message": "Hello"}')
data = api_client.deserialize(response, 'Hash<String, String>') data = api_client.deserialize(response, 'Hash<String, String>')
expect(data).to be_instance_of(Hash) expect(data).to be_instance_of(Hash)
expect(data).to eq({:message => 'Hello'}) expect(data).to eq(:message => 'Hello')
end end
end end
describe "#object_to_hash" do describe "#object_to_hash" do
it "ignores nils and includes empty arrays" do it 'ignores nils and includes empty arrays' do
# uncomment below to test object_to_hash for model # uncomment below to test object_to_hash for model
#api_client = {{moduleName}}::ApiClient.new # api_client = {{moduleName}}::ApiClient.new
#_model = {{moduleName}}::ModelName.new # _model = {{moduleName}}::ModelName.new
# update the model attribute below # update the model attribute below
#_model.id = 1 # _model.id = 1
# update the expected value (hash) below # update the expected value (hash) below
#expected = {id: 1, name: '', tags: []} # expected = {id: 1, name: '', tags: []}
#expect(api_client.object_to_hash(_model)).to eq(expected) # expect(api_client.object_to_hash(_model)).to eq(expected)
end end
end end
describe "#build_collection_param" do describe '#build_collection_param' do
let(:param) { ['aa', 'bb', 'cc'] } let(:param) { ['aa', 'bb', 'cc'] }
let(:api_client) { {{moduleName}}::ApiClient.new } let(:api_client) { {{moduleName}}::ApiClient.new }
it "works for csv" do it 'works for csv' do
expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc') expect(api_client.build_collection_param(param, :csv)).to eq('aa,bb,cc')
end end
it "works for ssv" do it 'works for ssv' do
expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc') expect(api_client.build_collection_param(param, :ssv)).to eq('aa bb cc')
end end
it "works for tsv" do it 'works for tsv' do
expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc") expect(api_client.build_collection_param(param, :tsv)).to eq("aa\tbb\tcc")
end end
it "works for pipes" do it 'works for pipes' do
expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc') expect(api_client.build_collection_param(param, :pipes)).to eq('aa|bb|cc')
end end
it "works for multi" do it 'works for multi' do
expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc']) expect(api_client.build_collection_param(param, :multi)).to eq(['aa', 'bb', 'cc'])
end end
it "fails for invalid collection format" do it 'fails for invalid collection format' do
expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID') expect(proc { api_client.build_collection_param(param, :INVALID) }).to raise_error(RuntimeError, 'unknown collection format: :INVALID')
end end
end end
describe "#json_mime?" do describe '#json_mime?' do
let(:api_client) { {{moduleName}}::ApiClient.new } let(:api_client) { {{moduleName}}::ApiClient.new }
it "works" do it 'works' do
expect(api_client.json_mime?(nil)).to eq false expect(api_client.json_mime?(nil)).to eq false
expect(api_client.json_mime?('')).to eq false expect(api_client.json_mime?('')).to eq false
@ -169,10 +169,10 @@ describe {{moduleName}}::ApiClient do
end end
end end
describe "#select_header_accept" do describe '#select_header_accept' do
let(:api_client) { {{moduleName}}::ApiClient.new } let(:api_client) { {{moduleName}}::ApiClient.new }
it "works" do it 'works' do
expect(api_client.select_header_accept(nil)).to be_nil expect(api_client.select_header_accept(nil)).to be_nil
expect(api_client.select_header_accept([])).to be_nil expect(api_client.select_header_accept([])).to be_nil
@ -185,10 +185,10 @@ describe {{moduleName}}::ApiClient do
end end
end end
describe "#select_header_content_type" do describe '#select_header_content_type' do
let(:api_client) { {{moduleName}}::ApiClient.new } let(:api_client) { {{moduleName}}::ApiClient.new }
it "works" do it 'works' do
expect(api_client.select_header_content_type(nil)).to eq('application/json') expect(api_client.select_header_content_type(nil)).to eq('application/json')
expect(api_client.select_header_content_type([])).to eq('application/json') expect(api_client.select_header_content_type([])).to eq('application/json')
@ -200,10 +200,10 @@ describe {{moduleName}}::ApiClient do
end end
end end
describe "#sanitize_filename" do describe '#sanitize_filename' do
let(:api_client) { {{moduleName}}::ApiClient.new } let(:api_client) { {{moduleName}}::ApiClient.new }
it "works" do it 'works' do
expect(api_client.sanitize_filename('sun')).to eq('sun') expect(api_client.sanitize_filename('sun')).to eq('sun')
expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif') expect(api_client.sanitize_filename('sun.gif')).to eq('sun.gif')
expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif') expect(api_client.sanitize_filename('../sun.gif')).to eq('sun.gif')

View File

@ -26,14 +26,18 @@ require 'json'
{{#operation}} {{#operation}}
# unit tests for {{operationId}} # unit tests for {{operationId}}
{{#summary}}
# {{summary}} # {{summary}}
{{/summary}}
{{#notes}}
# {{notes}} # {{notes}}
{{/notes}}
{{#allParams}}{{#required}} # @param {{paramName}} {{description}} {{#allParams}}{{#required}} # @param {{paramName}} {{description}}
{{/required}}{{/allParams}} # @param [Hash] opts the optional parameters {{/required}}{{/allParams}} # @param [Hash] opts the optional parameters
{{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}} {{#allParams}}{{^required}} # @option opts [{{{dataType}}}] :{{paramName}} {{description}}
{{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}] {{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}]
describe '{{operationId}} test' do describe '{{operationId}} test' do
it "should work" do it 'should work' do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end end
end end

View File

@ -8,7 +8,7 @@
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -90,7 +90,7 @@
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }

View File

@ -162,7 +162,7 @@ module {{moduleName}}
def base_path=(base_path) def base_path=(base_path)
# Add leading and trailing slashes to base_path # Add leading and trailing slashes to base_path
@base_path = "/#{base_path}".gsub(/\/+/, '/') @base_path = "/#{base_path}".gsub(/\/+/, '/')
@base_path = "" if @base_path == "/" @base_path = '' if @base_path == '/'
end end
def base_url def base_url

View File

@ -9,25 +9,25 @@ describe {{moduleName}}::Configuration do
before(:each) do before(:each) do
# uncomment below to setup host and base_path # uncomment below to setup host and base_path
#require 'URI' # require 'URI'
#uri = URI.parse("{{{basePath}}}") # uri = URI.parse("{{{basePath}}}")
#{{moduleName}}.configure do |c| # {{moduleName}}.configure do |c|
# c.host = uri.host # c.host = uri.host
# c.base_path = uri.path # c.base_path = uri.path
#end # end
end end
describe '#base_url' do describe '#base_url' do
it 'should have the default value' do it 'should have the default value' do
# uncomment below to test default value of the base path # uncomment below to test default value of the base path
#expect(config.base_url).to eq("{{{basePath}}}") # expect(config.base_url).to eq("{{{basePath}}}")
end end
it 'should remove trailing slashes' do it 'should remove trailing slashes' do
[nil, '', '/', '//'].each do |base_path| [nil, '', '/', '//'].each do |base_path|
config.base_path = base_path config.base_path = base_path
# uncomment below to test trailing slashes # uncomment below to test trailing slashes
#expect(config.base_url).to eq("{{{basePath}}}") # expect(config.base_url).to eq("{{{basePath}}}")
end end
end end
end end

View File

@ -1,5 +1,5 @@
# -*- encoding: utf-8 -*- # -*- encoding: utf-8 -*-
#
=begin =begin
{{> api_info}} {{> api_info}}
=end =end
@ -17,11 +17,10 @@ Gem::Specification.new do |s|
s.summary = "{{gemSummary}}{{^gemSummary}}{{{appName}}} Ruby Gem{{/gemSummary}}" s.summary = "{{gemSummary}}{{^gemSummary}}{{{appName}}} Ruby Gem{{/gemSummary}}"
s.description = "{{gemDescription}}{{^gemDescription}}{{{appDescription}}}{{^appDescription}}{{{appName}}} Ruby Gem{{/appDescription}}{{/gemDescription}}" s.description = "{{gemDescription}}{{^gemDescription}}{{{appDescription}}}{{^appDescription}}{{{appName}}} Ruby Gem{{/appDescription}}{{/gemDescription}}"
{{#gemLicense}} {{#gemLicense}}
s.license = "{{{gemLicense}}}" s.license = '{{{gemLicense}}}'
{{/gemLicense}} {{/gemLicense}}
{{^gemLicense}} {{^gemLicense}}
# TODO uncomment and update below with a proper license s.license = "Unlicense"
#s.license = "Apache 2.0"
{{/gemLicense}} {{/gemLicense}}
s.required_ruby_version = "{{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}>= 1.9{{/gemRequiredRubyVersion}}" s.required_ruby_version = "{{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}>= 1.9{{/gemRequiredRubyVersion}}"
@ -36,7 +35,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16' s.add_development_dependency 'autotest-growl', '~> 0.2', '>= 0.2.16'
s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.12' s.add_development_dependency 'autotest-fsevent', '~> 0.2', '>= 0.2.12'
s.files = `find *`.split("\n").uniq.sort.select{|f| !f.empty? } s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
s.test_files = `find spec/*`.split("\n") s.test_files = `find spec/*`.split("\n")
s.executables = [] s.executables = []
s.require_paths = ["lib"] s.require_paths = ["lib"]

View File

@ -5,5 +5,14 @@
require 'date' require 'date'
module {{moduleName}} module {{moduleName}}
{{#models}}{{#model}}{{#isEnum}}{{>partial_model_enum_class}}{{/isEnum}}{{^isEnum}}{{>partial_model_generic}}{{/isEnum}}{{/model}}{{/models}} {{#models}}
{{#model}}
{{#isEnum}}
{{>partial_model_enum_class}}
{{/isEnum}}
{{^isEnum}}
{{>partial_model_generic}}
{{/isEnum}}
{{/model}}
{{/models}}
end end

View File

@ -9,7 +9,9 @@ require 'date'
# Unit tests for {{moduleName}}::{{classname}} # Unit tests for {{moduleName}}::{{classname}}
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen) # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
# Please update as you see appropriate # Please update as you see appropriate
{{#models}}{{#model}}describe '{{classname}}' do {{#models}}
{{#model}}
describe '{{classname}}' do
before do before do
# run before each test # run before each test
@instance = {{moduleName}}::{{classname}}.new @instance = {{moduleName}}::{{classname}}.new
@ -29,10 +31,10 @@ require 'date'
it 'should work' do it 'should work' do
{{#isEnum}} {{#isEnum}}
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
#validator = Petstore::EnumTest::EnumAttributeValidator.new('{{{datatype}}}', [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]) # validator = Petstore::EnumTest::EnumAttributeValidator.new('{{{datatype}}}', [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}])
#validator.allowable_values.each do |value| # validator.allowable_values.each do |value|
# expect { @instance.{{name}} = value }.not_to raise_error # expect { @instance.{{name}} = value }.not_to raise_error
#end # end
{{/isEnum}} {{/isEnum}}
{{^isEnum}} {{^isEnum}}
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
@ -42,4 +44,5 @@ require 'date'
{{/vars}} {{/vars}}
end end
{{/model}}{{/models}} {{/model}}
{{/models}}

View File

@ -6,7 +6,7 @@
# @param [String] The enum value in the form of the string # @param [String] The enum value in the form of the string
# @return [String] The enum value # @return [String] The enum value
def build_from_hash(value) def build_from_hash(value)
constantValues = {{classname}}.constants.select{|c| {{classname}}::const_get(c) == value} constantValues = {{classname}}.constants.select { |c| {{classname}}::const_get(c) == value }
raise "Invalid ENUM value #{value} for class #{{{classname}}}" if constantValues.empty? raise "Invalid ENUM value #{value} for class #{{{classname}}}" if constantValues.empty?
value value
end end

View File

@ -1,9 +1,14 @@
{{#description}} # {{{description}}}{{/description}} {{#description}}
class {{classname}}{{#vars}}{{#description}} # {{{description}}}
# {{{description}}}{{/description}} {{/description}}
class {{classname}}
{{#vars}}
{{#description}}
# {{{description}}}
{{/description}}
attr_accessor :{{{name}}} attr_accessor :{{{name}}}
{{/vars}}
{{/vars}}
{{#hasEnums}} {{#hasEnums}}
class EnumAttributeValidator class EnumAttributeValidator
attr_reader :datatype attr_reader :datatype
@ -26,8 +31,8 @@
!value || allowable_values.include?(value) !value || allowable_values.include?(value)
end end
end end
{{/hasEnums}}
{{/hasEnums}}
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -52,9 +57,9 @@
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
{{#vars}} {{#vars}}
if attributes.has_key?(:'{{{baseName}}}') if attributes.has_key?(:'{{{baseName}}}')
{{#isListContainer}} {{#isListContainer}}
if (value = attributes[:'{{{baseName}}}']).is_a?(Array) if (value = attributes[:'{{{baseName}}}']).is_a?(Array)
@ -74,7 +79,6 @@
self.{{{name}}} = {{{defaultValue}}} self.{{{name}}} = {{{defaultValue}}}
{{/defaultValue}} {{/defaultValue}}
end end
{{/vars}} {{/vars}}
end end
@ -85,56 +89,56 @@
{{#vars}} {{#vars}}
{{#required}} {{#required}}
if @{{{name}}}.nil? if @{{{name}}}.nil?
invalid_properties.push("invalid value for '{{{name}}}', {{{name}}} cannot be nil.") invalid_properties.push('invalid value for "{{{name}}}", {{{name}}} cannot be nil.')
end end
{{/required}} {{/required}}
{{#hasValidation}} {{#hasValidation}}
{{#maxLength}} {{#maxLength}}
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length > {{{maxLength}}} if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length > {{{maxLength}}}
invalid_properties.push("invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}.") invalid_properties.push('invalid value for "{{{name}}}", the character length must be smaller than or equal to {{{maxLength}}}.')
end end
{{/maxLength}} {{/maxLength}}
{{#minLength}} {{#minLength}}
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length < {{{minLength}}} if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.to_s.length < {{{minLength}}}
invalid_properties.push("invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}.") invalid_properties.push('invalid value for "{{{name}}}", the character length must be great than or equal to {{{minLength}}}.')
end end
{{/minLength}} {{/minLength}}
{{#maximum}} {{#maximum}}
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}} if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}}
invalid_properties.push("invalid value for '{{{name}}}', must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}.") invalid_properties.push('invalid value for "{{{name}}}", must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}.')
end end
{{/maximum}} {{/maximum}}
{{#minimum}} {{#minimum}}
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}} if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}}
invalid_properties.push("invalid value for '{{{name}}}', must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}.") invalid_properties.push('invalid value for "{{{name}}}", must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}.')
end end
{{/minimum}} {{/minimum}}
{{#pattern}} {{#pattern}}
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} !~ Regexp.new({{{pattern}}}) if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}} !~ Regexp.new({{{pattern}}})
invalid_properties.push("invalid value for '{{{name}}}', must conform to the pattern {{{pattern}}}.") invalid_properties.push('invalid value for "{{{name}}}", must conform to the pattern {{{pattern}}}.')
end end
{{/pattern}} {{/pattern}}
{{#maxItems}} {{#maxItems}}
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length > {{{maxItems}}} if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length > {{{maxItems}}}
invalid_properties.push("invalid value for '{{{name}}}', number of items must be less than or equal to {{{maxItems}}}." invalid_properties.push('invalid value for "{{{name}}}", number of items must be less than or equal to {{{maxItems}}}.'
end end
{{/maxItems}} {{/maxItems}}
{{#minItems}} {{#minItems}}
if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length < {{{minItems}}} if {{^required}}!@{{{name}}}.nil? && {{/required}}@{{{name}}}.length < {{{minItems}}}
invalid_properties.push("invalid value for '{{{name}}}', number of items must be greater than or equal to {{{minItems}}}." invalid_properties.push('invalid value for "{{{name}}}", number of items must be greater than or equal to {{{minItems}}}.'
end end
{{/minItems}} {{/minItems}}
{{/hasValidation}} {{/hasValidation}}
{{/vars}} {{/vars}}
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
@ -146,7 +150,7 @@
{{/required}} {{/required}}
{{#isEnum}} {{#isEnum}}
{{^isContainer}} {{^isContainer}}
{{{name}}}_validator = EnumAttributeValidator.new('{{{datatype}}}', [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]) {{{name}}}_validator = EnumAttributeValidator.new('{{{datatype}}}', [{{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}])
return false unless {{{name}}}_validator.valid?(@{{{name}}}) return false unless {{{name}}}_validator.valid?(@{{{name}}})
{{/isContainer}} {{/isContainer}}
{{/isEnum}} {{/isEnum}}
@ -174,7 +178,7 @@
{{/minItems}} {{/minItems}}
{{/hasValidation}} {{/hasValidation}}
{{/vars}} {{/vars}}
return true true
end end
{{#vars}} {{#vars}}
@ -183,9 +187,9 @@
# Custom attribute writer method checking allowed values (enum). # Custom attribute writer method checking allowed values (enum).
# @param [Object] {{{name}}} Object to be assigned # @param [Object] {{{name}}} Object to be assigned
def {{{name}}}=({{{name}}}) def {{{name}}}=({{{name}}})
validator = EnumAttributeValidator.new('{{{datatype}}}', [{{#allowableValues}}{{#values}}"{{{this}}}"{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}]) validator = EnumAttributeValidator.new('{{{datatype}}}', [{{#allowableValues}}{{#values}}'{{{this}}}'{{^-last}}, {{/-last}}{{/values}}{{/allowableValues}}])
unless validator.valid?({{{name}}}) unless validator.valid?({{{name}}})
fail ArgumentError, "invalid value for '{{{name}}}', must be one of #{validator.allowable_values}." fail ArgumentError, 'invalid value for "{{{name}}}", must be one of #{validator.allowable_values}.'
end end
@{{{name}}} = {{{name}}} @{{{name}}} = {{{name}}}
end end
@ -199,49 +203,49 @@
def {{{name}}}=({{{name}}}) def {{{name}}}=({{{name}}})
{{#required}} {{#required}}
if {{{name}}}.nil? if {{{name}}}.nil?
fail ArgumentError, "{{{name}}} cannot be nil" fail ArgumentError, '{{{name}}} cannot be nil'
end end
{{/required}}
{{/required}}
{{#maxLength}} {{#maxLength}}
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.to_s.length > {{{maxLength}}} if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.to_s.length > {{{maxLength}}}
fail ArgumentError, "invalid value for '{{{name}}}', the character length must be smaller than or equal to {{{maxLength}}}." fail ArgumentError, 'invalid value for "{{{name}}}", the character length must be smaller than or equal to {{{maxLength}}}.'
end end
{{/maxLength}} {{/maxLength}}
{{#minLength}} {{#minLength}}
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.to_s.length < {{{minLength}}} if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.to_s.length < {{{minLength}}}
fail ArgumentError, "invalid value for '{{{name}}}', the character length must be great than or equal to {{{minLength}}}." fail ArgumentError, 'invalid value for "{{{name}}}", the character length must be great than or equal to {{{minLength}}}.'
end end
{{/minLength}} {{/minLength}}
{{#maximum}} {{#maximum}}
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}} if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} >{{#exclusiveMaximum}}={{/exclusiveMaximum}} {{{maximum}}}
fail ArgumentError, "invalid value for '{{{name}}}', must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}." fail ArgumentError, 'invalid value for "{{{name}}}", must be smaller than {{^exclusiveMaximum}}or equal to {{/exclusiveMaximum}}{{{maximum}}}.'
end end
{{/maximum}} {{/maximum}}
{{#minimum}} {{#minimum}}
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}} if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} <{{#exclusiveMinimum}}={{/exclusiveMinimum}} {{{minimum}}}
fail ArgumentError, "invalid value for '{{{name}}}', must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}." fail ArgumentError, 'invalid value for "{{{name}}}", must be greater than {{^exclusiveMinimum}}or equal to {{/exclusiveMinimum}}{{{minimum}}}.'
end end
{{/minimum}} {{/minimum}}
{{#pattern}} {{#pattern}}
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} !~ Regexp.new({{{pattern}}}) if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}} !~ Regexp.new({{{pattern}}})
fail ArgumentError, "invalid value for '{{{name}}}', must conform to the pattern {{{pattern}}}." fail ArgumentError, 'invalid value for "{{{name}}}", must conform to the pattern {{{pattern}}}.'
end end
{{/pattern}} {{/pattern}}
{{#maxItems}} {{#maxItems}}
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.length > {{{maxItems}}} if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.length > {{{maxItems}}}
fail ArgumentError, "invalid value for '{{{name}}}', number of items must be less than or equal to {{{maxItems}}}." fail ArgumentError, 'invalid value for "{{{name}}}", number of items must be less than or equal to {{{maxItems}}}.'
end end
{{/maxItems}} {{/maxItems}}
{{#minItems}} {{#minItems}}
if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.length < {{{minItems}}} if {{^required}}!{{{name}}}.nil? && {{/required}}{{{name}}}.length < {{{minItems}}}
fail ArgumentError, "invalid value for '{{{name}}}', number of items must be greater than or equal to {{{minItems}}}." fail ArgumentError, 'invalid value for "{{{name}}}", number of items must be greater than or equal to {{{minItems}}}.'
end end
{{/minItems}} {{/minItems}}

View File

@ -0,0 +1,154 @@
# This file is based on https://github.com/rails/rails/blob/master/.rubocop.yml (MIT license)
# Automatically generated by Swagger Codegen (https://github.com/swagger-api/swagger-codegen)
AllCops:
TargetRubyVersion: 2.2
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
Exclude:
- '**/templates/**/*'
- '**/vendor/**/*'
- 'actionpack/lib/action_dispatch/journey/parser.rb'
# Prefer &&/|| over and/or.
Style/AndOr:
Enabled: true
# Do not use braces for hash literals when they are the last argument of a
# method call.
Style/BracesAroundHashParameters:
Enabled: true
EnforcedStyle: context_dependent
# Align `when` with `case`.
Layout/CaseIndentation:
Enabled: true
# Align comments with method definitions.
Layout/CommentIndentation:
Enabled: true
Layout/ElseAlignment:
Enabled: true
Layout/EmptyLineAfterMagicComment:
Enabled: true
# In a regular class definition, no empty lines around the body.
Layout/EmptyLinesAroundClassBody:
Enabled: true
# In a regular method definition, no empty lines around the body.
Layout/EmptyLinesAroundMethodBody:
Enabled: true
# In a regular module definition, no empty lines around the body.
Layout/EmptyLinesAroundModuleBody:
Enabled: true
Layout/FirstParameterIndentation:
Enabled: true
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
Style/HashSyntax:
Enabled: false
# Method definitions after `private` or `protected` isolated calls need one
# extra level of indentation.
Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: rails
# Two spaces, no tabs (for indentation).
Layout/IndentationWidth:
Enabled: true
Layout/LeadingCommentSpace:
Enabled: true
Layout/SpaceAfterColon:
Enabled: true
Layout/SpaceAfterComma:
Enabled: true
Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true
Layout/SpaceAroundKeyword:
Enabled: true
Layout/SpaceAroundOperators:
Enabled: true
Layout/SpaceBeforeComma:
Enabled: true
Layout/SpaceBeforeFirstArg:
Enabled: true
Style/DefWithParentheses:
Enabled: true
# Defining a method with parameters needs parentheses.
Style/MethodDefParentheses:
Enabled: true
Style/FrozenStringLiteralComment:
Enabled: false
EnforcedStyle: always
# Use `foo {}` not `foo{}`.
Layout/SpaceBeforeBlockBraces:
Enabled: true
# Use `foo { bar }` not `foo {bar}`.
Layout/SpaceInsideBlockBraces:
Enabled: true
# Use `{ a: 1 }` not `{a:1}`.
Layout/SpaceInsideHashLiteralBraces:
Enabled: true
Layout/SpaceInsideParens:
Enabled: true
# Check quotes usage according to lint rule below.
#Style/StringLiterals:
# Enabled: true
# EnforcedStyle: single_quotes
# Detect hard tabs, no hard tabs.
Layout/Tab:
Enabled: true
# Blank lines should not have any spaces.
Layout/TrailingBlankLines:
Enabled: true
# No trailing whitespace.
Layout/TrailingWhitespace:
Enabled: false
# Use quotes for string literals when they are enough.
Style/UnneededPercentQ:
Enabled: true
# Align `end` with the matching keyword or starting expression except for
# assignments, where it should be aligned with the LHS.
Lint/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: variable
AutoCorrect: true
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
Lint/RequireParentheses:
Enabled: true
Style/RedundantReturn:
Enabled: true
AllowMultipleReturnValues: true
Style/Semicolon:
Enabled: true
AllowAsExpressionSeparator: true

View File

@ -3,5 +3,5 @@
=end =end
module {{moduleName}} module {{moduleName}}
VERSION = "{{gemVersion}}" VERSION = '{{gemVersion}}'
end end

View File

@ -55,7 +55,7 @@ public class RubyClientCodegenTest {
if (file.getName().equals("default_api.rb")) { if (file.getName().equals("default_api.rb")) {
apiFileGenerated = true; apiFileGenerated = true;
// Ruby client should set the path unescaped in the api file // Ruby client should set the path unescaped in the api file
assertTrue(FileUtils.readFileToString(file, StandardCharsets.UTF_8).contains("local_var_path = \"/foo=bar\"")); assertTrue(FileUtils.readFileToString(file, StandardCharsets.UTF_8).contains("local_var_path = '/foo=bar'"));
} }
} }
if (!apiFileGenerated) { if (!apiFileGenerated) {

View File

@ -501,7 +501,7 @@ paths:
parameters: parameters:
- name: username - name: username
in: path in: path
description: 'The name that needs to be fetched. Use user1 for testing. ' description: 'The name that needs to be fetched. Use user1 for testing.'
required: true required: true
type: string type: string
responses: responses:

View File

@ -501,7 +501,7 @@ paths:
parameters: parameters:
- name: username - name: username
in: path in: path
description: 'The name that needs to be fetched. Use user1 for testing. ' description: 'The name that needs to be fetched. Use user1 for testing.'
required: true required: true
type: string type: string
responses: responses:

View File

@ -0,0 +1,153 @@
AllCops:
TargetRubyVersion: 2.2
# RuboCop has a bunch of cops enabled by default. This setting tells RuboCop
# to ignore them, so only the ones explicitly set in this file are enabled.
DisabledByDefault: true
Exclude:
- '**/spec/**/*'
- '**/templates/**/*'
- '**/vendor/**/*'
- 'actionpack/lib/action_dispatch/journey/parser.rb'
# Prefer &&/|| over and/or.
Style/AndOr:
Enabled: true
# Do not use braces for hash literals when they are the last argument of a
# method call.
Style/BracesAroundHashParameters:
Enabled: true
EnforcedStyle: context_dependent
# Align `when` with `case`.
Layout/CaseIndentation:
Enabled: true
# Align comments with method definitions.
Layout/CommentIndentation:
Enabled: true
Layout/ElseAlignment:
Enabled: true
Layout/EmptyLineAfterMagicComment:
Enabled: true
# In a regular class definition, no empty lines around the body.
Layout/EmptyLinesAroundClassBody:
Enabled: true
# In a regular method definition, no empty lines around the body.
Layout/EmptyLinesAroundMethodBody:
Enabled: true
# In a regular module definition, no empty lines around the body.
Layout/EmptyLinesAroundModuleBody:
Enabled: true
Layout/FirstParameterIndentation:
Enabled: true
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
Style/HashSyntax:
Enabled: false
# Method definitions after `private` or `protected` isolated calls need one
# extra level of indentation.
Layout/IndentationConsistency:
Enabled: true
EnforcedStyle: rails
# Two spaces, no tabs (for indentation).
Layout/IndentationWidth:
Enabled: true
Layout/LeadingCommentSpace:
Enabled: true
Layout/SpaceAfterColon:
Enabled: true
Layout/SpaceAfterComma:
Enabled: true
Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true
Layout/SpaceAroundKeyword:
Enabled: true
Layout/SpaceAroundOperators:
Enabled: true
Layout/SpaceBeforeComma:
Enabled: true
Layout/SpaceBeforeFirstArg:
Enabled: true
Style/DefWithParentheses:
Enabled: true
# Defining a method with parameters needs parentheses.
Style/MethodDefParentheses:
Enabled: true
Style/FrozenStringLiteralComment:
Enabled: false
EnforcedStyle: always
# Use `foo {}` not `foo{}`.
Layout/SpaceBeforeBlockBraces:
Enabled: true
# Use `foo { bar }` not `foo {bar}`.
Layout/SpaceInsideBlockBraces:
Enabled: true
# Use `{ a: 1 }` not `{a:1}`.
Layout/SpaceInsideHashLiteralBraces:
Enabled: true
Layout/SpaceInsideParens:
Enabled: true
# Check quotes usage according to lint rule below.
Style/StringLiterals:
Enabled: true
EnforcedStyle: single_quotes
# Detect hard tabs, no hard tabs.
Layout/Tab:
Enabled: true
# Blank lines should not have any spaces.
Layout/TrailingBlankLines:
Enabled: true
# No trailing whitespace.
Layout/TrailingWhitespace:
Enabled: false
# Use quotes for string literals when they are enough.
Style/UnneededPercentQ:
Enabled: true
# Align `end` with the matching keyword or starting expression except for
# assignments, where it should be aligned with the LHS.
Lint/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: variable
AutoCorrect: true
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
Lint/RequireParentheses:
Enabled: true
Style/RedundantReturn:
Enabled: true
AllowMultipleReturnValues: true
Style/Semicolon:
Enabled: true
AllowAsExpressionSeparator: true

View File

@ -1 +1 @@
2.3.0-SNAPSHOT 2.4.0-SNAPSHOT

View File

@ -4,6 +4,6 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**class_name** | **String** | | **class_name** | **String** | |
**color** | **String** | | [optional] [default to &quot;red&quot;] **color** | **String** | | [optional] [default to &#39;red&#39;]

View File

@ -4,7 +4,7 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**class_name** | **String** | | **class_name** | **String** | |
**color** | **String** | | [optional] [default to &quot;red&quot;] **color** | **String** | | [optional] [default to &#39;red&#39;]
**declawed** | **BOOLEAN** | | [optional] **declawed** | **BOOLEAN** | | [optional]

View File

@ -4,7 +4,7 @@
Name | Type | Description | Notes Name | Type | Description | Notes
------------ | ------------- | ------------- | ------------- ------------ | ------------- | ------------- | -------------
**class_name** | **String** | | **class_name** | **String** | |
**color** | **String** | | [optional] [default to &quot;red&quot;] **color** | **String** | | [optional] [default to &#39;red&#39;]
**breed** | **String** | | [optional] **breed** | **String** | | [optional]

View File

@ -274,21 +274,21 @@ number = 8.14 # Float | None
double = 1.2 # Float | None double = 1.2 # Float | None
pattern_without_delimiter = "pattern_without_delimiter_example" # String | None pattern_without_delimiter = 'pattern_without_delimiter_example' # String | None
byte = "B" # String | None byte = 'B' # String | None
opts = { opts = {
integer: 56, # Integer | None integer: 56, # Integer | None
int32: 56, # Integer | None int32: 56, # Integer | None
int64: 789, # Integer | None int64: 789, # Integer | None
float: 3.4, # Float | None float: 3.4, # Float | None
string: "string_example", # String | None string: 'string_example', # String | None
binary: "B", # String | None binary: 'B', # String | None
date: Date.parse("2013-10-20"), # Date | None date: Date.parse('2013-10-20'), # Date | None
date_time: DateTime.parse("2013-10-20T19:20:30+01:00"), # DateTime | None date_time: DateTime.parse('2013-10-20T19:20:30+01:00'), # DateTime | None
password: "password_example", # String | None password: 'password_example', # String | None
callback: "callback_example" # String | None callback: 'callback_example' # String | None
} }
begin begin
@ -348,12 +348,12 @@ require 'petstore'
api_instance = Petstore::FakeApi.new api_instance = Petstore::FakeApi.new
opts = { opts = {
enum_form_string_array: ["enum_form_string_array_example"], # Array<String> | Form parameter enum test (string array) enum_form_string_array: ['enum_form_string_array_example'], # Array<String> | Form parameter enum test (string array)
enum_form_string: "-efg", # String | Form parameter enum test (string) enum_form_string: '-efg', # String | Form parameter enum test (string)
enum_header_string_array: ["enum_header_string_array_example"], # Array<String> | Header parameter enum test (string array) enum_header_string_array: ['enum_header_string_array_example'], # Array<String> | Header parameter enum test (string array)
enum_header_string: "-efg", # String | Header parameter enum test (string) enum_header_string: '-efg', # String | Header parameter enum test (string)
enum_query_string_array: ["enum_query_string_array_example"], # Array<String> | Query parameter enum test (string array) enum_query_string_array: ['enum_query_string_array_example'], # Array<String> | Query parameter enum test (string array)
enum_query_string: "-efg", # String | Query parameter enum test (string) enum_query_string: '-efg', # String | Query parameter enum test (string)
enum_query_integer: 56, # Integer | Query parameter enum test (double) enum_query_integer: 56, # Integer | Query parameter enum test (double)
enum_query_double: 1.2 # Float | Query parameter enum test (double) enum_query_double: 1.2 # Float | Query parameter enum test (double)
} }
@ -454,9 +454,9 @@ require 'petstore'
api_instance = Petstore::FakeApi.new api_instance = Petstore::FakeApi.new
param = "param_example" # String | field1 param = 'param_example' # String | field1
param2 = "param2_example" # String | field2 param2 = 'param2_example' # String | field2
begin begin

View File

@ -87,7 +87,7 @@ api_instance = Petstore::PetApi.new
pet_id = 789 # Integer | Pet id to delete pet_id = 789 # Integer | Pet id to delete
opts = { opts = {
api_key: "api_key_example" # String | api_key: 'api_key_example' # String |
} }
begin begin
@ -139,7 +139,7 @@ end
api_instance = Petstore::PetApi.new api_instance = Petstore::PetApi.new
status = ["status_example"] # Array<String> | Status values that need to be considered for filter status = ['status_example'] # Array<String> | Status values that need to be considered for filter
begin begin
@ -191,7 +191,7 @@ end
api_instance = Petstore::PetApi.new api_instance = Petstore::PetApi.new
tags = ["tags_example"] # Array<String> | Tags to filter by tags = ['tags_example'] # Array<String> | Tags to filter by
begin begin
@ -351,8 +351,8 @@ api_instance = Petstore::PetApi.new
pet_id = 789 # Integer | ID of pet that needs to be updated pet_id = 789 # Integer | ID of pet that needs to be updated
opts = { opts = {
name: "name_example", # String | Updated name of the pet name: 'name_example', # String | Updated name of the pet
status: "status_example" # String | Updated status of the pet status: 'status_example' # String | Updated status of the pet
} }
begin begin
@ -408,8 +408,8 @@ api_instance = Petstore::PetApi.new
pet_id = 789 # Integer | ID of pet to update pet_id = 789 # Integer | ID of pet to update
opts = { opts = {
additional_metadata: "additional_metadata_example", # String | Additional data to pass to server additional_metadata: 'additional_metadata_example', # String | Additional data to pass to server
file: File.new("/path/to/file.txt") # File | file to upload file: File.new('/path/to/file.txt') # File | file to upload
} }
begin begin

View File

@ -24,7 +24,7 @@ require 'petstore'
api_instance = Petstore::StoreApi.new api_instance = Petstore::StoreApi.new
order_id = "order_id_example" # String | ID of the order that needs to be deleted order_id = 'order_id_example' # String | ID of the order that needs to be deleted
begin begin

View File

@ -166,7 +166,7 @@ require 'petstore'
api_instance = Petstore::UserApi.new api_instance = Petstore::UserApi.new
username = "username_example" # String | The name that needs to be deleted username = 'username_example' # String | The name that needs to be deleted
begin begin
@ -212,7 +212,7 @@ require 'petstore'
api_instance = Petstore::UserApi.new api_instance = Petstore::UserApi.new
username = "username_example" # String | The name that needs to be fetched. Use user1 for testing. username = 'username_example' # String | The name that needs to be fetched. Use user1 for testing.
begin begin
@ -259,9 +259,9 @@ require 'petstore'
api_instance = Petstore::UserApi.new api_instance = Petstore::UserApi.new
username = "username_example" # String | The user name for login username = 'username_example' # String | The user name for login
password = "password_example" # String | The password for login in clear text password = 'password_example' # String | The password for login in clear text
begin begin
@ -349,7 +349,7 @@ require 'petstore'
api_instance = Petstore::UserApi.new api_instance = Petstore::UserApi.new
username = "username_example" # String | name that need to be deleted username = 'username_example' # String | name that need to be deleted
body = Petstore::User.new # User | Updated user object body = Petstore::User.new # User | Updated user object

View File

@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end

View File

@ -6,11 +6,11 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require "uri" require 'uri'
module Petstore module Petstore
class AnotherFakeApi class AnotherFakeApi
@ -19,7 +19,6 @@ module Petstore
def initialize(api_client = ApiClient.default) def initialize(api_client = ApiClient.default)
@api_client = api_client @api_client = api_client
end end
# To test special tags # To test special tags
# To test special tags # To test special tags
# @param body client model # @param body client model
@ -27,7 +26,7 @@ module Petstore
# @return [Client] # @return [Client]
def test_special_tags(body, opts = {}) def test_special_tags(body, opts = {})
data, _status_code, _headers = test_special_tags_with_http_info(body, opts) data, _status_code, _headers = test_special_tags_with_http_info(body, opts)
return data data
end end
# To test special tags # To test special tags
@ -37,14 +36,14 @@ module Petstore
# @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers # @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers
def test_special_tags_with_http_info(body, opts = {}) def test_special_tags_with_http_info(body, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: AnotherFakeApi.test_special_tags ..." @api_client.config.logger.debug 'Calling API: AnotherFakeApi.test_special_tags ...'
end end
# verify the required parameter 'body' is set # verify the required parameter 'body' is set
if @api_client.config.client_side_validation && body.nil? if @api_client.config.client_side_validation && body.nil?
fail ArgumentError, "Missing the required parameter 'body' when calling AnotherFakeApi.test_special_tags" fail ArgumentError, "Missing the required parameter 'body' when calling AnotherFakeApi.test_special_tags"
end end
# resource path # resource path
local_var_path = "/another-fake/dummy" local_var_path = '/another-fake/dummy'
# query parameters # query parameters
query_params = {} query_params = {}

View File

@ -6,11 +6,11 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require "uri" require 'uri'
module Petstore module Petstore
class FakeApi class FakeApi
@ -19,28 +19,25 @@ module Petstore
def initialize(api_client = ApiClient.default) def initialize(api_client = ApiClient.default)
@api_client = api_client @api_client = api_client
end end
#
# Test serialization of outer boolean types # Test serialization of outer boolean types
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @option opts [OuterBoolean] :body Input boolean as post body # @option opts [OuterBoolean] :body Input boolean as post body
# @return [OuterBoolean] # @return [OuterBoolean]
def fake_outer_boolean_serialize(opts = {}) def fake_outer_boolean_serialize(opts = {})
data, _status_code, _headers = fake_outer_boolean_serialize_with_http_info(opts) data, _status_code, _headers = fake_outer_boolean_serialize_with_http_info(opts)
return data data
end end
#
# Test serialization of outer boolean types # Test serialization of outer boolean types
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @option opts [OuterBoolean] :body Input boolean as post body # @option opts [OuterBoolean] :body Input boolean as post body
# @return [Array<(OuterBoolean, Fixnum, Hash)>] OuterBoolean data, response status code and response headers # @return [Array<(OuterBoolean, Fixnum, Hash)>] OuterBoolean data, response status code and response headers
def fake_outer_boolean_serialize_with_http_info(opts = {}) def fake_outer_boolean_serialize_with_http_info(opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: FakeApi.fake_outer_boolean_serialize ..." @api_client.config.logger.debug 'Calling API: FakeApi.fake_outer_boolean_serialize ...'
end end
# resource path # resource path
local_var_path = "/fake/outer/boolean" local_var_path = '/fake/outer/boolean'
# query parameters # query parameters
query_params = {} query_params = {}
@ -66,28 +63,25 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
#
# Test serialization of object with outer number type # Test serialization of object with outer number type
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @option opts [OuterComposite] :body Input composite as post body # @option opts [OuterComposite] :body Input composite as post body
# @return [OuterComposite] # @return [OuterComposite]
def fake_outer_composite_serialize(opts = {}) def fake_outer_composite_serialize(opts = {})
data, _status_code, _headers = fake_outer_composite_serialize_with_http_info(opts) data, _status_code, _headers = fake_outer_composite_serialize_with_http_info(opts)
return data data
end end
#
# Test serialization of object with outer number type # Test serialization of object with outer number type
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @option opts [OuterComposite] :body Input composite as post body # @option opts [OuterComposite] :body Input composite as post body
# @return [Array<(OuterComposite, Fixnum, Hash)>] OuterComposite data, response status code and response headers # @return [Array<(OuterComposite, Fixnum, Hash)>] OuterComposite data, response status code and response headers
def fake_outer_composite_serialize_with_http_info(opts = {}) def fake_outer_composite_serialize_with_http_info(opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: FakeApi.fake_outer_composite_serialize ..." @api_client.config.logger.debug 'Calling API: FakeApi.fake_outer_composite_serialize ...'
end end
# resource path # resource path
local_var_path = "/fake/outer/composite" local_var_path = '/fake/outer/composite'
# query parameters # query parameters
query_params = {} query_params = {}
@ -113,28 +107,25 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
#
# Test serialization of outer number types # Test serialization of outer number types
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @option opts [OuterNumber] :body Input number as post body # @option opts [OuterNumber] :body Input number as post body
# @return [OuterNumber] # @return [OuterNumber]
def fake_outer_number_serialize(opts = {}) def fake_outer_number_serialize(opts = {})
data, _status_code, _headers = fake_outer_number_serialize_with_http_info(opts) data, _status_code, _headers = fake_outer_number_serialize_with_http_info(opts)
return data data
end end
#
# Test serialization of outer number types # Test serialization of outer number types
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @option opts [OuterNumber] :body Input number as post body # @option opts [OuterNumber] :body Input number as post body
# @return [Array<(OuterNumber, Fixnum, Hash)>] OuterNumber data, response status code and response headers # @return [Array<(OuterNumber, Fixnum, Hash)>] OuterNumber data, response status code and response headers
def fake_outer_number_serialize_with_http_info(opts = {}) def fake_outer_number_serialize_with_http_info(opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: FakeApi.fake_outer_number_serialize ..." @api_client.config.logger.debug 'Calling API: FakeApi.fake_outer_number_serialize ...'
end end
# resource path # resource path
local_var_path = "/fake/outer/number" local_var_path = '/fake/outer/number'
# query parameters # query parameters
query_params = {} query_params = {}
@ -160,28 +151,25 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
#
# Test serialization of outer string types # Test serialization of outer string types
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @option opts [OuterString] :body Input string as post body # @option opts [OuterString] :body Input string as post body
# @return [OuterString] # @return [OuterString]
def fake_outer_string_serialize(opts = {}) def fake_outer_string_serialize(opts = {})
data, _status_code, _headers = fake_outer_string_serialize_with_http_info(opts) data, _status_code, _headers = fake_outer_string_serialize_with_http_info(opts)
return data data
end end
#
# Test serialization of outer string types # Test serialization of outer string types
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @option opts [OuterString] :body Input string as post body # @option opts [OuterString] :body Input string as post body
# @return [Array<(OuterString, Fixnum, Hash)>] OuterString data, response status code and response headers # @return [Array<(OuterString, Fixnum, Hash)>] OuterString data, response status code and response headers
def fake_outer_string_serialize_with_http_info(opts = {}) def fake_outer_string_serialize_with_http_info(opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: FakeApi.fake_outer_string_serialize ..." @api_client.config.logger.debug 'Calling API: FakeApi.fake_outer_string_serialize ...'
end end
# resource path # resource path
local_var_path = "/fake/outer/string" local_var_path = '/fake/outer/string'
# query parameters # query parameters
query_params = {} query_params = {}
@ -207,7 +195,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# To test \"client\" model # To test \"client\" model
# To test \"client\" model # To test \"client\" model
# @param body client model # @param body client model
@ -215,7 +202,7 @@ module Petstore
# @return [Client] # @return [Client]
def test_client_model(body, opts = {}) def test_client_model(body, opts = {})
data, _status_code, _headers = test_client_model_with_http_info(body, opts) data, _status_code, _headers = test_client_model_with_http_info(body, opts)
return data data
end end
# To test \&quot;client\&quot; model # To test \&quot;client\&quot; model
@ -225,14 +212,14 @@ module Petstore
# @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers # @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers
def test_client_model_with_http_info(body, opts = {}) def test_client_model_with_http_info(body, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: FakeApi.test_client_model ..." @api_client.config.logger.debug 'Calling API: FakeApi.test_client_model ...'
end end
# verify the required parameter 'body' is set # verify the required parameter 'body' is set
if @api_client.config.client_side_validation && body.nil? if @api_client.config.client_side_validation && body.nil?
fail ArgumentError, "Missing the required parameter 'body' when calling FakeApi.test_client_model" fail ArgumentError, "Missing the required parameter 'body' when calling FakeApi.test_client_model"
end end
# resource path # resource path
local_var_path = "/fake" local_var_path = '/fake'
# query parameters # query parameters
query_params = {} query_params = {}
@ -262,7 +249,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
# @param number None # @param number None
@ -283,7 +269,7 @@ module Petstore
# @return [nil] # @return [nil]
def test_endpoint_parameters(number, double, pattern_without_delimiter, byte, opts = {}) def test_endpoint_parameters(number, double, pattern_without_delimiter, byte, opts = {})
test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, opts) test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, opts)
return nil nil
end end
# Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트 # Fake endpoint for testing various parameters 假端點 偽のエンドポイント 가짜 엔드 포인트
@ -306,7 +292,7 @@ module Petstore
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, opts = {}) def test_endpoint_parameters_with_http_info(number, double, pattern_without_delimiter, byte, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: FakeApi.test_endpoint_parameters ..." @api_client.config.logger.debug 'Calling API: FakeApi.test_endpoint_parameters ...'
end end
# verify the required parameter 'number' is set # verify the required parameter 'number' is set
if @api_client.config.client_side_validation && number.nil? if @api_client.config.client_side_validation && number.nil?
@ -377,7 +363,7 @@ module Petstore
end end
# resource path # resource path
local_var_path = "/fake" local_var_path = '/fake'
# query parameters # query parameters
query_params = {} query_params = {}
@ -391,20 +377,20 @@ module Petstore
# form parameters # form parameters
form_params = {} form_params = {}
form_params["number"] = number form_params['number'] = number
form_params["double"] = double form_params['double'] = double
form_params["pattern_without_delimiter"] = pattern_without_delimiter form_params['pattern_without_delimiter'] = pattern_without_delimiter
form_params["byte"] = byte form_params['byte'] = byte
form_params["integer"] = opts[:'integer'] if !opts[:'integer'].nil? form_params['integer'] = opts[:'integer'] if !opts[:'integer'].nil?
form_params["int32"] = opts[:'int32'] if !opts[:'int32'].nil? form_params['int32'] = opts[:'int32'] if !opts[:'int32'].nil?
form_params["int64"] = opts[:'int64'] if !opts[:'int64'].nil? form_params['int64'] = opts[:'int64'] if !opts[:'int64'].nil?
form_params["float"] = opts[:'float'] if !opts[:'float'].nil? form_params['float'] = opts[:'float'] if !opts[:'float'].nil?
form_params["string"] = opts[:'string'] if !opts[:'string'].nil? form_params['string'] = opts[:'string'] if !opts[:'string'].nil?
form_params["binary"] = opts[:'binary'] if !opts[:'binary'].nil? form_params['binary'] = opts[:'binary'] if !opts[:'binary'].nil?
form_params["date"] = opts[:'date'] if !opts[:'date'].nil? form_params['date'] = opts[:'date'] if !opts[:'date'].nil?
form_params["dateTime"] = opts[:'date_time'] if !opts[:'date_time'].nil? form_params['dateTime'] = opts[:'date_time'] if !opts[:'date_time'].nil?
form_params["password"] = opts[:'password'] if !opts[:'password'].nil? form_params['password'] = opts[:'password'] if !opts[:'password'].nil?
form_params["callback"] = opts[:'callback'] if !opts[:'callback'].nil? form_params['callback'] = opts[:'callback'] if !opts[:'callback'].nil?
# http body (model) # http body (model)
post_body = nil post_body = nil
@ -420,7 +406,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# To test enum parameters # To test enum parameters
# To test enum parameters # To test enum parameters
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
@ -435,7 +420,7 @@ module Petstore
# @return [nil] # @return [nil]
def test_enum_parameters(opts = {}) def test_enum_parameters(opts = {})
test_enum_parameters_with_http_info(opts) test_enum_parameters_with_http_info(opts)
return nil nil
end end
# To test enum parameters # To test enum parameters
@ -452,21 +437,21 @@ module Petstore
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def test_enum_parameters_with_http_info(opts = {}) def test_enum_parameters_with_http_info(opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: FakeApi.test_enum_parameters ..." @api_client.config.logger.debug 'Calling API: FakeApi.test_enum_parameters ...'
end end
if @api_client.config.client_side_validation && opts[:'enum_form_string_array'] && !opts[:'enum_form_string_array'].all?{|item| ['>', '$'].include?(item)} if @api_client.config.client_side_validation && opts[:'enum_form_string_array'] && !opts[:'enum_form_string_array'].all? { |item| ['>', '$'].include?(item) }
fail ArgumentError, 'invalid value for "enum_form_string_array", must include one of >, $' fail ArgumentError, 'invalid value for "enum_form_string_array", must include one of >, $'
end end
if @api_client.config.client_side_validation && opts[:'enum_form_string'] && !['_abc', '-efg', '(xyz)'].include?(opts[:'enum_form_string']) if @api_client.config.client_side_validation && opts[:'enum_form_string'] && !['_abc', '-efg', '(xyz)'].include?(opts[:'enum_form_string'])
fail ArgumentError, 'invalid value for "enum_form_string", must be one of _abc, -efg, (xyz)' fail ArgumentError, 'invalid value for "enum_form_string", must be one of _abc, -efg, (xyz)'
end end
if @api_client.config.client_side_validation && opts[:'enum_header_string_array'] && !opts[:'enum_header_string_array'].all?{|item| ['>', '$'].include?(item)} if @api_client.config.client_side_validation && opts[:'enum_header_string_array'] && !opts[:'enum_header_string_array'].all? { |item| ['>', '$'].include?(item) }
fail ArgumentError, 'invalid value for "enum_header_string_array", must include one of >, $' fail ArgumentError, 'invalid value for "enum_header_string_array", must include one of >, $'
end end
if @api_client.config.client_side_validation && opts[:'enum_header_string'] && !['_abc', '-efg', '(xyz)'].include?(opts[:'enum_header_string']) if @api_client.config.client_side_validation && opts[:'enum_header_string'] && !['_abc', '-efg', '(xyz)'].include?(opts[:'enum_header_string'])
fail ArgumentError, 'invalid value for "enum_header_string", must be one of _abc, -efg, (xyz)' fail ArgumentError, 'invalid value for "enum_header_string", must be one of _abc, -efg, (xyz)'
end end
if @api_client.config.client_side_validation && opts[:'enum_query_string_array'] && !opts[:'enum_query_string_array'].all?{|item| ['>', '$'].include?(item)} if @api_client.config.client_side_validation && opts[:'enum_query_string_array'] && !opts[:'enum_query_string_array'].all? { |item| ['>', '$'].include?(item) }
fail ArgumentError, 'invalid value for "enum_query_string_array", must include one of >, $' fail ArgumentError, 'invalid value for "enum_query_string_array", must include one of >, $'
end end
if @api_client.config.client_side_validation && opts[:'enum_query_string'] && !['_abc', '-efg', '(xyz)'].include?(opts[:'enum_query_string']) if @api_client.config.client_side_validation && opts[:'enum_query_string'] && !['_abc', '-efg', '(xyz)'].include?(opts[:'enum_query_string'])
@ -479,7 +464,7 @@ module Petstore
fail ArgumentError, 'invalid value for "enum_query_double", must be one of 1.1, -1.2' fail ArgumentError, 'invalid value for "enum_query_double", must be one of 1.1, -1.2'
end end
# resource path # resource path
local_var_path = "/fake" local_var_path = '/fake'
# query parameters # query parameters
query_params = {} query_params = {}
@ -498,9 +483,9 @@ module Petstore
# form parameters # form parameters
form_params = {} form_params = {}
form_params["enum_form_string_array"] = @api_client.build_collection_param(opts[:'enum_form_string_array'], :csv) if !opts[:'enum_form_string_array'].nil? form_params['enum_form_string_array'] = @api_client.build_collection_param(opts[:'enum_form_string_array'], :csv) if !opts[:'enum_form_string_array'].nil?
form_params["enum_form_string"] = opts[:'enum_form_string'] if !opts[:'enum_form_string'].nil? form_params['enum_form_string'] = opts[:'enum_form_string'] if !opts[:'enum_form_string'].nil?
form_params["enum_query_double"] = opts[:'enum_query_double'] if !opts[:'enum_query_double'].nil? form_params['enum_query_double'] = opts[:'enum_query_double'] if !opts[:'enum_query_double'].nil?
# http body (model) # http body (model)
post_body = nil post_body = nil
@ -516,7 +501,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# test inline additionalProperties # test inline additionalProperties
# #
# @param param request body # @param param request body
@ -524,7 +508,7 @@ module Petstore
# @return [nil] # @return [nil]
def test_inline_additional_properties(param, opts = {}) def test_inline_additional_properties(param, opts = {})
test_inline_additional_properties_with_http_info(param, opts) test_inline_additional_properties_with_http_info(param, opts)
return nil nil
end end
# test inline additionalProperties # test inline additionalProperties
@ -534,14 +518,14 @@ module Petstore
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def test_inline_additional_properties_with_http_info(param, opts = {}) def test_inline_additional_properties_with_http_info(param, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: FakeApi.test_inline_additional_properties ..." @api_client.config.logger.debug 'Calling API: FakeApi.test_inline_additional_properties ...'
end end
# verify the required parameter 'param' is set # verify the required parameter 'param' is set
if @api_client.config.client_side_validation && param.nil? if @api_client.config.client_side_validation && param.nil?
fail ArgumentError, "Missing the required parameter 'param' when calling FakeApi.test_inline_additional_properties" fail ArgumentError, "Missing the required parameter 'param' when calling FakeApi.test_inline_additional_properties"
end end
# resource path # resource path
local_var_path = "/fake/inline-additionalProperties" local_var_path = '/fake/inline-additionalProperties'
# query parameters # query parameters
query_params = {} query_params = {}
@ -568,7 +552,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# test json serialization of form data # test json serialization of form data
# #
# @param param field1 # @param param field1
@ -577,7 +560,7 @@ module Petstore
# @return [nil] # @return [nil]
def test_json_form_data(param, param2, opts = {}) def test_json_form_data(param, param2, opts = {})
test_json_form_data_with_http_info(param, param2, opts) test_json_form_data_with_http_info(param, param2, opts)
return nil nil
end end
# test json serialization of form data # test json serialization of form data
@ -588,7 +571,7 @@ module Petstore
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def test_json_form_data_with_http_info(param, param2, opts = {}) def test_json_form_data_with_http_info(param, param2, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: FakeApi.test_json_form_data ..." @api_client.config.logger.debug 'Calling API: FakeApi.test_json_form_data ...'
end end
# verify the required parameter 'param' is set # verify the required parameter 'param' is set
if @api_client.config.client_side_validation && param.nil? if @api_client.config.client_side_validation && param.nil?
@ -599,7 +582,7 @@ module Petstore
fail ArgumentError, "Missing the required parameter 'param2' when calling FakeApi.test_json_form_data" fail ArgumentError, "Missing the required parameter 'param2' when calling FakeApi.test_json_form_data"
end end
# resource path # resource path
local_var_path = "/fake/jsonFormData" local_var_path = '/fake/jsonFormData'
# query parameters # query parameters
query_params = {} query_params = {}
@ -611,8 +594,8 @@ module Petstore
# form parameters # form parameters
form_params = {} form_params = {}
form_params["param"] = param form_params['param'] = param
form_params["param2"] = param2 form_params['param2'] = param2
# http body (model) # http body (model)
post_body = nil post_body = nil

View File

@ -6,11 +6,11 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require "uri" require 'uri'
module Petstore module Petstore
class FakeClassnameTags123Api class FakeClassnameTags123Api
@ -19,32 +19,29 @@ module Petstore
def initialize(api_client = ApiClient.default) def initialize(api_client = ApiClient.default)
@api_client = api_client @api_client = api_client
end end
# To test class name in snake case # To test class name in snake case
#
# @param body client model # @param body client model
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @return [Client] # @return [Client]
def test_classname(body, opts = {}) def test_classname(body, opts = {})
data, _status_code, _headers = test_classname_with_http_info(body, opts) data, _status_code, _headers = test_classname_with_http_info(body, opts)
return data data
end end
# To test class name in snake case # To test class name in snake case
#
# @param body client model # @param body client model
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers # @return [Array<(Client, Fixnum, Hash)>] Client data, response status code and response headers
def test_classname_with_http_info(body, opts = {}) def test_classname_with_http_info(body, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: FakeClassnameTags123Api.test_classname ..." @api_client.config.logger.debug 'Calling API: FakeClassnameTags123Api.test_classname ...'
end end
# verify the required parameter 'body' is set # verify the required parameter 'body' is set
if @api_client.config.client_side_validation && body.nil? if @api_client.config.client_side_validation && body.nil?
fail ArgumentError, "Missing the required parameter 'body' when calling FakeClassnameTags123Api.test_classname" fail ArgumentError, "Missing the required parameter 'body' when calling FakeClassnameTags123Api.test_classname"
end end
# resource path # resource path
local_var_path = "/fake_classname_test" local_var_path = '/fake_classname_test'
# query parameters # query parameters
query_params = {} query_params = {}

View File

@ -6,11 +6,11 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require "uri" require 'uri'
module Petstore module Petstore
class PetApi class PetApi
@ -19,7 +19,6 @@ module Petstore
def initialize(api_client = ApiClient.default) def initialize(api_client = ApiClient.default)
@api_client = api_client @api_client = api_client
end end
# Add a new pet to the store # Add a new pet to the store
# #
# @param body Pet object that needs to be added to the store # @param body Pet object that needs to be added to the store
@ -27,7 +26,7 @@ module Petstore
# @return [nil] # @return [nil]
def add_pet(body, opts = {}) def add_pet(body, opts = {})
add_pet_with_http_info(body, opts) add_pet_with_http_info(body, opts)
return nil nil
end end
# Add a new pet to the store # Add a new pet to the store
@ -37,14 +36,14 @@ module Petstore
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def add_pet_with_http_info(body, opts = {}) def add_pet_with_http_info(body, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi.add_pet ..." @api_client.config.logger.debug 'Calling API: PetApi.add_pet ...'
end end
# verify the required parameter 'body' is set # verify the required parameter 'body' is set
if @api_client.config.client_side_validation && body.nil? if @api_client.config.client_side_validation && body.nil?
fail ArgumentError, "Missing the required parameter 'body' when calling PetApi.add_pet" fail ArgumentError, "Missing the required parameter 'body' when calling PetApi.add_pet"
end end
# resource path # resource path
local_var_path = "/pet" local_var_path = '/pet'
# query parameters # query parameters
query_params = {} query_params = {}
@ -73,7 +72,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Deletes a pet # Deletes a pet
# #
# @param pet_id Pet id to delete # @param pet_id Pet id to delete
@ -82,7 +80,7 @@ module Petstore
# @return [nil] # @return [nil]
def delete_pet(pet_id, opts = {}) def delete_pet(pet_id, opts = {})
delete_pet_with_http_info(pet_id, opts) delete_pet_with_http_info(pet_id, opts)
return nil nil
end end
# Deletes a pet # Deletes a pet
@ -93,14 +91,14 @@ module Petstore
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_pet_with_http_info(pet_id, opts = {}) def delete_pet_with_http_info(pet_id, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi.delete_pet ..." @api_client.config.logger.debug 'Calling API: PetApi.delete_pet ...'
end end
# verify the required parameter 'pet_id' is set # verify the required parameter 'pet_id' is set
if @api_client.config.client_side_validation && pet_id.nil? if @api_client.config.client_side_validation && pet_id.nil?
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet" fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.delete_pet"
end end
# resource path # resource path
local_var_path = "/pet/{petId}".sub('{' + 'petId' + '}', pet_id.to_s) local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters # query parameters
query_params = {} query_params = {}
@ -128,7 +126,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Finds Pets by status # Finds Pets by status
# Multiple status values can be provided with comma separated strings # Multiple status values can be provided with comma separated strings
# @param status Status values that need to be considered for filter # @param status Status values that need to be considered for filter
@ -136,7 +133,7 @@ module Petstore
# @return [Array<Pet>] # @return [Array<Pet>]
def find_pets_by_status(status, opts = {}) def find_pets_by_status(status, opts = {})
data, _status_code, _headers = find_pets_by_status_with_http_info(status, opts) data, _status_code, _headers = find_pets_by_status_with_http_info(status, opts)
return data data
end end
# Finds Pets by status # Finds Pets by status
@ -146,14 +143,14 @@ module Petstore
# @return [Array<(Array<Pet>, Fixnum, Hash)>] Array<Pet> data, response status code and response headers # @return [Array<(Array<Pet>, Fixnum, Hash)>] Array<Pet> data, response status code and response headers
def find_pets_by_status_with_http_info(status, opts = {}) def find_pets_by_status_with_http_info(status, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi.find_pets_by_status ..." @api_client.config.logger.debug 'Calling API: PetApi.find_pets_by_status ...'
end end
# verify the required parameter 'status' is set # verify the required parameter 'status' is set
if @api_client.config.client_side_validation && status.nil? if @api_client.config.client_side_validation && status.nil?
fail ArgumentError, "Missing the required parameter 'status' when calling PetApi.find_pets_by_status" fail ArgumentError, "Missing the required parameter 'status' when calling PetApi.find_pets_by_status"
end end
# resource path # resource path
local_var_path = "/pet/findByStatus" local_var_path = '/pet/findByStatus'
# query parameters # query parameters
query_params = {} query_params = {}
@ -182,7 +179,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Finds Pets by tags # Finds Pets by tags
# Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. # Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
# @param tags Tags to filter by # @param tags Tags to filter by
@ -190,7 +186,7 @@ module Petstore
# @return [Array<Pet>] # @return [Array<Pet>]
def find_pets_by_tags(tags, opts = {}) def find_pets_by_tags(tags, opts = {})
data, _status_code, _headers = find_pets_by_tags_with_http_info(tags, opts) data, _status_code, _headers = find_pets_by_tags_with_http_info(tags, opts)
return data data
end end
# Finds Pets by tags # Finds Pets by tags
@ -200,14 +196,14 @@ module Petstore
# @return [Array<(Array<Pet>, Fixnum, Hash)>] Array<Pet> data, response status code and response headers # @return [Array<(Array<Pet>, Fixnum, Hash)>] Array<Pet> data, response status code and response headers
def find_pets_by_tags_with_http_info(tags, opts = {}) def find_pets_by_tags_with_http_info(tags, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi.find_pets_by_tags ..." @api_client.config.logger.debug 'Calling API: PetApi.find_pets_by_tags ...'
end end
# verify the required parameter 'tags' is set # verify the required parameter 'tags' is set
if @api_client.config.client_side_validation && tags.nil? if @api_client.config.client_side_validation && tags.nil?
fail ArgumentError, "Missing the required parameter 'tags' when calling PetApi.find_pets_by_tags" fail ArgumentError, "Missing the required parameter 'tags' when calling PetApi.find_pets_by_tags"
end end
# resource path # resource path
local_var_path = "/pet/findByTags" local_var_path = '/pet/findByTags'
# query parameters # query parameters
query_params = {} query_params = {}
@ -236,7 +232,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Find pet by ID # Find pet by ID
# Returns a single pet # Returns a single pet
# @param pet_id ID of pet to return # @param pet_id ID of pet to return
@ -244,7 +239,7 @@ module Petstore
# @return [Pet] # @return [Pet]
def get_pet_by_id(pet_id, opts = {}) def get_pet_by_id(pet_id, opts = {})
data, _status_code, _headers = get_pet_by_id_with_http_info(pet_id, opts) data, _status_code, _headers = get_pet_by_id_with_http_info(pet_id, opts)
return data data
end end
# Find pet by ID # Find pet by ID
@ -254,14 +249,14 @@ module Petstore
# @return [Array<(Pet, Fixnum, Hash)>] Pet data, response status code and response headers # @return [Array<(Pet, Fixnum, Hash)>] Pet data, response status code and response headers
def get_pet_by_id_with_http_info(pet_id, opts = {}) def get_pet_by_id_with_http_info(pet_id, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi.get_pet_by_id ..." @api_client.config.logger.debug 'Calling API: PetApi.get_pet_by_id ...'
end end
# verify the required parameter 'pet_id' is set # verify the required parameter 'pet_id' is set
if @api_client.config.client_side_validation && pet_id.nil? if @api_client.config.client_side_validation && pet_id.nil?
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.get_pet_by_id" fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.get_pet_by_id"
end end
# resource path # resource path
local_var_path = "/pet/{petId}".sub('{' + 'petId' + '}', pet_id.to_s) local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters # query parameters
query_params = {} query_params = {}
@ -289,7 +284,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Update an existing pet # Update an existing pet
# #
# @param body Pet object that needs to be added to the store # @param body Pet object that needs to be added to the store
@ -297,7 +291,7 @@ module Petstore
# @return [nil] # @return [nil]
def update_pet(body, opts = {}) def update_pet(body, opts = {})
update_pet_with_http_info(body, opts) update_pet_with_http_info(body, opts)
return nil nil
end end
# Update an existing pet # Update an existing pet
@ -307,14 +301,14 @@ module Petstore
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def update_pet_with_http_info(body, opts = {}) def update_pet_with_http_info(body, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi.update_pet ..." @api_client.config.logger.debug 'Calling API: PetApi.update_pet ...'
end end
# verify the required parameter 'body' is set # verify the required parameter 'body' is set
if @api_client.config.client_side_validation && body.nil? if @api_client.config.client_side_validation && body.nil?
fail ArgumentError, "Missing the required parameter 'body' when calling PetApi.update_pet" fail ArgumentError, "Missing the required parameter 'body' when calling PetApi.update_pet"
end end
# resource path # resource path
local_var_path = "/pet" local_var_path = '/pet'
# query parameters # query parameters
query_params = {} query_params = {}
@ -343,7 +337,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Updates a pet in the store with form data # Updates a pet in the store with form data
# #
# @param pet_id ID of pet that needs to be updated # @param pet_id ID of pet that needs to be updated
@ -353,7 +346,7 @@ module Petstore
# @return [nil] # @return [nil]
def update_pet_with_form(pet_id, opts = {}) def update_pet_with_form(pet_id, opts = {})
update_pet_with_form_with_http_info(pet_id, opts) update_pet_with_form_with_http_info(pet_id, opts)
return nil nil
end end
# Updates a pet in the store with form data # Updates a pet in the store with form data
@ -365,14 +358,14 @@ module Petstore
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def update_pet_with_form_with_http_info(pet_id, opts = {}) def update_pet_with_form_with_http_info(pet_id, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi.update_pet_with_form ..." @api_client.config.logger.debug 'Calling API: PetApi.update_pet_with_form ...'
end end
# verify the required parameter 'pet_id' is set # verify the required parameter 'pet_id' is set
if @api_client.config.client_side_validation && pet_id.nil? if @api_client.config.client_side_validation && pet_id.nil?
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.update_pet_with_form" fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.update_pet_with_form"
end end
# resource path # resource path
local_var_path = "/pet/{petId}".sub('{' + 'petId' + '}', pet_id.to_s) local_var_path = '/pet/{petId}'.sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters # query parameters
query_params = {} query_params = {}
@ -386,8 +379,8 @@ module Petstore
# form parameters # form parameters
form_params = {} form_params = {}
form_params["name"] = opts[:'name'] if !opts[:'name'].nil? form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
form_params["status"] = opts[:'status'] if !opts[:'status'].nil? form_params['status'] = opts[:'status'] if !opts[:'status'].nil?
# http body (model) # http body (model)
post_body = nil post_body = nil
@ -403,7 +396,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# uploads an image # uploads an image
# #
# @param pet_id ID of pet to update # @param pet_id ID of pet to update
@ -413,7 +405,7 @@ module Petstore
# @return [ApiResponse] # @return [ApiResponse]
def upload_file(pet_id, opts = {}) def upload_file(pet_id, opts = {})
data, _status_code, _headers = upload_file_with_http_info(pet_id, opts) data, _status_code, _headers = upload_file_with_http_info(pet_id, opts)
return data data
end end
# uploads an image # uploads an image
@ -425,14 +417,14 @@ module Petstore
# @return [Array<(ApiResponse, Fixnum, Hash)>] ApiResponse data, response status code and response headers # @return [Array<(ApiResponse, Fixnum, Hash)>] ApiResponse data, response status code and response headers
def upload_file_with_http_info(pet_id, opts = {}) def upload_file_with_http_info(pet_id, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi.upload_file ..." @api_client.config.logger.debug 'Calling API: PetApi.upload_file ...'
end end
# verify the required parameter 'pet_id' is set # verify the required parameter 'pet_id' is set
if @api_client.config.client_side_validation && pet_id.nil? if @api_client.config.client_side_validation && pet_id.nil?
fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.upload_file" fail ArgumentError, "Missing the required parameter 'pet_id' when calling PetApi.upload_file"
end end
# resource path # resource path
local_var_path = "/pet/{petId}/uploadImage".sub('{' + 'petId' + '}', pet_id.to_s) local_var_path = '/pet/{petId}/uploadImage'.sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters # query parameters
query_params = {} query_params = {}
@ -446,8 +438,8 @@ module Petstore
# form parameters # form parameters
form_params = {} form_params = {}
form_params["additionalMetadata"] = opts[:'additional_metadata'] if !opts[:'additional_metadata'].nil? form_params['additionalMetadata'] = opts[:'additional_metadata'] if !opts[:'additional_metadata'].nil?
form_params["file"] = opts[:'file'] if !opts[:'file'].nil? form_params['file'] = opts[:'file'] if !opts[:'file'].nil?
# http body (model) # http body (model)
post_body = nil post_body = nil

View File

@ -6,11 +6,11 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require "uri" require 'uri'
module Petstore module Petstore
class StoreApi class StoreApi
@ -19,7 +19,6 @@ module Petstore
def initialize(api_client = ApiClient.default) def initialize(api_client = ApiClient.default)
@api_client = api_client @api_client = api_client
end end
# Delete purchase order by ID # Delete purchase order by ID
# For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors # For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
# @param order_id ID of the order that needs to be deleted # @param order_id ID of the order that needs to be deleted
@ -27,7 +26,7 @@ module Petstore
# @return [nil] # @return [nil]
def delete_order(order_id, opts = {}) def delete_order(order_id, opts = {})
delete_order_with_http_info(order_id, opts) delete_order_with_http_info(order_id, opts)
return nil nil
end end
# Delete purchase order by ID # Delete purchase order by ID
@ -37,14 +36,14 @@ module Petstore
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_order_with_http_info(order_id, opts = {}) def delete_order_with_http_info(order_id, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: StoreApi.delete_order ..." @api_client.config.logger.debug 'Calling API: StoreApi.delete_order ...'
end end
# verify the required parameter 'order_id' is set # verify the required parameter 'order_id' is set
if @api_client.config.client_side_validation && order_id.nil? if @api_client.config.client_side_validation && order_id.nil?
fail ArgumentError, "Missing the required parameter 'order_id' when calling StoreApi.delete_order" fail ArgumentError, "Missing the required parameter 'order_id' when calling StoreApi.delete_order"
end end
# resource path # resource path
local_var_path = "/store/order/{order_id}".sub('{' + 'order_id' + '}', order_id.to_s) local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', order_id.to_s)
# query parameters # query parameters
query_params = {} query_params = {}
@ -71,14 +70,13 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Returns pet inventories by status # Returns pet inventories by status
# Returns a map of status codes to quantities # Returns a map of status codes to quantities
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @return [Hash<String, Integer>] # @return [Hash<String, Integer>]
def get_inventory(opts = {}) def get_inventory(opts = {})
data, _status_code, _headers = get_inventory_with_http_info(opts) data, _status_code, _headers = get_inventory_with_http_info(opts)
return data data
end end
# Returns pet inventories by status # Returns pet inventories by status
@ -87,10 +85,10 @@ module Petstore
# @return [Array<(Hash<String, Integer>, Fixnum, Hash)>] Hash<String, Integer> data, response status code and response headers # @return [Array<(Hash<String, Integer>, Fixnum, Hash)>] Hash<String, Integer> data, response status code and response headers
def get_inventory_with_http_info(opts = {}) def get_inventory_with_http_info(opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: StoreApi.get_inventory ..." @api_client.config.logger.debug 'Calling API: StoreApi.get_inventory ...'
end end
# resource path # resource path
local_var_path = "/store/inventory" local_var_path = '/store/inventory'
# query parameters # query parameters
query_params = {} query_params = {}
@ -118,7 +116,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Find purchase order by ID # Find purchase order by ID
# For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions # For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
# @param order_id ID of pet that needs to be fetched # @param order_id ID of pet that needs to be fetched
@ -126,7 +123,7 @@ module Petstore
# @return [Order] # @return [Order]
def get_order_by_id(order_id, opts = {}) def get_order_by_id(order_id, opts = {})
data, _status_code, _headers = get_order_by_id_with_http_info(order_id, opts) data, _status_code, _headers = get_order_by_id_with_http_info(order_id, opts)
return data data
end end
# Find purchase order by ID # Find purchase order by ID
@ -136,7 +133,7 @@ module Petstore
# @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers # @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers
def get_order_by_id_with_http_info(order_id, opts = {}) def get_order_by_id_with_http_info(order_id, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: StoreApi.get_order_by_id ..." @api_client.config.logger.debug 'Calling API: StoreApi.get_order_by_id ...'
end end
# verify the required parameter 'order_id' is set # verify the required parameter 'order_id' is set
if @api_client.config.client_side_validation && order_id.nil? if @api_client.config.client_side_validation && order_id.nil?
@ -151,7 +148,7 @@ module Petstore
end end
# resource path # resource path
local_var_path = "/store/order/{order_id}".sub('{' + 'order_id' + '}', order_id.to_s) local_var_path = '/store/order/{order_id}'.sub('{' + 'order_id' + '}', order_id.to_s)
# query parameters # query parameters
query_params = {} query_params = {}
@ -179,7 +176,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Place an order for a pet # Place an order for a pet
# #
# @param body order placed for purchasing the pet # @param body order placed for purchasing the pet
@ -187,7 +183,7 @@ module Petstore
# @return [Order] # @return [Order]
def place_order(body, opts = {}) def place_order(body, opts = {})
data, _status_code, _headers = place_order_with_http_info(body, opts) data, _status_code, _headers = place_order_with_http_info(body, opts)
return data data
end end
# Place an order for a pet # Place an order for a pet
@ -197,14 +193,14 @@ module Petstore
# @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers # @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers
def place_order_with_http_info(body, opts = {}) def place_order_with_http_info(body, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: StoreApi.place_order ..." @api_client.config.logger.debug 'Calling API: StoreApi.place_order ...'
end end
# verify the required parameter 'body' is set # verify the required parameter 'body' is set
if @api_client.config.client_side_validation && body.nil? if @api_client.config.client_side_validation && body.nil?
fail ArgumentError, "Missing the required parameter 'body' when calling StoreApi.place_order" fail ArgumentError, "Missing the required parameter 'body' when calling StoreApi.place_order"
end end
# resource path # resource path
local_var_path = "/store/order" local_var_path = '/store/order'
# query parameters # query parameters
query_params = {} query_params = {}

View File

@ -6,11 +6,11 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require "uri" require 'uri'
module Petstore module Petstore
class UserApi class UserApi
@ -19,7 +19,6 @@ module Petstore
def initialize(api_client = ApiClient.default) def initialize(api_client = ApiClient.default)
@api_client = api_client @api_client = api_client
end end
# Create user # Create user
# This can only be done by the logged in user. # This can only be done by the logged in user.
# @param body Created user object # @param body Created user object
@ -27,7 +26,7 @@ module Petstore
# @return [nil] # @return [nil]
def create_user(body, opts = {}) def create_user(body, opts = {})
create_user_with_http_info(body, opts) create_user_with_http_info(body, opts)
return nil nil
end end
# Create user # Create user
@ -37,14 +36,14 @@ module Petstore
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def create_user_with_http_info(body, opts = {}) def create_user_with_http_info(body, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: UserApi.create_user ..." @api_client.config.logger.debug 'Calling API: UserApi.create_user ...'
end end
# verify the required parameter 'body' is set # verify the required parameter 'body' is set
if @api_client.config.client_side_validation && body.nil? if @api_client.config.client_side_validation && body.nil?
fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.create_user" fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.create_user"
end end
# resource path # resource path
local_var_path = "/user" local_var_path = '/user'
# query parameters # query parameters
query_params = {} query_params = {}
@ -71,7 +70,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Creates list of users with given input array # Creates list of users with given input array
# #
# @param body List of user object # @param body List of user object
@ -79,7 +77,7 @@ module Petstore
# @return [nil] # @return [nil]
def create_users_with_array_input(body, opts = {}) def create_users_with_array_input(body, opts = {})
create_users_with_array_input_with_http_info(body, opts) create_users_with_array_input_with_http_info(body, opts)
return nil nil
end end
# Creates list of users with given input array # Creates list of users with given input array
@ -89,14 +87,14 @@ module Petstore
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def create_users_with_array_input_with_http_info(body, opts = {}) def create_users_with_array_input_with_http_info(body, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: UserApi.create_users_with_array_input ..." @api_client.config.logger.debug 'Calling API: UserApi.create_users_with_array_input ...'
end end
# verify the required parameter 'body' is set # verify the required parameter 'body' is set
if @api_client.config.client_side_validation && body.nil? if @api_client.config.client_side_validation && body.nil?
fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.create_users_with_array_input" fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.create_users_with_array_input"
end end
# resource path # resource path
local_var_path = "/user/createWithArray" local_var_path = '/user/createWithArray'
# query parameters # query parameters
query_params = {} query_params = {}
@ -123,7 +121,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Creates list of users with given input array # Creates list of users with given input array
# #
# @param body List of user object # @param body List of user object
@ -131,7 +128,7 @@ module Petstore
# @return [nil] # @return [nil]
def create_users_with_list_input(body, opts = {}) def create_users_with_list_input(body, opts = {})
create_users_with_list_input_with_http_info(body, opts) create_users_with_list_input_with_http_info(body, opts)
return nil nil
end end
# Creates list of users with given input array # Creates list of users with given input array
@ -141,14 +138,14 @@ module Petstore
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def create_users_with_list_input_with_http_info(body, opts = {}) def create_users_with_list_input_with_http_info(body, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: UserApi.create_users_with_list_input ..." @api_client.config.logger.debug 'Calling API: UserApi.create_users_with_list_input ...'
end end
# verify the required parameter 'body' is set # verify the required parameter 'body' is set
if @api_client.config.client_side_validation && body.nil? if @api_client.config.client_side_validation && body.nil?
fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.create_users_with_list_input" fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.create_users_with_list_input"
end end
# resource path # resource path
local_var_path = "/user/createWithList" local_var_path = '/user/createWithList'
# query parameters # query parameters
query_params = {} query_params = {}
@ -175,7 +172,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Delete user # Delete user
# This can only be done by the logged in user. # This can only be done by the logged in user.
# @param username The name that needs to be deleted # @param username The name that needs to be deleted
@ -183,7 +179,7 @@ module Petstore
# @return [nil] # @return [nil]
def delete_user(username, opts = {}) def delete_user(username, opts = {})
delete_user_with_http_info(username, opts) delete_user_with_http_info(username, opts)
return nil nil
end end
# Delete user # Delete user
@ -193,14 +189,14 @@ module Petstore
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_user_with_http_info(username, opts = {}) def delete_user_with_http_info(username, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: UserApi.delete_user ..." @api_client.config.logger.debug 'Calling API: UserApi.delete_user ...'
end end
# verify the required parameter 'username' is set # verify the required parameter 'username' is set
if @api_client.config.client_side_validation && username.nil? if @api_client.config.client_side_validation && username.nil?
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.delete_user" fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.delete_user"
end end
# resource path # resource path
local_var_path = "/user/{username}".sub('{' + 'username' + '}', username.to_s) local_var_path = '/user/{username}'.sub('{' + 'username' + '}', username.to_s)
# query parameters # query parameters
query_params = {} query_params = {}
@ -227,7 +223,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Get user by user name # Get user by user name
# #
# @param username The name that needs to be fetched. Use user1 for testing. # @param username The name that needs to be fetched. Use user1 for testing.
@ -235,7 +230,7 @@ module Petstore
# @return [User] # @return [User]
def get_user_by_name(username, opts = {}) def get_user_by_name(username, opts = {})
data, _status_code, _headers = get_user_by_name_with_http_info(username, opts) data, _status_code, _headers = get_user_by_name_with_http_info(username, opts)
return data data
end end
# Get user by user name # Get user by user name
@ -245,14 +240,14 @@ module Petstore
# @return [Array<(User, Fixnum, Hash)>] User data, response status code and response headers # @return [Array<(User, Fixnum, Hash)>] User data, response status code and response headers
def get_user_by_name_with_http_info(username, opts = {}) def get_user_by_name_with_http_info(username, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: UserApi.get_user_by_name ..." @api_client.config.logger.debug 'Calling API: UserApi.get_user_by_name ...'
end end
# verify the required parameter 'username' is set # verify the required parameter 'username' is set
if @api_client.config.client_side_validation && username.nil? if @api_client.config.client_side_validation && username.nil?
fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.get_user_by_name" fail ArgumentError, "Missing the required parameter 'username' when calling UserApi.get_user_by_name"
end end
# resource path # resource path
local_var_path = "/user/{username}".sub('{' + 'username' + '}', username.to_s) local_var_path = '/user/{username}'.sub('{' + 'username' + '}', username.to_s)
# query parameters # query parameters
query_params = {} query_params = {}
@ -280,7 +275,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Logs user into the system # Logs user into the system
# #
# @param username The user name for login # @param username The user name for login
@ -289,7 +283,7 @@ module Petstore
# @return [String] # @return [String]
def login_user(username, password, opts = {}) def login_user(username, password, opts = {})
data, _status_code, _headers = login_user_with_http_info(username, password, opts) data, _status_code, _headers = login_user_with_http_info(username, password, opts)
return data data
end end
# Logs user into the system # Logs user into the system
@ -300,7 +294,7 @@ module Petstore
# @return [Array<(String, Fixnum, Hash)>] String data, response status code and response headers # @return [Array<(String, Fixnum, Hash)>] String data, response status code and response headers
def login_user_with_http_info(username, password, opts = {}) def login_user_with_http_info(username, password, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: UserApi.login_user ..." @api_client.config.logger.debug 'Calling API: UserApi.login_user ...'
end end
# verify the required parameter 'username' is set # verify the required parameter 'username' is set
if @api_client.config.client_side_validation && username.nil? if @api_client.config.client_side_validation && username.nil?
@ -311,7 +305,7 @@ module Petstore
fail ArgumentError, "Missing the required parameter 'password' when calling UserApi.login_user" fail ArgumentError, "Missing the required parameter 'password' when calling UserApi.login_user"
end end
# resource path # resource path
local_var_path = "/user/login" local_var_path = '/user/login'
# query parameters # query parameters
query_params = {} query_params = {}
@ -341,14 +335,13 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Logs out current logged in user session # Logs out current logged in user session
# #
# @param [Hash] opts the optional parameters # @param [Hash] opts the optional parameters
# @return [nil] # @return [nil]
def logout_user(opts = {}) def logout_user(opts = {})
logout_user_with_http_info(opts) logout_user_with_http_info(opts)
return nil nil
end end
# Logs out current logged in user session # Logs out current logged in user session
@ -357,10 +350,10 @@ module Petstore
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def logout_user_with_http_info(opts = {}) def logout_user_with_http_info(opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: UserApi.logout_user ..." @api_client.config.logger.debug 'Calling API: UserApi.logout_user ...'
end end
# resource path # resource path
local_var_path = "/user/logout" local_var_path = '/user/logout'
# query parameters # query parameters
query_params = {} query_params = {}
@ -387,7 +380,6 @@ module Petstore
end end
return data, status_code, headers return data, status_code, headers
end end
# Updated user # Updated user
# This can only be done by the logged in user. # This can only be done by the logged in user.
# @param username name that need to be deleted # @param username name that need to be deleted
@ -396,7 +388,7 @@ module Petstore
# @return [nil] # @return [nil]
def update_user(username, body, opts = {}) def update_user(username, body, opts = {})
update_user_with_http_info(username, body, opts) update_user_with_http_info(username, body, opts)
return nil nil
end end
# Updated user # Updated user
@ -407,7 +399,7 @@ module Petstore
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def update_user_with_http_info(username, body, opts = {}) def update_user_with_http_info(username, body, opts = {})
if @api_client.config.debugging if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: UserApi.update_user ..." @api_client.config.logger.debug 'Calling API: UserApi.update_user ...'
end end
# verify the required parameter 'username' is set # verify the required parameter 'username' is set
if @api_client.config.client_side_validation && username.nil? if @api_client.config.client_side_validation && username.nil?
@ -418,7 +410,7 @@ module Petstore
fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.update_user" fail ArgumentError, "Missing the required parameter 'body' when calling UserApi.update_user"
end end
# resource path # resource path
local_var_path = "/user/{username}".sub('{' + 'username' + '}', username.to_s) local_var_path = '/user/{username}'.sub('{' + 'username' + '}', username.to_s)
# query parameters # query parameters
query_params = {} query_params = {}

View File

@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
@ -33,7 +33,7 @@ module Petstore
@config = config @config = config
@user_agent = "Swagger-Codegen/#{VERSION}/ruby" @user_agent = "Swagger-Codegen/#{VERSION}/ruby"
@default_headers = { @default_headers = {
'Content-Type' => "application/json", 'Content-Type' => 'application/json',
'User-Agent' => @user_agent 'User-Agent' => @user_agent
} }
end end
@ -137,7 +137,7 @@ module Petstore
# @param [String] mime MIME # @param [String] mime MIME
# @return [Boolean] True if the MIME is application/json # @return [Boolean] True if the MIME is application/json
def json_mime?(mime) def json_mime?(mime)
(mime == "*/*") || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil? (mime == '*/*') || !(mime =~ /Application\/.*json(?!p)(;.*)?/i).nil?
end end
# Deserialize the response to the given return type. # Deserialize the response to the given return type.
@ -201,12 +201,12 @@ module Petstore
when /\AArray<(.+)>\z/ when /\AArray<(.+)>\z/
# e.g. Array<Pet> # e.g. Array<Pet>
sub_type = $1 sub_type = $1
data.map {|item| convert_to_type(item, sub_type) } data.map { |item| convert_to_type(item, sub_type) }
when /\AHash\<String, (.+)\>\z/ when /\AHash\<String, (.+)\>\z/
# e.g. Hash<String, Integer> # e.g. Hash<String, Integer>
sub_type = $1 sub_type = $1
{}.tap do |hash| {}.tap do |hash|
data.each {|k, v| hash[k] = convert_to_type(v, sub_type) } data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
end end
else else
# models, e.g. Pet # models, e.g. Pet
@ -228,7 +228,7 @@ module Petstore
encoding = nil encoding = nil
request.on_headers do |response| request.on_headers do |response|
content_disposition = response.headers['Content-Disposition'] content_disposition = response.headers['Content-Disposition']
if content_disposition and content_disposition =~ /filename=/i if content_disposition && content_disposition =~ /filename=/i
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1] filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
prefix = sanitize_filename(filename) prefix = sanitize_filename(filename)
else else
@ -248,7 +248,7 @@ module Petstore
@config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
"with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
"will be deleted automatically with GC. It's also recommended to delete the temp file "\ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
"explicitly with `tempfile.delete`" 'explicitly with `tempfile.delete`'
end end
end end
@ -327,7 +327,7 @@ module Petstore
return nil if accepts.nil? || accepts.empty? return nil if accepts.nil? || accepts.empty?
# use JSON when present, otherwise use all of the provided # use JSON when present, otherwise use all of the provided
json_accept = accepts.find { |s| json_mime?(s) } json_accept = accepts.find { |s| json_mime?(s) }
return json_accept || accepts.join(',') json_accept || accepts.join(',')
end end
# Return Content-Type header based on an array of content types provided. # Return Content-Type header based on an array of content types provided.
@ -338,7 +338,7 @@ module Petstore
return 'application/json' if content_types.nil? || content_types.empty? return 'application/json' if content_types.nil? || content_types.empty?
# use JSON when present, otherwise use the first one # use JSON when present, otherwise use the first one
json_content_type = content_types.find { |s| json_mime?(s) } json_content_type = content_types.find { |s| json_mime?(s) }
return json_content_type || content_types.first json_content_type || content_types.first
end end
# Convert object (array, hash, object, etc) to JSON string. # Convert object (array, hash, object, etc) to JSON string.
@ -348,7 +348,7 @@ module Petstore
return model if model.nil? || model.is_a?(String) return model if model.nil? || model.is_a?(String)
local_body = nil local_body = nil
if model.is_a?(Array) if model.is_a?(Array)
local_body = model.map{|m| object_to_hash(m) } local_body = model.map { |m| object_to_hash(m) }
else else
local_body = object_to_hash(model) local_body = object_to_hash(model)
end end

View File

@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end

View File

@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
@ -170,7 +170,7 @@ module Petstore
def base_path=(base_path) def base_path=(base_path)
# Add leading and trailing slashes to base_path # Add leading and trailing slashes to base_path
@base_path = "/#{base_path}".gsub(/\/+/, '/') @base_path = "/#{base_path}".gsub(/\/+/, '/')
@base_path = "" if @base_path == "/" @base_path = '' if @base_path == '/'
end end
def base_url def base_url

View File

@ -6,20 +6,18 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class AdditionalPropertiesClass class AdditionalPropertiesClass
attr_accessor :map_property attr_accessor :map_property
attr_accessor :map_of_map_property attr_accessor :map_of_map_property
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -42,7 +40,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'map_property') if attributes.has_key?(:'map_property')
if (value = attributes[:'map_property']).is_a?(Hash) if (value = attributes[:'map_property']).is_a?(Hash)
@ -55,20 +53,19 @@ module Petstore
self.map_of_map_property = value self.map_of_map_property = value
end end
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -102,7 +99,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -184,7 +181,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -195,7 +192,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,20 +6,18 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class Animal class Animal
attr_accessor :class_name attr_accessor :class_name
attr_accessor :color attr_accessor :color
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -42,7 +40,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'className') if attributes.has_key?(:'className')
self.class_name = attributes[:'className'] self.class_name = attributes[:'className']
@ -51,9 +49,8 @@ module Petstore
if attributes.has_key?(:'color') if attributes.has_key?(:'color')
self.color = attributes[:'color'] self.color = attributes[:'color']
else else
self.color = "red" self.color = 'red'
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
@ -61,17 +58,17 @@ module Petstore
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
if @class_name.nil? if @class_name.nil?
invalid_properties.push("invalid value for 'class_name', class_name cannot be nil.") invalid_properties.push('invalid value for "class_name", class_name cannot be nil.')
end end
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return false if @class_name.nil? return false if @class_name.nil?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -105,7 +102,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -187,7 +184,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -198,7 +195,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,16 +6,14 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class AnimalFarm class AnimalFarm
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -34,21 +32,20 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -80,7 +77,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -162,7 +159,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -173,7 +170,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,14 +6,13 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class ApiResponse class ApiResponse
attr_accessor :code attr_accessor :code
@ -21,7 +20,6 @@ module Petstore
attr_accessor :message attr_accessor :message
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -46,7 +44,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'code') if attributes.has_key?(:'code')
self.code = attributes[:'code'] self.code = attributes[:'code']
@ -59,20 +57,19 @@ module Petstore
if attributes.has_key?(:'message') if attributes.has_key?(:'message')
self.message = attributes[:'message'] self.message = attributes[:'message']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -107,7 +104,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -189,7 +186,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -200,7 +197,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,18 +6,16 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class ArrayOfArrayOfNumberOnly class ArrayOfArrayOfNumberOnly
attr_accessor :array_array_number attr_accessor :array_array_number
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -38,27 +36,26 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'ArrayArrayNumber') if attributes.has_key?(:'ArrayArrayNumber')
if (value = attributes[:'ArrayArrayNumber']).is_a?(Array) if (value = attributes[:'ArrayArrayNumber']).is_a?(Array)
self.array_array_number = value self.array_array_number = value
end end
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -91,7 +88,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -173,7 +170,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -184,7 +181,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,18 +6,16 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class ArrayOfNumberOnly class ArrayOfNumberOnly
attr_accessor :array_number attr_accessor :array_number
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -38,27 +36,26 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'ArrayNumber') if attributes.has_key?(:'ArrayNumber')
if (value = attributes[:'ArrayNumber']).is_a?(Array) if (value = attributes[:'ArrayNumber']).is_a?(Array)
self.array_number = value self.array_number = value
end end
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -91,7 +88,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -173,7 +170,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -184,7 +181,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,14 +6,13 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class ArrayTest class ArrayTest
attr_accessor :array_of_string attr_accessor :array_of_string
@ -21,7 +20,6 @@ module Petstore
attr_accessor :array_array_of_model attr_accessor :array_array_of_model
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -46,7 +44,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'array_of_string') if attributes.has_key?(:'array_of_string')
if (value = attributes[:'array_of_string']).is_a?(Array) if (value = attributes[:'array_of_string']).is_a?(Array)
@ -65,20 +63,19 @@ module Petstore
self.array_array_of_model = value self.array_array_of_model = value
end end
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -113,7 +110,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -195,7 +192,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -206,7 +203,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,14 +6,13 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class Capitalization class Capitalization
attr_accessor :small_camel attr_accessor :small_camel
@ -28,7 +27,6 @@ module Petstore
# Name of the pet # Name of the pet
attr_accessor :att_name attr_accessor :att_name
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -59,7 +57,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'smallCamel') if attributes.has_key?(:'smallCamel')
self.small_camel = attributes[:'smallCamel'] self.small_camel = attributes[:'smallCamel']
@ -84,20 +82,19 @@ module Petstore
if attributes.has_key?(:'ATT_NAME') if attributes.has_key?(:'ATT_NAME')
self.att_name = attributes[:'ATT_NAME'] self.att_name = attributes[:'ATT_NAME']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -135,7 +132,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -217,7 +214,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -228,7 +225,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,14 +6,13 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class Cat class Cat
attr_accessor :class_name attr_accessor :class_name
@ -21,7 +20,6 @@ module Petstore
attr_accessor :declawed attr_accessor :declawed
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -46,7 +44,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'className') if attributes.has_key?(:'className')
self.class_name = attributes[:'className'] self.class_name = attributes[:'className']
@ -55,13 +53,12 @@ module Petstore
if attributes.has_key?(:'color') if attributes.has_key?(:'color')
self.color = attributes[:'color'] self.color = attributes[:'color']
else else
self.color = "red" self.color = 'red'
end end
if attributes.has_key?(:'declawed') if attributes.has_key?(:'declawed')
self.declawed = attributes[:'declawed'] self.declawed = attributes[:'declawed']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
@ -69,17 +66,17 @@ module Petstore
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
if @class_name.nil? if @class_name.nil?
invalid_properties.push("invalid value for 'class_name', class_name cannot be nil.") invalid_properties.push('invalid value for "class_name", class_name cannot be nil.')
end end
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return false if @class_name.nil? return false if @class_name.nil?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -114,7 +111,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -196,7 +193,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -207,7 +204,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,20 +6,18 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class Category class Category
attr_accessor :id attr_accessor :id
attr_accessor :name attr_accessor :name
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -42,7 +40,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'id') if attributes.has_key?(:'id')
self.id = attributes[:'id'] self.id = attributes[:'id']
@ -51,20 +49,19 @@ module Petstore
if attributes.has_key?(:'name') if attributes.has_key?(:'name')
self.name = attributes[:'name'] self.name = attributes[:'name']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -98,7 +95,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -180,7 +177,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -191,7 +188,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
@ -17,7 +17,6 @@ module Petstore
class ClassModel class ClassModel
attr_accessor :_class attr_accessor :_class
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -38,25 +37,24 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'_class') if attributes.has_key?(:'_class')
self._class = attributes[:'_class'] self._class = attributes[:'_class']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -89,7 +87,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -171,7 +169,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -182,7 +180,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,18 +6,16 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class Client class Client
attr_accessor :client attr_accessor :client
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -38,25 +36,24 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'client') if attributes.has_key?(:'client')
self.client = attributes[:'client'] self.client = attributes[:'client']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -89,7 +86,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -171,7 +168,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -182,7 +179,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,14 +6,13 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class Dog class Dog
attr_accessor :class_name attr_accessor :class_name
@ -21,7 +20,6 @@ module Petstore
attr_accessor :breed attr_accessor :breed
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -46,7 +44,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'className') if attributes.has_key?(:'className')
self.class_name = attributes[:'className'] self.class_name = attributes[:'className']
@ -55,13 +53,12 @@ module Petstore
if attributes.has_key?(:'color') if attributes.has_key?(:'color')
self.color = attributes[:'color'] self.color = attributes[:'color']
else else
self.color = "red" self.color = 'red'
end end
if attributes.has_key?(:'breed') if attributes.has_key?(:'breed')
self.breed = attributes[:'breed'] self.breed = attributes[:'breed']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
@ -69,17 +66,17 @@ module Petstore
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
if @class_name.nil? if @class_name.nil?
invalid_properties.push("invalid value for 'class_name', class_name cannot be nil.") invalid_properties.push('invalid value for "class_name", class_name cannot be nil.')
end end
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return false if @class_name.nil? return false if @class_name.nil?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -114,7 +111,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -196,7 +193,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -207,7 +204,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,14 +6,13 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class EnumArrays class EnumArrays
attr_accessor :just_symbol attr_accessor :just_symbol
@ -63,7 +62,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'just_symbol') if attributes.has_key?(:'just_symbol')
self.just_symbol = attributes[:'just_symbol'] self.just_symbol = attributes[:'just_symbol']
@ -74,30 +73,29 @@ module Petstore
self.array_enum = value self.array_enum = value
end end
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
just_symbol_validator = EnumAttributeValidator.new('String', [">=", "$"]) just_symbol_validator = EnumAttributeValidator.new('String', ['>=', '$'])
return false unless just_symbol_validator.valid?(@just_symbol) return false unless just_symbol_validator.valid?(@just_symbol)
return true true
end end
# Custom attribute writer method checking allowed values (enum). # Custom attribute writer method checking allowed values (enum).
# @param [Object] just_symbol Object to be assigned # @param [Object] just_symbol Object to be assigned
def just_symbol=(just_symbol) def just_symbol=(just_symbol)
validator = EnumAttributeValidator.new('String', [">=", "$"]) validator = EnumAttributeValidator.new('String', ['>=', '$'])
unless validator.valid?(just_symbol) unless validator.valid?(just_symbol)
fail ArgumentError, "invalid value for 'just_symbol', must be one of #{validator.allowable_values}." fail ArgumentError, 'invalid value for "just_symbol", must be one of #{validator.allowable_values}.'
end end
@just_symbol = just_symbol @just_symbol = just_symbol
end end
@ -133,7 +131,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -215,7 +213,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -226,7 +224,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
@ -15,18 +15,17 @@ require 'date'
module Petstore module Petstore
class EnumClass class EnumClass
ABC = "_abc".freeze ABC = '_abc'.freeze
EFG = "-efg".freeze EFG = '-efg'.freeze
XYZ = "(xyz)".freeze XYZ = '(xyz)'.freeze
# Builds the enum from string # Builds the enum from string
# @param [String] The enum value in the form of the string # @param [String] The enum value in the form of the string
# @return [String] The enum value # @return [String] The enum value
def build_from_hash(value) def build_from_hash(value)
constantValues = EnumClass.constants.select{|c| EnumClass::const_get(c) == value} constantValues = EnumClass.constants.select { |c| EnumClass::const_get(c) == value }
raise "Invalid ENUM value #{value} for class #EnumClass" if constantValues.empty? raise "Invalid ENUM value #{value} for class #EnumClass" if constantValues.empty?
value value
end end
end end
end end

View File

@ -6,14 +6,13 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class EnumTest class EnumTest
attr_accessor :enum_string attr_accessor :enum_string
@ -71,7 +70,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'enum_string') if attributes.has_key?(:'enum_string')
self.enum_string = attributes[:'enum_string'] self.enum_string = attributes[:'enum_string']
@ -88,34 +87,33 @@ module Petstore
if attributes.has_key?(:'outerEnum') if attributes.has_key?(:'outerEnum')
self.outer_enum = attributes[:'outerEnum'] self.outer_enum = attributes[:'outerEnum']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
enum_string_validator = EnumAttributeValidator.new('String', ["UPPER", "lower", ""]) enum_string_validator = EnumAttributeValidator.new('String', ['UPPER', 'lower', ''])
return false unless enum_string_validator.valid?(@enum_string) return false unless enum_string_validator.valid?(@enum_string)
enum_integer_validator = EnumAttributeValidator.new('Integer', ["1", "-1"]) enum_integer_validator = EnumAttributeValidator.new('Integer', ['1', '-1'])
return false unless enum_integer_validator.valid?(@enum_integer) return false unless enum_integer_validator.valid?(@enum_integer)
enum_number_validator = EnumAttributeValidator.new('Float', ["1.1", "-1.2"]) enum_number_validator = EnumAttributeValidator.new('Float', ['1.1', '-1.2'])
return false unless enum_number_validator.valid?(@enum_number) return false unless enum_number_validator.valid?(@enum_number)
return true true
end end
# Custom attribute writer method checking allowed values (enum). # Custom attribute writer method checking allowed values (enum).
# @param [Object] enum_string Object to be assigned # @param [Object] enum_string Object to be assigned
def enum_string=(enum_string) def enum_string=(enum_string)
validator = EnumAttributeValidator.new('String', ["UPPER", "lower", ""]) validator = EnumAttributeValidator.new('String', ['UPPER', 'lower', ''])
unless validator.valid?(enum_string) unless validator.valid?(enum_string)
fail ArgumentError, "invalid value for 'enum_string', must be one of #{validator.allowable_values}." fail ArgumentError, 'invalid value for "enum_string", must be one of #{validator.allowable_values}.'
end end
@enum_string = enum_string @enum_string = enum_string
end end
@ -123,9 +121,9 @@ module Petstore
# Custom attribute writer method checking allowed values (enum). # Custom attribute writer method checking allowed values (enum).
# @param [Object] enum_integer Object to be assigned # @param [Object] enum_integer Object to be assigned
def enum_integer=(enum_integer) def enum_integer=(enum_integer)
validator = EnumAttributeValidator.new('Integer', ["1", "-1"]) validator = EnumAttributeValidator.new('Integer', ['1', '-1'])
unless validator.valid?(enum_integer) unless validator.valid?(enum_integer)
fail ArgumentError, "invalid value for 'enum_integer', must be one of #{validator.allowable_values}." fail ArgumentError, 'invalid value for "enum_integer", must be one of #{validator.allowable_values}.'
end end
@enum_integer = enum_integer @enum_integer = enum_integer
end end
@ -133,9 +131,9 @@ module Petstore
# Custom attribute writer method checking allowed values (enum). # Custom attribute writer method checking allowed values (enum).
# @param [Object] enum_number Object to be assigned # @param [Object] enum_number Object to be assigned
def enum_number=(enum_number) def enum_number=(enum_number)
validator = EnumAttributeValidator.new('Float', ["1.1", "-1.2"]) validator = EnumAttributeValidator.new('Float', ['1.1', '-1.2'])
unless validator.valid?(enum_number) unless validator.valid?(enum_number)
fail ArgumentError, "invalid value for 'enum_number', must be one of #{validator.allowable_values}." fail ArgumentError, 'invalid value for "enum_number", must be one of #{validator.allowable_values}.'
end end
@enum_number = enum_number @enum_number = enum_number
end end
@ -173,7 +171,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -255,7 +253,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -266,7 +264,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,14 +6,13 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class FormatTest class FormatTest
attr_accessor :integer attr_accessor :integer
@ -41,7 +40,6 @@ module Petstore
attr_accessor :password attr_accessor :password
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -86,7 +84,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'integer') if attributes.has_key?(:'integer')
self.integer = attributes[:'integer'] self.integer = attributes[:'integer']
@ -139,7 +137,6 @@ module Petstore
if attributes.has_key?(:'password') if attributes.has_key?(:'password')
self.password = attributes[:'password'] self.password = attributes[:'password']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
@ -147,78 +144,78 @@ module Petstore
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
if !@integer.nil? && @integer > 100 if !@integer.nil? && @integer > 100
invalid_properties.push("invalid value for 'integer', must be smaller than or equal to 100.") invalid_properties.push('invalid value for "integer", must be smaller than or equal to 100.')
end end
if !@integer.nil? && @integer < 10 if !@integer.nil? && @integer < 10
invalid_properties.push("invalid value for 'integer', must be greater than or equal to 10.") invalid_properties.push('invalid value for "integer", must be greater than or equal to 10.')
end end
if !@int32.nil? && @int32 > 200 if !@int32.nil? && @int32 > 200
invalid_properties.push("invalid value for 'int32', must be smaller than or equal to 200.") invalid_properties.push('invalid value for "int32", must be smaller than or equal to 200.')
end end
if !@int32.nil? && @int32 < 20 if !@int32.nil? && @int32 < 20
invalid_properties.push("invalid value for 'int32', must be greater than or equal to 20.") invalid_properties.push('invalid value for "int32", must be greater than or equal to 20.')
end end
if @number.nil? if @number.nil?
invalid_properties.push("invalid value for 'number', number cannot be nil.") invalid_properties.push('invalid value for "number", number cannot be nil.')
end end
if @number > 543.2 if @number > 543.2
invalid_properties.push("invalid value for 'number', must be smaller than or equal to 543.2.") invalid_properties.push('invalid value for "number", must be smaller than or equal to 543.2.')
end end
if @number < 32.1 if @number < 32.1
invalid_properties.push("invalid value for 'number', must be greater than or equal to 32.1.") invalid_properties.push('invalid value for "number", must be greater than or equal to 32.1.')
end end
if !@float.nil? && @float > 987.6 if !@float.nil? && @float > 987.6
invalid_properties.push("invalid value for 'float', must be smaller than or equal to 987.6.") invalid_properties.push('invalid value for "float", must be smaller than or equal to 987.6.')
end end
if !@float.nil? && @float < 54.3 if !@float.nil? && @float < 54.3
invalid_properties.push("invalid value for 'float', must be greater than or equal to 54.3.") invalid_properties.push('invalid value for "float", must be greater than or equal to 54.3.')
end end
if !@double.nil? && @double > 123.4 if !@double.nil? && @double > 123.4
invalid_properties.push("invalid value for 'double', must be smaller than or equal to 123.4.") invalid_properties.push('invalid value for "double", must be smaller than or equal to 123.4.')
end end
if !@double.nil? && @double < 67.8 if !@double.nil? && @double < 67.8
invalid_properties.push("invalid value for 'double', must be greater than or equal to 67.8.") invalid_properties.push('invalid value for "double", must be greater than or equal to 67.8.')
end end
if !@string.nil? && @string !~ Regexp.new(/[a-z]/i) if !@string.nil? && @string !~ Regexp.new(/[a-z]/i)
invalid_properties.push("invalid value for 'string', must conform to the pattern /[a-z]/i.") invalid_properties.push('invalid value for "string", must conform to the pattern /[a-z]/i.')
end end
if @byte.nil? if @byte.nil?
invalid_properties.push("invalid value for 'byte', byte cannot be nil.") invalid_properties.push('invalid value for "byte", byte cannot be nil.')
end end
if @byte !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/) if @byte !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
invalid_properties.push("invalid value for 'byte', must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.") invalid_properties.push('invalid value for "byte", must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.')
end end
if @date.nil? if @date.nil?
invalid_properties.push("invalid value for 'date', date cannot be nil.") invalid_properties.push('invalid value for "date", date cannot be nil.')
end end
if @password.nil? if @password.nil?
invalid_properties.push("invalid value for 'password', password cannot be nil.") invalid_properties.push('invalid value for "password", password cannot be nil.')
end end
if @password.to_s.length > 64 if @password.to_s.length > 64
invalid_properties.push("invalid value for 'password', the character length must be smaller than or equal to 64.") invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 64.')
end end
if @password.to_s.length < 10 if @password.to_s.length < 10
invalid_properties.push("invalid value for 'password', the character length must be great than or equal to 10.") invalid_properties.push('invalid value for "password", the character length must be great than or equal to 10.')
end end
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
@ -242,19 +239,18 @@ module Petstore
return false if @password.nil? return false if @password.nil?
return false if @password.to_s.length > 64 return false if @password.to_s.length > 64
return false if @password.to_s.length < 10 return false if @password.to_s.length < 10
return true true
end end
# Custom attribute writer method with validation # Custom attribute writer method with validation
# @param [Object] integer Value to be assigned # @param [Object] integer Value to be assigned
def integer=(integer) def integer=(integer)
if !integer.nil? && integer > 100 if !integer.nil? && integer > 100
fail ArgumentError, "invalid value for 'integer', must be smaller than or equal to 100." fail ArgumentError, 'invalid value for "integer", must be smaller than or equal to 100.'
end end
if !integer.nil? && integer < 10 if !integer.nil? && integer < 10
fail ArgumentError, "invalid value for 'integer', must be greater than or equal to 10." fail ArgumentError, 'invalid value for "integer", must be greater than or equal to 10.'
end end
@integer = integer @integer = integer
@ -263,13 +259,12 @@ module Petstore
# Custom attribute writer method with validation # Custom attribute writer method with validation
# @param [Object] int32 Value to be assigned # @param [Object] int32 Value to be assigned
def int32=(int32) def int32=(int32)
if !int32.nil? && int32 > 200 if !int32.nil? && int32 > 200
fail ArgumentError, "invalid value for 'int32', must be smaller than or equal to 200." fail ArgumentError, 'invalid value for "int32", must be smaller than or equal to 200.'
end end
if !int32.nil? && int32 < 20 if !int32.nil? && int32 < 20
fail ArgumentError, "invalid value for 'int32', must be greater than or equal to 20." fail ArgumentError, 'invalid value for "int32", must be greater than or equal to 20.'
end end
@int32 = int32 @int32 = int32
@ -279,15 +274,15 @@ module Petstore
# @param [Object] number Value to be assigned # @param [Object] number Value to be assigned
def number=(number) def number=(number)
if number.nil? if number.nil?
fail ArgumentError, "number cannot be nil" fail ArgumentError, 'number cannot be nil'
end end
if number > 543.2 if number > 543.2
fail ArgumentError, "invalid value for 'number', must be smaller than or equal to 543.2." fail ArgumentError, 'invalid value for "number", must be smaller than or equal to 543.2.'
end end
if number < 32.1 if number < 32.1
fail ArgumentError, "invalid value for 'number', must be greater than or equal to 32.1." fail ArgumentError, 'invalid value for "number", must be greater than or equal to 32.1.'
end end
@number = number @number = number
@ -296,13 +291,12 @@ module Petstore
# Custom attribute writer method with validation # Custom attribute writer method with validation
# @param [Object] float Value to be assigned # @param [Object] float Value to be assigned
def float=(float) def float=(float)
if !float.nil? && float > 987.6 if !float.nil? && float > 987.6
fail ArgumentError, "invalid value for 'float', must be smaller than or equal to 987.6." fail ArgumentError, 'invalid value for "float", must be smaller than or equal to 987.6.'
end end
if !float.nil? && float < 54.3 if !float.nil? && float < 54.3
fail ArgumentError, "invalid value for 'float', must be greater than or equal to 54.3." fail ArgumentError, 'invalid value for "float", must be greater than or equal to 54.3.'
end end
@float = float @float = float
@ -311,13 +305,12 @@ module Petstore
# Custom attribute writer method with validation # Custom attribute writer method with validation
# @param [Object] double Value to be assigned # @param [Object] double Value to be assigned
def double=(double) def double=(double)
if !double.nil? && double > 123.4 if !double.nil? && double > 123.4
fail ArgumentError, "invalid value for 'double', must be smaller than or equal to 123.4." fail ArgumentError, 'invalid value for "double", must be smaller than or equal to 123.4.'
end end
if !double.nil? && double < 67.8 if !double.nil? && double < 67.8
fail ArgumentError, "invalid value for 'double', must be greater than or equal to 67.8." fail ArgumentError, 'invalid value for "double", must be greater than or equal to 67.8.'
end end
@double = double @double = double
@ -326,9 +319,8 @@ module Petstore
# Custom attribute writer method with validation # Custom attribute writer method with validation
# @param [Object] string Value to be assigned # @param [Object] string Value to be assigned
def string=(string) def string=(string)
if !string.nil? && string !~ Regexp.new(/[a-z]/i) if !string.nil? && string !~ Regexp.new(/[a-z]/i)
fail ArgumentError, "invalid value for 'string', must conform to the pattern /[a-z]/i." fail ArgumentError, 'invalid value for "string", must conform to the pattern /[a-z]/i.'
end end
@string = string @string = string
@ -338,11 +330,11 @@ module Petstore
# @param [Object] byte Value to be assigned # @param [Object] byte Value to be assigned
def byte=(byte) def byte=(byte)
if byte.nil? if byte.nil?
fail ArgumentError, "byte cannot be nil" fail ArgumentError, 'byte cannot be nil'
end end
if byte !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/) if byte !~ Regexp.new(/^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/)
fail ArgumentError, "invalid value for 'byte', must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/." fail ArgumentError, 'invalid value for "byte", must conform to the pattern /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.'
end end
@byte = byte @byte = byte
@ -352,15 +344,15 @@ module Petstore
# @param [Object] password Value to be assigned # @param [Object] password Value to be assigned
def password=(password) def password=(password)
if password.nil? if password.nil?
fail ArgumentError, "password cannot be nil" fail ArgumentError, 'password cannot be nil'
end end
if password.to_s.length > 64 if password.to_s.length > 64
fail ArgumentError, "invalid value for 'password', the character length must be smaller than or equal to 64." fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 64.'
end end
if password.to_s.length < 10 if password.to_s.length < 10
fail ArgumentError, "invalid value for 'password', the character length must be great than or equal to 10." fail ArgumentError, 'invalid value for "password", the character length must be great than or equal to 10.'
end end
@password = password @password = password
@ -408,7 +400,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -490,7 +482,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -501,7 +493,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,20 +6,18 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class HasOnlyReadOnly class HasOnlyReadOnly
attr_accessor :bar attr_accessor :bar
attr_accessor :foo attr_accessor :foo
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -42,7 +40,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'bar') if attributes.has_key?(:'bar')
self.bar = attributes[:'bar'] self.bar = attributes[:'bar']
@ -51,20 +49,19 @@ module Petstore
if attributes.has_key?(:'foo') if attributes.has_key?(:'foo')
self.foo = attributes[:'foo'] self.foo = attributes[:'foo']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -98,7 +95,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -180,7 +177,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -191,7 +188,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -1,230 +0,0 @@
=begin
Swagger Petstore
This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
License: Apache 2.0
http://www.apache.org/licenses/LICENSE-2.0.html
Terms of Service: http://swagger.io/terms/
=end
require 'date'
module Petstore
class InlineResponse200
attr_accessor :tags
attr_accessor :id
attr_accessor :category
# pet status in the store
attr_accessor :status
attr_accessor :name
attr_accessor :photo_urls
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'tags' => :'tags',
:'id' => :'id',
:'category' => :'category',
:'status' => :'status',
:'name' => :'name',
:'photo_urls' => :'photoUrls'
}
end
# Attribute type mapping.
def self.swagger_types
{
:'tags' => :'Array<Tag>',
:'id' => :'Integer',
:'category' => :'Object',
:'status' => :'String',
:'name' => :'String',
:'photo_urls' => :'Array<String>'
}
end
# Initializes the object
# @param [Hash] attributes Model attributes in the form of hash
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
# convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}
if attributes[:'tags']
if (value = attributes[:'tags']).is_a?(Array)
self.tags = value
end
end
if attributes[:'id']
self.id = attributes[:'id']
end
if attributes[:'category']
self.category = attributes[:'category']
end
if attributes[:'status']
self.status = attributes[:'status']
end
if attributes[:'name']
self.name = attributes[:'name']
end
if attributes[:'photoUrls']
if (value = attributes[:'photoUrls']).is_a?(Array)
self.photo_urls = value
end
end
end
# Custom attribute writer method checking allowed values (enum).
# @param [Object] status Object to be assigned
def status=(status)
allowed_values = ["available", "pending", "sold"]
if status && !allowed_values.include?(status)
fail "invalid value for 'status', must be one of #{allowed_values}"
end
@status = status
end
# Checks equality by comparing each attribute.
# @param [Object] Object to be compared
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
tags == o.tags &&
id == o.id &&
category == o.category &&
status == o.status &&
name == o.name &&
photo_urls == o.photo_urls
end
# @see the `==` method
# @param [Object] Object to be compared
def eql?(o)
self == o
end
# Calculates hash code according to all attributes.
# @return [Fixnum] Hash code
def hash
[tags, id, category, status, name, photo_urls].hash
end
# Builds the object from hash
# @param [Hash] attributes Model attributes in the form of hash
# @return [Object] Returns the model itself
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.swagger_types.each_pair do |key, type|
if type =~ /^Array<(.*)>/i
# check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
end # or else data not found in attributes(hash), not an issue as the data can be optional
end
self
end
# Deserializes the data based on type
# @param string type Data type
# @param string value Value to be deserialized
# @return [Object] Deserialized data
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :BOOLEAN
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
temp_model = Petstore.const_get(type).new
temp_model.build_from_hash(value)
end
end
# Returns the string representation of the object
# @return [String] String presentation of the object
def to_s
to_hash.to_s
end
# to_body is an alias to to_hash (backward compatibility)
# @return [Hash] Returns the object in the form of hash
def to_body
to_hash
end
# Returns the object in the form of hash
# @return [Hash] Returns the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end
# Outputs non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
# @param [Object] value Any valid value
# @return [Hash] Returns the value in the form of hash
def _to_hash(value)
if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end

View File

@ -6,18 +6,16 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class List class List
attr_accessor :_123_list attr_accessor :_123_list
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -38,25 +36,24 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'123-list') if attributes.has_key?(:'123-list')
self._123_list = attributes[:'123-list'] self._123_list = attributes[:'123-list']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -89,7 +86,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -171,7 +168,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -182,7 +179,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,14 +6,13 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class MapTest class MapTest
attr_accessor :map_map_of_string attr_accessor :map_map_of_string
@ -63,7 +62,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'map_map_of_string') if attributes.has_key?(:'map_map_of_string')
if (value = attributes[:'map_map_of_string']).is_a?(Hash) if (value = attributes[:'map_map_of_string']).is_a?(Hash)
@ -76,20 +75,19 @@ module Petstore
self.map_of_enum_string = value self.map_of_enum_string = value
end end
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -123,7 +121,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -205,7 +203,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -216,7 +214,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,14 +6,13 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class MixedPropertiesAndAdditionalPropertiesClass class MixedPropertiesAndAdditionalPropertiesClass
attr_accessor :uuid attr_accessor :uuid
@ -21,7 +20,6 @@ module Petstore
attr_accessor :map attr_accessor :map
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -46,7 +44,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'uuid') if attributes.has_key?(:'uuid')
self.uuid = attributes[:'uuid'] self.uuid = attributes[:'uuid']
@ -61,20 +59,19 @@ module Petstore
self.map = value self.map = value
end end
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -109,7 +106,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -191,7 +188,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -202,7 +199,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
@ -19,7 +19,6 @@ module Petstore
attr_accessor :_class attr_accessor :_class
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -42,7 +41,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'name') if attributes.has_key?(:'name')
self.name = attributes[:'name'] self.name = attributes[:'name']
@ -51,20 +50,19 @@ module Petstore
if attributes.has_key?(:'class') if attributes.has_key?(:'class')
self._class = attributes[:'class'] self._class = attributes[:'class']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -98,7 +96,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -180,7 +178,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -191,7 +189,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
@ -17,7 +17,6 @@ module Petstore
class ModelReturn class ModelReturn
attr_accessor :_return attr_accessor :_return
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -38,25 +37,24 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'return') if attributes.has_key?(:'return')
self._return = attributes[:'return'] self._return = attributes[:'return']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -89,7 +87,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -171,7 +169,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -182,7 +180,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
@ -23,7 +23,6 @@ module Petstore
attr_accessor :_123_number attr_accessor :_123_number
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -50,7 +49,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'name') if attributes.has_key?(:'name')
self.name = attributes[:'name'] self.name = attributes[:'name']
@ -67,7 +66,6 @@ module Petstore
if attributes.has_key?(:'123Number') if attributes.has_key?(:'123Number')
self._123_number = attributes[:'123Number'] self._123_number = attributes[:'123Number']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
@ -75,17 +73,17 @@ module Petstore
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
if @name.nil? if @name.nil?
invalid_properties.push("invalid value for 'name', name cannot be nil.") invalid_properties.push('invalid value for "name", name cannot be nil.')
end end
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return false if @name.nil? return false if @name.nil?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -121,7 +119,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -203,7 +201,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -214,7 +212,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,18 +6,16 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class NumberOnly class NumberOnly
attr_accessor :just_number attr_accessor :just_number
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -38,25 +36,24 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'JustNumber') if attributes.has_key?(:'JustNumber')
self.just_number = attributes[:'JustNumber'] self.just_number = attributes[:'JustNumber']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -89,7 +86,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -171,7 +168,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -182,7 +179,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,14 +6,13 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class Order class Order
attr_accessor :id attr_accessor :id
@ -80,7 +79,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'id') if attributes.has_key?(:'id')
self.id = attributes[:'id'] self.id = attributes[:'id']
@ -107,30 +106,29 @@ module Petstore
else else
self.complete = false self.complete = false
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
status_validator = EnumAttributeValidator.new('String', ["placed", "approved", "delivered"]) status_validator = EnumAttributeValidator.new('String', ['placed', 'approved', 'delivered'])
return false unless status_validator.valid?(@status) return false unless status_validator.valid?(@status)
return true true
end end
# Custom attribute writer method checking allowed values (enum). # Custom attribute writer method checking allowed values (enum).
# @param [Object] status Object to be assigned # @param [Object] status Object to be assigned
def status=(status) def status=(status)
validator = EnumAttributeValidator.new('String', ["placed", "approved", "delivered"]) validator = EnumAttributeValidator.new('String', ['placed', 'approved', 'delivered'])
unless validator.valid?(status) unless validator.valid?(status)
fail ArgumentError, "invalid value for 'status', must be one of #{validator.allowable_values}." fail ArgumentError, 'invalid value for "status", must be one of #{validator.allowable_values}.'
end end
@status = status @status = status
end end
@ -170,7 +168,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -252,7 +250,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -263,7 +261,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,16 +6,14 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class OuterBoolean class OuterBoolean
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -34,21 +32,20 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -80,7 +77,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -162,7 +159,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -173,7 +170,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,14 +6,13 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class OuterComposite class OuterComposite
attr_accessor :my_number attr_accessor :my_number
@ -21,7 +20,6 @@ module Petstore
attr_accessor :my_boolean attr_accessor :my_boolean
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -46,7 +44,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'my_number') if attributes.has_key?(:'my_number')
self.my_number = attributes[:'my_number'] self.my_number = attributes[:'my_number']
@ -59,20 +57,19 @@ module Petstore
if attributes.has_key?(:'my_boolean') if attributes.has_key?(:'my_boolean')
self.my_boolean = attributes[:'my_boolean'] self.my_boolean = attributes[:'my_boolean']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -107,7 +104,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -189,7 +186,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -200,7 +197,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,7 +6,7 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
@ -15,18 +15,17 @@ require 'date'
module Petstore module Petstore
class OuterEnum class OuterEnum
PLACED = "placed".freeze PLACED = 'placed'.freeze
APPROVED = "approved".freeze APPROVED = 'approved'.freeze
DELIVERED = "delivered".freeze DELIVERED = 'delivered'.freeze
# Builds the enum from string # Builds the enum from string
# @param [String] The enum value in the form of the string # @param [String] The enum value in the form of the string
# @return [String] The enum value # @return [String] The enum value
def build_from_hash(value) def build_from_hash(value)
constantValues = OuterEnum.constants.select{|c| OuterEnum::const_get(c) == value} constantValues = OuterEnum.constants.select { |c| OuterEnum::const_get(c) == value }
raise "Invalid ENUM value #{value} for class #OuterEnum" if constantValues.empty? raise "Invalid ENUM value #{value} for class #OuterEnum" if constantValues.empty?
value value
end end
end end
end end

View File

@ -6,16 +6,14 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class OuterNumber class OuterNumber
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -34,21 +32,20 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -80,7 +77,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -162,7 +159,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -173,7 +170,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,16 +6,14 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class OuterString class OuterString
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -34,21 +32,20 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -80,7 +77,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -162,7 +159,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -173,7 +170,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,14 +6,13 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class Pet class Pet
attr_accessor :id attr_accessor :id
@ -80,7 +79,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'id') if attributes.has_key?(:'id')
self.id = attributes[:'id'] self.id = attributes[:'id']
@ -109,7 +108,6 @@ module Petstore
if attributes.has_key?(:'status') if attributes.has_key?(:'status')
self.status = attributes[:'status'] self.status = attributes[:'status']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
@ -117,14 +115,14 @@ module Petstore
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
if @name.nil? if @name.nil?
invalid_properties.push("invalid value for 'name', name cannot be nil.") invalid_properties.push('invalid value for "name", name cannot be nil.')
end end
if @photo_urls.nil? if @photo_urls.nil?
invalid_properties.push("invalid value for 'photo_urls', photo_urls cannot be nil.") invalid_properties.push('invalid value for "photo_urls", photo_urls cannot be nil.')
end end
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
@ -132,17 +130,17 @@ module Petstore
def valid? def valid?
return false if @name.nil? return false if @name.nil?
return false if @photo_urls.nil? return false if @photo_urls.nil?
status_validator = EnumAttributeValidator.new('String', ["available", "pending", "sold"]) status_validator = EnumAttributeValidator.new('String', ['available', 'pending', 'sold'])
return false unless status_validator.valid?(@status) return false unless status_validator.valid?(@status)
return true true
end end
# Custom attribute writer method checking allowed values (enum). # Custom attribute writer method checking allowed values (enum).
# @param [Object] status Object to be assigned # @param [Object] status Object to be assigned
def status=(status) def status=(status)
validator = EnumAttributeValidator.new('String', ["available", "pending", "sold"]) validator = EnumAttributeValidator.new('String', ['available', 'pending', 'sold'])
unless validator.valid?(status) unless validator.valid?(status)
fail ArgumentError, "invalid value for 'status', must be one of #{validator.allowable_values}." fail ArgumentError, 'invalid value for "status", must be one of #{validator.allowable_values}.'
end end
@status = status @status = status
end end
@ -182,7 +180,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -264,7 +262,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -275,7 +273,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,20 +6,18 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class ReadOnlyFirst class ReadOnlyFirst
attr_accessor :bar attr_accessor :bar
attr_accessor :baz attr_accessor :baz
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -42,7 +40,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'bar') if attributes.has_key?(:'bar')
self.bar = attributes[:'bar'] self.bar = attributes[:'bar']
@ -51,20 +49,19 @@ module Petstore
if attributes.has_key?(:'baz') if attributes.has_key?(:'baz')
self.baz = attributes[:'baz'] self.baz = attributes[:'baz']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -98,7 +95,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -180,7 +177,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -191,7 +188,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,18 +6,16 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class SpecialModelName class SpecialModelName
attr_accessor :special_property_name attr_accessor :special_property_name
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -38,25 +36,24 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'$special[property.name]') if attributes.has_key?(:'$special[property.name]')
self.special_property_name = attributes[:'$special[property.name]'] self.special_property_name = attributes[:'$special[property.name]']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -89,7 +86,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -171,7 +168,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -182,7 +179,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,20 +6,18 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class Tag class Tag
attr_accessor :id attr_accessor :id
attr_accessor :name attr_accessor :name
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -42,7 +40,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'id') if attributes.has_key?(:'id')
self.id = attributes[:'id'] self.id = attributes[:'id']
@ -51,20 +49,19 @@ module Petstore
if attributes.has_key?(:'name') if attributes.has_key?(:'name')
self.name = attributes[:'name'] self.name = attributes[:'name']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -98,7 +95,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -180,7 +177,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -191,7 +188,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,14 +6,13 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
require 'date' require 'date'
module Petstore module Petstore
class User class User
attr_accessor :id attr_accessor :id
@ -32,7 +31,6 @@ module Petstore
# User Status # User Status
attr_accessor :user_status attr_accessor :user_status
# Attribute mapping from ruby-style variable name to JSON key. # Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map def self.attribute_map
{ {
@ -67,7 +65,7 @@ module Petstore
return unless attributes.is_a?(Hash) return unless attributes.is_a?(Hash)
# convert string to symbol for hash key # convert string to symbol for hash key
attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v} attributes = attributes.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }
if attributes.has_key?(:'id') if attributes.has_key?(:'id')
self.id = attributes[:'id'] self.id = attributes[:'id']
@ -100,20 +98,19 @@ module Petstore
if attributes.has_key?(:'userStatus') if attributes.has_key?(:'userStatus')
self.user_status = attributes[:'userStatus'] self.user_status = attributes[:'userStatus']
end end
end end
# Show invalid properties with the reasons. Usually used together with valid? # Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons # @return Array for valid properties with the reasons
def list_invalid_properties def list_invalid_properties
invalid_properties = Array.new invalid_properties = Array.new
return invalid_properties invalid_properties
end end
# Check to see if the all the properties in the model are valid # Check to see if the all the properties in the model are valid
# @return true if the model is valid # @return true if the model is valid
def valid? def valid?
return true true
end end
# Checks equality by comparing each attribute. # Checks equality by comparing each attribute.
@ -153,7 +150,7 @@ module Petstore
# check to ensure the input is an array given that the the attribute # check to ensure the input is an array given that the the attribute
# is documented as an array but the input is not # is documented as an array but the input is not
if attributes[self.class.attribute_map[key]].is_a?(Array) if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } ) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
end end
elsif !attributes[self.class.attribute_map[key]].nil? elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
@ -235,7 +232,7 @@ module Petstore
# @return [Hash] Returns the value in the form of hash # @return [Hash] Returns the value in the form of hash
def _to_hash(value) def _to_hash(value)
if value.is_a?(Array) if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) } value.compact.map { |v| _to_hash(v) }
elsif value.is_a?(Hash) elsif value.is_a?(Hash)
{}.tap do |hash| {}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) } value.each { |k, v| hash[k] = _to_hash(v) }
@ -246,7 +243,5 @@ module Petstore
value value
end end
end end
end end
end end

View File

@ -6,10 +6,10 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end
module Petstore module Petstore
VERSION = "1.0.0" VERSION = '1.0.0'
end end

View File

@ -8,7 +8,7 @@
OpenAPI spec version: 1.0.0 OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.3.0-SNAPSHOT Swagger Codegen version: 2.4.0-SNAPSHOT
=end =end