forked from loafle/openapi-generator-original
Merge pull request #545 from wing328/ruby_better_naming
Update ruby codgen for better naming convention
This commit is contained in:
commit
16403950d5
@ -39,7 +39,11 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
|
|
||||||
reservedWords = new HashSet<String> (
|
reservedWords = new HashSet<String> (
|
||||||
Arrays.asList(
|
Arrays.asList(
|
||||||
"int")
|
"__FILE__", "and", "def", "end", "in", "or", "self", "unless", "__LINE__",
|
||||||
|
"begin", "defined?", "ensure", "module", "redo", "super", "until", "BEGIN",
|
||||||
|
"break", "do", "false", "next", "rescue", "then", "when", "END", "case",
|
||||||
|
"else", "for", "nil", "retry", "true", "while", "alias", "class", "elsif",
|
||||||
|
"if", "not", "return", "undef", "yield")
|
||||||
);
|
);
|
||||||
|
|
||||||
additionalProperties.put("invokerPackage", invokerPackage);
|
additionalProperties.put("invokerPackage", invokerPackage);
|
||||||
@ -117,4 +121,70 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
|||||||
public String toDefaultValue(Property p) {
|
public String toDefaultValue(Property p) {
|
||||||
return "null";
|
return "null";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toVarName(String name) {
|
||||||
|
// replace - with _ e.g. created-at => created_at
|
||||||
|
name = name.replaceAll("-", "_");
|
||||||
|
|
||||||
|
// if it's all uppper case, convert to lower case
|
||||||
|
if (name.matches("^[A-Z_]*$"))
|
||||||
|
name = name.toLowerCase();
|
||||||
|
|
||||||
|
// camelize (lower first character) the variable name
|
||||||
|
// petId => pet_id
|
||||||
|
name = underscore(name);
|
||||||
|
|
||||||
|
// for reserved word or word starting with number, append _
|
||||||
|
if(reservedWords.contains(name) || name.matches("^\\d.*"))
|
||||||
|
name = escapeReservedWord(name);
|
||||||
|
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toParamName(String name) {
|
||||||
|
// should be the same as variable name
|
||||||
|
return toVarName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelName(String name) {
|
||||||
|
// model name cannot use reserved keyword, e.g. return
|
||||||
|
if(reservedWords.contains(name))
|
||||||
|
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
|
||||||
|
|
||||||
|
// camelize the model name
|
||||||
|
// phone_number => PhoneNumber
|
||||||
|
return camelize(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toModelFilename(String name) {
|
||||||
|
// model name cannot use reserved keyword, e.g. return
|
||||||
|
if(reservedWords.contains(name))
|
||||||
|
throw new RuntimeException(name + " (reserved word) cannot be used as a model name");
|
||||||
|
|
||||||
|
// underscore the model file name
|
||||||
|
// PhoneNumber.rb => phone_number.rb
|
||||||
|
return underscore(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiFilename(String name) {
|
||||||
|
// replace - with _ e.g. created-at => created_at
|
||||||
|
name = name.replaceAll("-", "_");
|
||||||
|
|
||||||
|
// e.g. PhoneNumberApi.rb => phone_number_api.rb
|
||||||
|
return underscore(name) + "_api";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toApiName(String name) {
|
||||||
|
if(name.length() == 0)
|
||||||
|
return "DefaultApi";
|
||||||
|
// e.g. phone_number_api => PhoneNumberApi
|
||||||
|
return camelize(name) + "Api";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,324 +0,0 @@
|
|||||||
require "uri"
|
|
||||||
|
|
||||||
class Pet_api
|
|
||||||
basePath = "http://petstore.swagger.wordnik.com/api"
|
|
||||||
# apiInvoker = APIInvoker
|
|
||||||
|
|
||||||
def self.escapeString(string)
|
|
||||||
URI.encode(string.to_s)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.get_pet_by_id (pet_id,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "pet_id is required" if pet_id.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:pet_id => pet_id}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
|
|
||||||
Pet.new(response)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.delete_pet (pet_id,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "pet_id is required" if pet_id.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:pet_id => pet_id}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.partial_update (pet_id,body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "pet_id is required" if pet_id.nil?
|
|
||||||
raise "body is required" if body.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:pet_id => pet_id,
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
response = Swagger::Request.new(:PATCH, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
|
|
||||||
response.map {|response|Pet.new(response)}
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.update_pet_with_form (pet_id,name,status,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "pet_id is required" if pet_id.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:pet_id => pet_id,
|
|
||||||
:name => name,
|
|
||||||
:status => status}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.upload_file (additional_metadata,body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:additional_metadata => additional_metadata,
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet/uploadImage".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.add_pet (body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "body is required" if body.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.update_pet (body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "body is required" if body.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Swagger::Request.new(:PUT, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.find_pets_by_status (status= "available",opts={})
|
|
||||||
query_param_keys = [:status]
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "status is required" if status.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:status => status}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet/findByStatus".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
|
|
||||||
response.map {|response|Pet.new(response)}
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.find_pets_by_tags (tags,opts={})
|
|
||||||
query_param_keys = [:tags]
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "tags is required" if tags.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:tags => tags}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/pet/findByTags".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
|
|
||||||
response.map {|response|Pet.new(response)}
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
|||||||
require "uri"
|
|
||||||
|
|
||||||
class Store_api
|
|
||||||
basePath = "http://petstore.swagger.wordnik.com/api"
|
|
||||||
# apiInvoker = APIInvoker
|
|
||||||
|
|
||||||
def self.escapeString(string)
|
|
||||||
URI.encode(string.to_s)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.get_order_by_id (order_id,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "order_id is required" if order_id.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:order_id => order_id}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(order_id))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
|
|
||||||
Order.new(response)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.delete_order (order_id,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "order_id is required" if order_id.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:order_id => order_id}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(order_id))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.place_order (body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "body is required" if body.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/store/order".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
@ -1,297 +0,0 @@
|
|||||||
require "uri"
|
|
||||||
|
|
||||||
class User_api
|
|
||||||
basePath = "http://petstore.swagger.wordnik.com/api"
|
|
||||||
# apiInvoker = APIInvoker
|
|
||||||
|
|
||||||
def self.escapeString(string)
|
|
||||||
URI.encode(string.to_s)
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.update_user (username,body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "username is required" if username.nil?
|
|
||||||
raise "body is required" if body.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:username => username,
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Swagger::Request.new(:PUT, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.delete_user (username,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "username is required" if username.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:username => username}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.get_user_by_name (username,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "username is required" if username.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:username => username}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', escapeString(username))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
|
|
||||||
User.new(response)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.login_user (username,password,opts={})
|
|
||||||
query_param_keys = [:username,:password]
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "username is required" if username.nil?
|
|
||||||
raise "password is required" if password.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:username => username,
|
|
||||||
:password => password}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/user/login".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body }).make.body
|
|
||||||
string.new(response)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.logout_user (opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/user/logout".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.create_user (body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "body is required" if body.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/user".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.create_users_with_array_input (body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "body is required" if body.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/user/createWithArray".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.create_users_with_list_input (body,opts={})
|
|
||||||
query_param_keys = []
|
|
||||||
|
|
||||||
# verify existence of params
|
|
||||||
raise "body is required" if body.nil?
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:body => body}.merge(opts)
|
|
||||||
|
|
||||||
#resource path
|
|
||||||
path = "/user/createWithList".sub('{format}','json')
|
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
headers = nil
|
|
||||||
post_body = nil
|
|
||||||
if body != nil
|
|
||||||
if body.is_a?(Array)
|
|
||||||
array = Array.new
|
|
||||||
body.each do |item|
|
|
||||||
if item.respond_to?("to_body".to_sym)
|
|
||||||
array.push item.to_body
|
|
||||||
else
|
|
||||||
array.push item
|
|
||||||
end
|
|
||||||
end
|
|
||||||
post_body = array
|
|
||||||
|
|
||||||
else
|
|
||||||
if body.respond_to?("to_body".to_sym)
|
|
||||||
post_body = body.to_body
|
|
||||||
else
|
|
||||||
post_body = body
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body}).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
@ -215,19 +215,19 @@ class PetApi
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.getPetById (petId, opts={})
|
def self.getPetById (pet_id, opts={})
|
||||||
query_param_keys = []
|
query_param_keys = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
# set default values and merge with input
|
||||||
options = {
|
options = {
|
||||||
:'petId' => petId
|
:'pet_id' => pet_id
|
||||||
|
|
||||||
}.merge(opts)
|
}.merge(opts)
|
||||||
|
|
||||||
#resource path
|
#resource path
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(petId))
|
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
# pull querystring keys from options
|
||||||
@ -257,21 +257,21 @@ class PetApi
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.updatePetWithForm (petId,name,status, opts={})
|
def self.updatePetWithForm (pet_id,name,status, opts={})
|
||||||
query_param_keys = []
|
query_param_keys = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
# set default values and merge with input
|
||||||
options = {
|
options = {
|
||||||
:'petId' => petId,
|
:'pet_id' => pet_id,
|
||||||
:'name' => name,
|
:'name' => name,
|
||||||
:'status' => status
|
:'status' => status
|
||||||
|
|
||||||
}.merge(opts)
|
}.merge(opts)
|
||||||
|
|
||||||
#resource path
|
#resource path
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(petId))
|
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
# pull querystring keys from options
|
||||||
@ -302,7 +302,7 @@ class PetApi
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.deletePet (api_key,petId, opts={})
|
def self.deletePet (api_key,pet_id, opts={})
|
||||||
query_param_keys = []
|
query_param_keys = []
|
||||||
|
|
||||||
|
|
||||||
@ -310,12 +310,12 @@ class PetApi
|
|||||||
# set default values and merge with input
|
# set default values and merge with input
|
||||||
options = {
|
options = {
|
||||||
:'api_key' => api_key,
|
:'api_key' => api_key,
|
||||||
:'petId' => petId
|
:'pet_id' => pet_id
|
||||||
|
|
||||||
}.merge(opts)
|
}.merge(opts)
|
||||||
|
|
||||||
#resource path
|
#resource path
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(petId))
|
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
# pull querystring keys from options
|
||||||
@ -344,21 +344,21 @@ class PetApi
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.uploadFile (petId,additionalMetadata,file, opts={})
|
def self.uploadFile (pet_id,additional_metadata,file, opts={})
|
||||||
query_param_keys = []
|
query_param_keys = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
# set default values and merge with input
|
||||||
options = {
|
options = {
|
||||||
:'petId' => petId,
|
:'pet_id' => pet_id,
|
||||||
:'additionalMetadata' => additionalMetadata,
|
:'additional_metadata' => additional_metadata,
|
||||||
:'file' => file
|
:'file' => file
|
||||||
|
|
||||||
}.merge(opts)
|
}.merge(opts)
|
||||||
|
|
||||||
#resource path
|
#resource path
|
||||||
path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(petId))
|
path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', escapeString(pet_id))
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
# pull querystring keys from options
|
||||||
@ -378,7 +378,7 @@ class PetApi
|
|||||||
# form parameters
|
# form parameters
|
||||||
form_parameter_hash = {}
|
form_parameter_hash = {}
|
||||||
|
|
||||||
form_parameter_hash["additionalMetadata"] = additionalMetadata
|
form_parameter_hash["additionalMetadata"] = additional_metadata
|
||||||
form_parameter_hash["file"] = file
|
form_parameter_hash["file"] = file
|
||||||
|
|
||||||
|
|
@ -112,19 +112,19 @@ class StoreApi
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.getOrderById (orderId, opts={})
|
def self.getOrderById (order_id, opts={})
|
||||||
query_param_keys = []
|
query_param_keys = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
# set default values and merge with input
|
||||||
options = {
|
options = {
|
||||||
:'orderId' => orderId
|
:'order_id' => order_id
|
||||||
|
|
||||||
}.merge(opts)
|
}.merge(opts)
|
||||||
|
|
||||||
#resource path
|
#resource path
|
||||||
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(orderId))
|
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(order_id))
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
# pull querystring keys from options
|
||||||
@ -154,19 +154,19 @@ class StoreApi
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def self.deleteOrder (orderId, opts={})
|
def self.deleteOrder (order_id, opts={})
|
||||||
query_param_keys = []
|
query_param_keys = []
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
# set default values and merge with input
|
||||||
options = {
|
options = {
|
||||||
:'orderId' => orderId
|
:'order_id' => order_id
|
||||||
|
|
||||||
}.merge(opts)
|
}.merge(opts)
|
||||||
|
|
||||||
#resource path
|
#resource path
|
||||||
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(orderId))
|
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', escapeString(order_id))
|
||||||
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
# pull querystring keys from options
|
@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
class Order
|
class Order
|
||||||
attr_accessor :id, :petId, :quantity, :shipDate, :status, :complete
|
attr_accessor :id, :pet_id, :quantity, :ship_date, :status, :complete
|
||||||
# :internal => :external
|
# :internal => :external
|
||||||
def self.attribute_map
|
def self.attribute_map
|
||||||
{
|
{
|
||||||
:id => :'id',
|
:id => :'id',
|
||||||
:petId => :'petId',
|
:pet_id => :'petId',
|
||||||
:quantity => :'quantity',
|
:quantity => :'quantity',
|
||||||
:shipDate => :'shipDate',
|
:ship_date => :'shipDate',
|
||||||
:status => :'status',
|
:status => :'status',
|
||||||
:complete => :'complete'
|
:complete => :'complete'
|
||||||
|
|
||||||
@ -22,16 +22,16 @@ class Order
|
|||||||
@id = attributes["id"]
|
@id = attributes["id"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"petId"]
|
if self.class.attribute_map[:"pet_id"]
|
||||||
@petId = attributes["petId"]
|
@pet_id = attributes["petId"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"quantity"]
|
if self.class.attribute_map[:"quantity"]
|
||||||
@quantity = attributes["quantity"]
|
@quantity = attributes["quantity"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"shipDate"]
|
if self.class.attribute_map[:"ship_date"]
|
||||||
@shipDate = attributes["shipDate"]
|
@ship_date = attributes["shipDate"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"status"]
|
if self.class.attribute_map[:"status"]
|
@ -1,13 +1,13 @@
|
|||||||
|
|
||||||
class Pet
|
class Pet
|
||||||
attr_accessor :id, :category, :name, :photoUrls, :tags, :status
|
attr_accessor :id, :category, :name, :photo_urls, :tags, :status
|
||||||
# :internal => :external
|
# :internal => :external
|
||||||
def self.attribute_map
|
def self.attribute_map
|
||||||
{
|
{
|
||||||
:id => :'id',
|
:id => :'id',
|
||||||
:category => :'category',
|
:category => :'category',
|
||||||
:name => :'name',
|
:name => :'name',
|
||||||
:photoUrls => :'photoUrls',
|
:photo_urls => :'photoUrls',
|
||||||
:tags => :'tags',
|
:tags => :'tags',
|
||||||
:status => :'status'
|
:status => :'status'
|
||||||
|
|
||||||
@ -30,9 +30,9 @@ class Pet
|
|||||||
@name = attributes["name"]
|
@name = attributes["name"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"photoUrls"]
|
if self.class.attribute_map[:"photo_urls"]
|
||||||
if (value = attributes["photoUrls"]).is_a?(Array)
|
if (value = attributes["photoUrls"]).is_a?(Array)
|
||||||
@photoUrls = value
|
@photo_urls = value
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
@ -1,17 +1,17 @@
|
|||||||
|
|
||||||
class User
|
class User
|
||||||
attr_accessor :id, :username, :firstName, :lastName, :email, :password, :phone, :userStatus
|
attr_accessor :id, :username, :first_name, :last_name, :email, :password, :phone, :user_status
|
||||||
# :internal => :external
|
# :internal => :external
|
||||||
def self.attribute_map
|
def self.attribute_map
|
||||||
{
|
{
|
||||||
:id => :'id',
|
:id => :'id',
|
||||||
:username => :'username',
|
:username => :'username',
|
||||||
:firstName => :'firstName',
|
:first_name => :'firstName',
|
||||||
:lastName => :'lastName',
|
:last_name => :'lastName',
|
||||||
:email => :'email',
|
:email => :'email',
|
||||||
:password => :'password',
|
:password => :'password',
|
||||||
:phone => :'phone',
|
:phone => :'phone',
|
||||||
:userStatus => :'userStatus'
|
:user_status => :'userStatus'
|
||||||
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -28,12 +28,12 @@ class User
|
|||||||
@username = attributes["username"]
|
@username = attributes["username"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"firstName"]
|
if self.class.attribute_map[:"first_name"]
|
||||||
@firstName = attributes["firstName"]
|
@first_name = attributes["firstName"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"lastName"]
|
if self.class.attribute_map[:"last_name"]
|
||||||
@lastName = attributes["lastName"]
|
@last_name = attributes["lastName"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"email"]
|
if self.class.attribute_map[:"email"]
|
||||||
@ -48,8 +48,8 @@ class User
|
|||||||
@phone = attributes["phone"]
|
@phone = attributes["phone"]
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.class.attribute_map[:"userStatus"]
|
if self.class.attribute_map[:"user_status"]
|
||||||
@userStatus = attributes["userStatus"]
|
@user_status = attributes["userStatus"]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
Loading…
x
Reference in New Issue
Block a user