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> (
|
||||
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);
|
||||
@ -117,4 +121,70 @@ public class RubyClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
public String toDefaultValue(Property p) {
|
||||
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
|
||||
|
||||
|
||||
def self.getPetById (petId, opts={})
|
||||
def self.getPetById (pet_id, opts={})
|
||||
query_param_keys = []
|
||||
|
||||
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
:'petId' => petId
|
||||
:'pet_id' => pet_id
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#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
|
||||
@ -257,21 +257,21 @@ class PetApi
|
||||
end
|
||||
|
||||
|
||||
def self.updatePetWithForm (petId,name,status, opts={})
|
||||
def self.updatePetWithForm (pet_id,name,status, opts={})
|
||||
query_param_keys = []
|
||||
|
||||
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
:'petId' => petId,
|
||||
:'pet_id' => pet_id,
|
||||
:'name' => name,
|
||||
:'status' => status
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#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
|
||||
@ -302,7 +302,7 @@ class PetApi
|
||||
end
|
||||
|
||||
|
||||
def self.deletePet (api_key,petId, opts={})
|
||||
def self.deletePet (api_key,pet_id, opts={})
|
||||
query_param_keys = []
|
||||
|
||||
|
||||
@ -310,12 +310,12 @@ class PetApi
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
:'api_key' => api_key,
|
||||
:'petId' => petId
|
||||
:'pet_id' => pet_id
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#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
|
||||
@ -344,21 +344,21 @@ class PetApi
|
||||
end
|
||||
|
||||
|
||||
def self.uploadFile (petId,additionalMetadata,file, opts={})
|
||||
def self.uploadFile (pet_id,additional_metadata,file, opts={})
|
||||
query_param_keys = []
|
||||
|
||||
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
:'petId' => petId,
|
||||
:'additionalMetadata' => additionalMetadata,
|
||||
:'pet_id' => pet_id,
|
||||
:'additional_metadata' => additional_metadata,
|
||||
:'file' => file
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#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
|
||||
@ -378,7 +378,7 @@ class PetApi
|
||||
# form parameters
|
||||
form_parameter_hash = {}
|
||||
|
||||
form_parameter_hash["additionalMetadata"] = additionalMetadata
|
||||
form_parameter_hash["additionalMetadata"] = additional_metadata
|
||||
form_parameter_hash["file"] = file
|
||||
|
||||
|
@ -112,19 +112,19 @@ class StoreApi
|
||||
end
|
||||
|
||||
|
||||
def self.getOrderById (orderId, opts={})
|
||||
def self.getOrderById (order_id, opts={})
|
||||
query_param_keys = []
|
||||
|
||||
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
:'orderId' => orderId
|
||||
:'order_id' => order_id
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#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
|
||||
@ -154,19 +154,19 @@ class StoreApi
|
||||
end
|
||||
|
||||
|
||||
def self.deleteOrder (orderId, opts={})
|
||||
def self.deleteOrder (order_id, opts={})
|
||||
query_param_keys = []
|
||||
|
||||
|
||||
|
||||
# set default values and merge with input
|
||||
options = {
|
||||
:'orderId' => orderId
|
||||
:'order_id' => order_id
|
||||
|
||||
}.merge(opts)
|
||||
|
||||
#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
|
@ -1,13 +1,13 @@
|
||||
|
||||
class Order
|
||||
attr_accessor :id, :petId, :quantity, :shipDate, :status, :complete
|
||||
attr_accessor :id, :pet_id, :quantity, :ship_date, :status, :complete
|
||||
# :internal => :external
|
||||
def self.attribute_map
|
||||
{
|
||||
:id => :'id',
|
||||
:petId => :'petId',
|
||||
:pet_id => :'petId',
|
||||
:quantity => :'quantity',
|
||||
:shipDate => :'shipDate',
|
||||
:ship_date => :'shipDate',
|
||||
:status => :'status',
|
||||
:complete => :'complete'
|
||||
|
||||
@ -22,16 +22,16 @@ class Order
|
||||
@id = attributes["id"]
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"petId"]
|
||||
@petId = attributes["petId"]
|
||||
if self.class.attribute_map[:"pet_id"]
|
||||
@pet_id = attributes["petId"]
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"quantity"]
|
||||
@quantity = attributes["quantity"]
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"shipDate"]
|
||||
@shipDate = attributes["shipDate"]
|
||||
if self.class.attribute_map[:"ship_date"]
|
||||
@ship_date = attributes["shipDate"]
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"status"]
|
@ -1,13 +1,13 @@
|
||||
|
||||
class Pet
|
||||
attr_accessor :id, :category, :name, :photoUrls, :tags, :status
|
||||
attr_accessor :id, :category, :name, :photo_urls, :tags, :status
|
||||
# :internal => :external
|
||||
def self.attribute_map
|
||||
{
|
||||
:id => :'id',
|
||||
:category => :'category',
|
||||
:name => :'name',
|
||||
:photoUrls => :'photoUrls',
|
||||
:photo_urls => :'photoUrls',
|
||||
:tags => :'tags',
|
||||
:status => :'status'
|
||||
|
||||
@ -30,9 +30,9 @@ class Pet
|
||||
@name = attributes["name"]
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"photoUrls"]
|
||||
if self.class.attribute_map[:"photo_urls"]
|
||||
if (value = attributes["photoUrls"]).is_a?(Array)
|
||||
@photoUrls = value
|
||||
@photo_urls = value
|
||||
end
|
||||
end
|
||||
|
@ -1,17 +1,17 @@
|
||||
|
||||
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
|
||||
def self.attribute_map
|
||||
{
|
||||
:id => :'id',
|
||||
:username => :'username',
|
||||
:firstName => :'firstName',
|
||||
:lastName => :'lastName',
|
||||
:first_name => :'firstName',
|
||||
:last_name => :'lastName',
|
||||
:email => :'email',
|
||||
:password => :'password',
|
||||
:phone => :'phone',
|
||||
:userStatus => :'userStatus'
|
||||
:user_status => :'userStatus'
|
||||
|
||||
}
|
||||
end
|
||||
@ -28,12 +28,12 @@ class User
|
||||
@username = attributes["username"]
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"firstName"]
|
||||
@firstName = attributes["firstName"]
|
||||
if self.class.attribute_map[:"first_name"]
|
||||
@first_name = attributes["firstName"]
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"lastName"]
|
||||
@lastName = attributes["lastName"]
|
||||
if self.class.attribute_map[:"last_name"]
|
||||
@last_name = attributes["lastName"]
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"email"]
|
||||
@ -48,8 +48,8 @@ class User
|
||||
@phone = attributes["phone"]
|
||||
end
|
||||
|
||||
if self.class.attribute_map[:"userStatus"]
|
||||
@userStatus = attributes["userStatus"]
|
||||
if self.class.attribute_map[:"user_status"]
|
||||
@user_status = attributes["userStatus"]
|
||||
end
|
||||
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user