forked from loafle/openapi-generator-original
Support optional parameters in Ruby client
* Pass optional parameters via the `opts` Hash * Handle query parameters in a way similar to header/form parameters to support parameter name normalization, e.g. the "additional_metadata" key is passed for "additionalMetadata" * Rename variables to be consistent: `query_params`, `header_params` and `form_params` * Remove unnecessary blank lines
This commit is contained in:
parent
57ca71fcc9
commit
a819e4d523
@ -4,55 +4,47 @@ require "uri"
|
|||||||
class {{classname}}
|
class {{classname}}
|
||||||
basePath = "{{basePath}}"
|
basePath = "{{basePath}}"
|
||||||
# apiInvoker = APIInvoker
|
# apiInvoker = APIInvoker
|
||||||
|
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
{{newline}}
|
{{newline}}
|
||||||
# {{summary}}
|
# {{summary}}
|
||||||
# {{notes}}
|
# {{notes}}
|
||||||
{{#allParams}}{{^optional}} # @param {{paramName}} {{description}}
|
{{#allParams}}{{#required}} # @param {{paramName}} {{description}}
|
||||||
{{/optional}}{{/allParams}}{{#allParams}}{{#optional}} # @option opts [{{dataType}}] :{{baseName}} {{description}}
|
{{/required}}{{/allParams}} # @param [Hash] opts the optional parameters
|
||||||
{{/optional}}{{/allParams}} # @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
{{#allParams}}{{^required}} # @option opts [{{dataType}}] :{{baseName}} {{description}}
|
||||||
def self.{{nickname}} ({{#allParams}}{{paramName}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}, {{/allParams}}opts={})
|
{{/required}}{{/allParams}} # @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||||
query_param_keys = [{{#queryParams}}:{{paramName}}{{#hasMore}},{{/hasMore}}{{/queryParams}}]
|
def self.{{nickname}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {})
|
||||||
headerParams = {}
|
# verify existence of params{{#allParams}}{{#required}}
|
||||||
|
raise "{{{paramName}}} is required" if {{{paramName}}}.nil?{{/required}}{{/allParams}}
|
||||||
{{#requiredParamCount}}
|
|
||||||
# verify existence of params
|
|
||||||
{{#requiredParams}}
|
|
||||||
raise "{{{paramName}}} is required" if {{{paramName}}}.nil?
|
|
||||||
{{/requiredParams}}
|
|
||||||
{{/requiredParamCount}}
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
{{#allParams}}:'{{paramName}}' => {{paramName}}{{#hasMore}},{{/hasMore}}
|
|
||||||
{{/allParams}}
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "{{path}}".sub('{format}','json'){{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s)
|
path = "{{path}}".sub('{format}','json'){{#pathParams}}.sub('{' + '{{baseName}}' + '}', {{paramName}}.to_s){{/pathParams}}
|
||||||
{{/pathParams}}{{newline}}
|
|
||||||
|
|
||||||
# pull querystring keys from options
|
# query parameters
|
||||||
queryopts = options.select do |key,value|
|
query_params = {}
|
||||||
query_param_keys.include? key
|
{{#queryParams}}{{#required}}
|
||||||
end
|
query_params[:'{{{baseName}}}'] = {{{paramName}}}{{/required}}{{/queryParams}}{{#queryParams}}{{^required}}
|
||||||
|
query_params[:'{{{baseName}}}'] = opts[:'{{{paramName}}}'] if opts[:'{{{paramName}}}']{{/required}}{{/queryParams}}
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = '{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}'
|
_header_accept = '{{#produces}}{{mediaType}}{{#hasMore}}, {{/hasMore}}{{/produces}}'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
_header_content_type = [{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]
|
||||||
_header_content_type = [{{#consumes}}'{{mediaType}}'{{#hasMore}}, {{/hasMore}}{{/consumes}}]
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
{{#headerParams}}{{#required}}
|
||||||
|
header_params[:'{{{baseName}}}'] = {{{paramName}}}{{/required}}{{/headerParams}}{{#headerParams}}{{^required}}
|
||||||
|
header_params[:'{{{baseName}}}'] = opts[:'{{{paramName}}}'] if opts[:'{{{paramName}}}']{{/required}}{{/headerParams}}
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
{{#formParams}}{{#required}}
|
||||||
|
form_params["{{baseName}}"] = {{paramName}}{{/required}}{{/formParams}}{{#formParams}}{{^required}}
|
||||||
|
form_params["{{baseName}}"] = opts[:'{{paramName}}'] if opts[:'{{paramName}}']{{/required}}{{/formParams}}
|
||||||
|
|
||||||
{{#headerParams}}{{#optional}}headers[:'{{{baseName}}}'] = options[:'{{{paramName}}}'] if options[:'{{{paramName}}}']{{/optional}}{{/headerParams}}
|
|
||||||
{{#headerParams}}{{^optional}}headers[:'{{{baseName}}}'] = {{{paramName}}}{{/optional}}{{/headerParams}}
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil{{#bodyParam}}
|
||||||
{{#bodyParam}}
|
|
||||||
if body != nil
|
if body != nil
|
||||||
if body.is_a?(Array)
|
if body.is_a?(Array)
|
||||||
array = Array.new
|
array = Array.new
|
||||||
@ -71,21 +63,11 @@ class {{classname}}
|
|||||||
post_body = body
|
post_body = body
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end{{/bodyParam}}
|
||||||
{{/bodyParam}}
|
|
||||||
# form parameters
|
|
||||||
form_parameter_hash = {}
|
|
||||||
{{#formParams}}{{#optional}}form_parameter_hash["{{baseName}}"] = options[:'{{paramName}}'] if options[:'{{paramName}}']{{/optional}}
|
|
||||||
{{^optional}}form_parameter_hash["{{baseName}}"] = {{paramName}}{{/optional}}{{/formParams}}
|
|
||||||
{{#returnType}}
|
{{#returnType}}
|
||||||
response = Swagger::Request.new(:{{httpMethod}}, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make.body
|
response = Swagger::Request.new(:{{httpMethod}}, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
{{#returnContainer}}
|
{{#returnContainer}}response.map {|response| {{/returnContainer}}{{returnBaseType}}.new(response){{#returnContainer}} }{{/returnContainer}}{{/returnType}}{{^returnType}} Swagger::Request.new(:{{httpMethod}}, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make{{/returnType}}
|
||||||
response.map {|response|{{/returnContainer}} {{returnBaseType}}.new(response){{#returnContainer}} }{{/returnContainer}}
|
|
||||||
{{/returnType}}
|
|
||||||
{{^returnType}}
|
|
||||||
Swagger::Request.new(:{{httpMethod}}, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
|
||||||
{{/returnType}}
|
|
||||||
{{newline}}
|
|
||||||
end
|
end
|
||||||
{{/operation}}
|
{{/operation}}
|
||||||
end
|
end
|
||||||
|
@ -4,46 +4,37 @@ class PetApi
|
|||||||
basePath = "http://petstore.swagger.io/v2"
|
basePath = "http://petstore.swagger.io/v2"
|
||||||
# apiInvoker = APIInvoker
|
# apiInvoker = APIInvoker
|
||||||
|
|
||||||
|
|
||||||
# Update an existing pet
|
# Update an existing pet
|
||||||
#
|
#
|
||||||
# @param body Pet object that needs to be added to the store
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [Pet] :body Pet object that needs to be added to the store
|
||||||
# @return void
|
# @return void
|
||||||
def self.updatePet (body, opts={})
|
def self.updatePet(opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'body' => body
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/pet".sub('{format}','json')
|
path = "/pet".sub('{format}','json')
|
||||||
|
|
||||||
# pull querystring keys from options
|
# query parameters
|
||||||
queryopts = options.select do |key,value|
|
query_params = {}
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = ['application/json', 'application/xml', ]
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = ['application/json', 'application/xml', ]
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
if body != nil
|
if body != nil
|
||||||
if body.is_a?(Array)
|
if body.is_a?(Array)
|
||||||
array = Array.new
|
array = Array.new
|
||||||
@ -64,55 +55,40 @@ class PetApi
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# form parameters
|
Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:PUT, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
|
||||||
|
|
||||||
|
|
||||||
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 [Hash] opts the optional parameters
|
||||||
|
# @option opts [Pet] :body Pet object that needs to be added to the store
|
||||||
# @return void
|
# @return void
|
||||||
def self.addPet (body, opts={})
|
def self.addPet(opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'body' => body
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/pet".sub('{format}','json')
|
path = "/pet".sub('{format}','json')
|
||||||
|
|
||||||
# pull querystring keys from options
|
# query parameters
|
||||||
queryopts = options.select do |key,value|
|
query_params = {}
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = ['application/json', 'application/xml', ]
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = ['application/json', 'application/xml', ]
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
if body != nil
|
if body != nil
|
||||||
if body.is_a?(Array)
|
if body.is_a?(Array)
|
||||||
array = Array.new
|
array = Array.new
|
||||||
@ -133,330 +109,235 @@ class PetApi
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# form parameters
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Finds Pets by status
|
# Finds Pets by status
|
||||||
# Multiple status values can be provided with comma seperated strings
|
# Multiple status values can be provided with comma seperated strings
|
||||||
# @param status Status values that need to be considered for filter
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [array[string]] :status Status values that need to be considered for filter
|
||||||
# @return array[Pet]
|
# @return array[Pet]
|
||||||
def self.findPetsByStatus (status, opts={})
|
def self.findPetsByStatus(opts = {})
|
||||||
query_param_keys = [:status]
|
# verify existence of params
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'status' => status
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/pet/findByStatus".sub('{format}','json')
|
path = "/pet/findByStatus".sub('{format}','json')
|
||||||
|
|
||||||
# pull querystring keys from options
|
# query parameters
|
||||||
queryopts = options.select do |key,value|
|
query_params = {}
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
query_params[:'status'] = opts[:'status'] if opts[:'status']
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = []
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = []
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
# form parameters
|
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make.body
|
|
||||||
|
|
||||||
response.map {|response| Pet.new(response) }
|
response.map {|response| Pet.new(response) }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Finds Pets by tags
|
# Finds Pets by tags
|
||||||
# Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
# Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||||
# @param tags Tags to filter by
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [array[string]] :tags Tags to filter by
|
||||||
# @return array[Pet]
|
# @return array[Pet]
|
||||||
def self.findPetsByTags (tags, opts={})
|
def self.findPetsByTags(opts = {})
|
||||||
query_param_keys = [:tags]
|
# verify existence of params
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'tags' => tags
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/pet/findByTags".sub('{format}','json')
|
path = "/pet/findByTags".sub('{format}','json')
|
||||||
|
|
||||||
# pull querystring keys from options
|
# query parameters
|
||||||
queryopts = options.select do |key,value|
|
query_params = {}
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
query_params[:'tags'] = opts[:'tags'] if opts[:'tags']
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = []
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = []
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
# form parameters
|
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make.body
|
|
||||||
|
|
||||||
response.map {|response| Pet.new(response) }
|
response.map {|response| Pet.new(response) }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Find pet by ID
|
# Find pet by ID
|
||||||
# Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
# Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||||
# @param pet_id ID of pet that needs to be fetched
|
# @param pet_id ID of pet that needs to be fetched
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
# @return Pet
|
# @return Pet
|
||||||
def self.getPetById(pet_id, opts = {})
|
def self.getPetById(pet_id, opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
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
|
# resource path
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
||||||
|
|
||||||
|
# query parameters
|
||||||
|
query_params = {}
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = []
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = []
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
# form parameters
|
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make.body
|
|
||||||
Pet.new(response)
|
Pet.new(response)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
# @param name Updated name of the pet
|
# @param [Hash] opts the optional parameters
|
||||||
# @param status Updated status of the pet
|
# @option opts [string] :name Updated name of the pet
|
||||||
|
# @option opts [string] :status Updated status of the pet
|
||||||
# @return void
|
# @return void
|
||||||
def self.updatePetWithForm (pet_id, name, status, opts={})
|
def self.updatePetWithForm(pet_id, opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
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
|
# resource path
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
||||||
|
|
||||||
|
# query parameters
|
||||||
|
query_params = {}
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = ['application/x-www-form-urlencoded', ]
|
_header_content_type = ['application/x-www-form-urlencoded', ]
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
form_params["name"] = opts[:'name'] if opts[:'name']
|
||||||
|
form_params["status"] = opts[:'status'] if opts[:'status']
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
# form parameters
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
form_parameter_hash["name"] = name
|
|
||||||
form_parameter_hash["status"] = status
|
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Deletes a pet
|
# Deletes a pet
|
||||||
#
|
#
|
||||||
# @param api_key
|
|
||||||
# @param pet_id Pet id to delete
|
# @param pet_id Pet id to delete
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [string] :api_key
|
||||||
# @return void
|
# @return void
|
||||||
def self.deletePet (api_key, pet_id, opts={})
|
def self.deletePet(pet_id, opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
raise "pet_id is required" if pet_id.nil?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'api_key' => api_key,
|
|
||||||
:'pet_id' => pet_id
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
||||||
|
|
||||||
|
# query parameters
|
||||||
|
query_params = {}
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = []
|
_header_content_type = []
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
header_params[:'api_key'] = opts[:'api_key'] if opts[:'api_key']
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
headers[:'api_key'] = api_key
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
# form parameters
|
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# uploads an image
|
# uploads an image
|
||||||
#
|
#
|
||||||
# @param pet_id ID of pet to update
|
# @param pet_id ID of pet to update
|
||||||
# @param additional_metadata Additional data to pass to server
|
# @param [Hash] opts the optional parameters
|
||||||
# @param file file to upload
|
# @option opts [string] :additionalMetadata Additional data to pass to server
|
||||||
|
# @option opts [file] :file file to upload
|
||||||
# @return void
|
# @return void
|
||||||
def self.uploadFile (pet_id, additional_metadata, file, opts={})
|
def self.uploadFile(pet_id, opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
raise "pet_id is required" if pet_id.nil?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'pet_id' => pet_id,
|
|
||||||
:'additional_metadata' => additional_metadata,
|
|
||||||
:'file' => file
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
|
||||||
|
|
||||||
|
# query parameters
|
||||||
|
query_params = {}
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = ['multipart/form-data', ]
|
_header_content_type = ['multipart/form-data', ]
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
form_params["additionalMetadata"] = opts[:'additional_metadata'] if opts[:'additional_metadata']
|
||||||
|
form_params["file"] = opts[:'file'] if opts[:'file']
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
# form parameters
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
form_parameter_hash["additionalMetadata"] = additional_metadata
|
|
||||||
form_parameter_hash["file"] = file
|
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,95 +4,72 @@ class StoreApi
|
|||||||
basePath = "http://petstore.swagger.io/v2"
|
basePath = "http://petstore.swagger.io/v2"
|
||||||
# apiInvoker = APIInvoker
|
# apiInvoker = APIInvoker
|
||||||
|
|
||||||
|
|
||||||
# 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
|
||||||
# @return map[string,int]
|
# @return map[string,int]
|
||||||
def self.getInventory(opts = {})
|
def self.getInventory(opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/store/inventory".sub('{format}','json')
|
path = "/store/inventory".sub('{format}','json')
|
||||||
|
|
||||||
# pull querystring keys from options
|
# query parameters
|
||||||
queryopts = options.select do |key,value|
|
query_params = {}
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = []
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = []
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
# form parameters
|
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make.body
|
|
||||||
|
|
||||||
response.map {|response| map.new(response) }
|
response.map {|response| map.new(response) }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Place an order for a pet
|
# Place an order for a pet
|
||||||
#
|
#
|
||||||
# @param body order placed for purchasing the pet
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [Order] :body order placed for purchasing the pet
|
||||||
# @return Order
|
# @return Order
|
||||||
def self.placeOrder (body, opts={})
|
def self.placeOrder(opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'body' => body
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/store/order".sub('{format}','json')
|
path = "/store/order".sub('{format}','json')
|
||||||
|
|
||||||
# pull querystring keys from options
|
# query parameters
|
||||||
queryopts = options.select do |key,value|
|
query_params = {}
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = []
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = []
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
if body != nil
|
if body != nil
|
||||||
if body.is_a?(Array)
|
if body.is_a?(Array)
|
||||||
array = Array.new
|
array = Array.new
|
||||||
@ -113,115 +90,80 @@ class StoreApi
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# form parameters
|
response = Swagger::Request.new(:POST, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make.body
|
|
||||||
Order.new(response)
|
Order.new(response)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
# @return Order
|
# @return Order
|
||||||
def self.getOrderById(order_id, opts = {})
|
def self.getOrderById(order_id, opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
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
|
# resource path
|
||||||
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
|
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
|
||||||
|
|
||||||
|
# query parameters
|
||||||
|
query_params = {}
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = []
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = []
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
# form parameters
|
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make.body
|
|
||||||
Order.new(response)
|
Order.new(response)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
# @return void
|
# @return void
|
||||||
def self.deleteOrder(order_id, opts = {})
|
def self.deleteOrder(order_id, opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
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
|
# resource path
|
||||||
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
|
path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
|
||||||
|
|
||||||
|
# query parameters
|
||||||
|
query_params = {}
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = []
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = []
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
# form parameters
|
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -4,46 +4,37 @@ class UserApi
|
|||||||
basePath = "http://petstore.swagger.io/v2"
|
basePath = "http://petstore.swagger.io/v2"
|
||||||
# apiInvoker = APIInvoker
|
# apiInvoker = APIInvoker
|
||||||
|
|
||||||
|
|
||||||
# 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 [Hash] opts the optional parameters
|
||||||
|
# @option opts [User] :body Created user object
|
||||||
# @return void
|
# @return void
|
||||||
def self.createUser (body, opts={})
|
def self.createUser(opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'body' => body
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/user".sub('{format}','json')
|
path = "/user".sub('{format}','json')
|
||||||
|
|
||||||
# pull querystring keys from options
|
# query parameters
|
||||||
queryopts = options.select do |key,value|
|
query_params = {}
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = []
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = []
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
if body != nil
|
if body != nil
|
||||||
if body.is_a?(Array)
|
if body.is_a?(Array)
|
||||||
array = Array.new
|
array = Array.new
|
||||||
@ -64,55 +55,40 @@ class UserApi
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# form parameters
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
|
||||||
|
|
||||||
|
|
||||||
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 [Hash] opts the optional parameters
|
||||||
|
# @option opts [array[User]] :body List of user object
|
||||||
# @return void
|
# @return void
|
||||||
def self.createUsersWithArrayInput (body, opts={})
|
def self.createUsersWithArrayInput(opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'body' => body
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/user/createWithArray".sub('{format}','json')
|
path = "/user/createWithArray".sub('{format}','json')
|
||||||
|
|
||||||
# pull querystring keys from options
|
# query parameters
|
||||||
queryopts = options.select do |key,value|
|
query_params = {}
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = []
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = []
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
if body != nil
|
if body != nil
|
||||||
if body.is_a?(Array)
|
if body.is_a?(Array)
|
||||||
array = Array.new
|
array = Array.new
|
||||||
@ -133,55 +109,40 @@ class UserApi
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# form parameters
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
|
||||||
|
|
||||||
|
|
||||||
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 [Hash] opts the optional parameters
|
||||||
|
# @option opts [array[User]] :body List of user object
|
||||||
# @return void
|
# @return void
|
||||||
def self.createUsersWithListInput (body, opts={})
|
def self.createUsersWithListInput(opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'body' => body
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/user/createWithList".sub('{format}','json')
|
path = "/user/createWithList".sub('{format}','json')
|
||||||
|
|
||||||
# pull querystring keys from options
|
# query parameters
|
||||||
queryopts = options.select do |key,value|
|
query_params = {}
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = []
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = []
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
if body != nil
|
if body != nil
|
||||||
if body.is_a?(Array)
|
if body.is_a?(Array)
|
||||||
array = Array.new
|
array = Array.new
|
||||||
@ -202,208 +163,152 @@ class UserApi
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# form parameters
|
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:POST, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Logs user into the system
|
# Logs user into the system
|
||||||
#
|
#
|
||||||
# @param username The user name for login
|
# @param [Hash] opts the optional parameters
|
||||||
# @param password The password for login in clear text
|
# @option opts [string] :username The user name for login
|
||||||
|
# @option opts [string] :password The password for login in clear text
|
||||||
# @return string
|
# @return string
|
||||||
def self.loginUser (username, password, opts={})
|
def self.loginUser(opts = {})
|
||||||
query_param_keys = [:username,:password]
|
# verify existence of params
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'username' => username,
|
|
||||||
:'password' => password
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/user/login".sub('{format}','json')
|
path = "/user/login".sub('{format}','json')
|
||||||
|
|
||||||
# pull querystring keys from options
|
# query parameters
|
||||||
queryopts = options.select do |key,value|
|
query_params = {}
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
query_params[:'username'] = opts[:'username'] if opts[:'username']
|
||||||
|
query_params[:'password'] = opts[:'password'] if opts[:'password']
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = []
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = []
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
# form parameters
|
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make.body
|
|
||||||
string.new(response)
|
string.new(response)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Logs out current logged in user session
|
# Logs out current logged in user session
|
||||||
#
|
#
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
# @return void
|
# @return void
|
||||||
def self.logoutUser(opts = {})
|
def self.logoutUser(opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/user/logout".sub('{format}','json')
|
path = "/user/logout".sub('{format}','json')
|
||||||
|
|
||||||
# pull querystring keys from options
|
# query parameters
|
||||||
queryopts = options.select do |key,value|
|
query_params = {}
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = []
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = []
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
# form parameters
|
Swagger::Request.new(:GET, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
|
||||||
|
|
||||||
|
|
||||||
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.
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
# @return User
|
# @return User
|
||||||
def self.getUserByName(username, opts = {})
|
def self.getUserByName(username, opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
raise "username is required" if username.nil?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'username' => username
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
|
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
|
||||||
|
|
||||||
|
# query parameters
|
||||||
|
query_params = {}
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = []
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = []
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
# form parameters
|
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
response = Swagger::Request.new(:GET, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make.body
|
|
||||||
User.new(response)
|
User.new(response)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
# @param body Updated user object
|
# @param [Hash] opts the optional parameters
|
||||||
|
# @option opts [User] :body Updated user object
|
||||||
# @return void
|
# @return void
|
||||||
def self.updateUser (username, body, opts={})
|
def self.updateUser(username, opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
raise "username is required" if username.nil?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'username' => username,
|
|
||||||
:'body' => body
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
|
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
|
||||||
|
|
||||||
|
# query parameters
|
||||||
|
query_params = {}
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = []
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = []
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
if body != nil
|
if body != nil
|
||||||
if body.is_a?(Array)
|
if body.is_a?(Array)
|
||||||
array = Array.new
|
array = Array.new
|
||||||
@ -424,63 +329,42 @@ class UserApi
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# form parameters
|
Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:PUT, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
|
||||||
|
|
||||||
|
|
||||||
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
|
||||||
|
# @param [Hash] opts the optional parameters
|
||||||
# @return void
|
# @return void
|
||||||
def self.deleteUser(username, opts = {})
|
def self.deleteUser(username, opts = {})
|
||||||
query_param_keys = []
|
# verify existence of params
|
||||||
headerParams = {}
|
raise "username is required" if username.nil?
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# set default values and merge with input
|
|
||||||
options = {
|
|
||||||
:'username' => username
|
|
||||||
|
|
||||||
}.merge(opts)
|
|
||||||
|
|
||||||
# resource path
|
# resource path
|
||||||
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
|
path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
|
||||||
|
|
||||||
|
# query parameters
|
||||||
|
query_params = {}
|
||||||
|
|
||||||
# pull querystring keys from options
|
|
||||||
queryopts = options.select do |key,value|
|
|
||||||
query_param_keys.include? key
|
|
||||||
end
|
|
||||||
|
|
||||||
# header parameters
|
# header parameters
|
||||||
headers = {}
|
header_params = {}
|
||||||
|
|
||||||
_header_accept = 'application/json, application/xml'
|
_header_accept = 'application/json, application/xml'
|
||||||
if _header_accept != ''
|
header_params['Accept'] = _header_accept if _header_accept != ''
|
||||||
headerParams['Accept'] = _header_accept
|
|
||||||
end
|
|
||||||
_header_content_type = []
|
|
||||||
headerParams['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
|
||||||
|
|
||||||
|
_header_content_type = []
|
||||||
|
header_params['Content-Type'] = _header_content_type.length > 0 ? _header_content_type[0] : 'application/json'
|
||||||
|
|
||||||
|
|
||||||
|
# form parameters
|
||||||
|
form_params = {}
|
||||||
|
|
||||||
|
|
||||||
# http body (model)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
# form parameters
|
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||||
form_parameter_hash = {}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Swagger::Request.new(:DELETE, path, {:params=>queryopts,:headers=>headers, :body=>post_body, :form_params => form_parameter_hash }).make
|
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user