Ruby: add auto-generated documentation in Markdown

This commit is contained in:
xhh
2016-03-09 17:18:15 +08:00
parent 998087d662
commit 2c64b885bb
28 changed files with 2443 additions and 590 deletions

View File

@@ -21,19 +21,19 @@ require 'petstore/version'
require 'petstore/configuration'
# Models
require 'petstore/models/order'
require 'petstore/models/special_model_name'
require 'petstore/models/user'
require 'petstore/models/category'
require 'petstore/models/object_return'
require 'petstore/models/inline_response_200'
require 'petstore/models/tag'
require 'petstore/models/model_return'
require 'petstore/models/order'
require 'petstore/models/pet'
require 'petstore/models/special_model_name'
require 'petstore/models/tag'
require 'petstore/models/user'
# APIs
require 'petstore/api/user_api'
require 'petstore/api/store_api'
require 'petstore/api/pet_api'
require 'petstore/api/store_api'
require 'petstore/api/user_api'
module Petstore
class << self

View File

@@ -24,62 +24,6 @@ module Petstore
@api_client = api_client
end
# Update an existing pet
#
# @param [Hash] opts the optional parameters
# @option opts [Pet] :body Pet object that needs to be added to the store
# @return [nil]
def update_pet(opts = {})
update_pet_with_http_info(opts)
return nil
end
# Update an existing pet
#
# @param [Hash] opts the optional parameters
# @option opts [Pet] :body Pet object that needs to be added to the store
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def update_pet_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#update_pet ..."
end
# resource path
local_var_path = "/pet".sub('{format}','json')
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = ['application/json', 'application/xml']
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#update_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Add a new pet to the store
#
# @param [Hash] opts the optional parameters
@@ -136,6 +80,124 @@ module Petstore
return data, status_code, headers
end
# Fake endpoint to test byte array in body parameter for adding a new pet to the store
#
# @param [Hash] opts the optional parameters
# @option opts [String] :body Pet object in the form of byte array
# @return [nil]
def add_pet_using_byte_array(opts = {})
add_pet_using_byte_array_with_http_info(opts)
return nil
end
# Fake endpoint to test byte array in body parameter for adding a new pet to the store
#
# @param [Hash] opts the optional parameters
# @option opts [String] :body Pet object in the form of byte array
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def add_pet_using_byte_array_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#add_pet_using_byte_array ..."
end
# resource path
local_var_path = "/pet?testing_byte_array=true".sub('{format}','json')
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = ['application/json', 'application/xml']
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#add_pet_using_byte_array\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Deletes a pet
#
# @param pet_id Pet id to delete
# @param [Hash] opts the optional parameters
# @option opts [String] :api_key
# @return [nil]
def delete_pet(pet_id, opts = {})
delete_pet_with_http_info(pet_id, opts)
return nil
end
# Deletes a pet
#
# @param pet_id Pet id to delete
# @param [Hash] opts the optional parameters
# @option opts [String] :api_key
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_pet_with_http_info(pet_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#delete_pet ..."
end
# verify the required parameter 'pet_id' is set
fail "Missing the required parameter 'pet_id' when calling delete_pet" if pet_id.nil?
# resource path
local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
header_params[:'api_key'] = opts[:'api_key'] if opts[:'api_key']
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#delete_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Finds Pets by status
# Multiple status values can be provided with comma separated strings
# @param [Hash] opts the optional parameters
@@ -312,198 +374,6 @@ module Petstore
return data, status_code, headers
end
# Updates a pet in the store with form data
#
# @param pet_id ID of pet that needs to be updated
# @param [Hash] opts the optional parameters
# @option opts [String] :name Updated name of the pet
# @option opts [String] :status Updated status of the pet
# @return [nil]
def update_pet_with_form(pet_id, opts = {})
update_pet_with_form_with_http_info(pet_id, opts)
return nil
end
# Updates a pet in the store with form data
#
# @param pet_id ID of pet that needs to be updated
# @param [Hash] opts the optional parameters
# @option opts [String] :name Updated name of the pet
# @option opts [String] :status Updated status of the pet
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def update_pet_with_form_with_http_info(pet_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#update_pet_with_form ..."
end
# verify the required parameter 'pet_id' is set
fail "Missing the required parameter 'pet_id' when calling update_pet_with_form" if pet_id.nil?
# resource path
local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = ['application/x-www-form-urlencoded']
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
form_params["name"] = opts[:'name'] if opts[:'name']
form_params["status"] = opts[:'status'] if opts[:'status']
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#update_pet_with_form\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Deletes a pet
#
# @param pet_id Pet id to delete
# @param [Hash] opts the optional parameters
# @option opts [String] :api_key
# @return [nil]
def delete_pet(pet_id, opts = {})
delete_pet_with_http_info(pet_id, opts)
return nil
end
# Deletes a pet
#
# @param pet_id Pet id to delete
# @param [Hash] opts the optional parameters
# @option opts [String] :api_key
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_pet_with_http_info(pet_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#delete_pet ..."
end
# verify the required parameter 'pet_id' is set
fail "Missing the required parameter 'pet_id' when calling delete_pet" if pet_id.nil?
# resource path
local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
header_params[:'api_key'] = opts[:'api_key'] if opts[:'api_key']
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#delete_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# uploads an image
#
# @param pet_id ID of pet to update
# @param [Hash] opts the optional parameters
# @option opts [String] :additional_metadata Additional data to pass to server
# @option opts [File] :file file to upload
# @return [nil]
def upload_file(pet_id, opts = {})
upload_file_with_http_info(pet_id, opts)
return nil
end
# uploads an image
#
# @param pet_id ID of pet to update
# @param [Hash] opts the optional parameters
# @option opts [String] :additional_metadata Additional data to pass to server
# @option opts [File] :file file to upload
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def upload_file_with_http_info(pet_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#upload_file ..."
end
# verify the required parameter 'pet_id' is set
fail "Missing the required parameter 'pet_id' when calling upload_file" if pet_id.nil?
# resource path
local_var_path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = ['multipart/form-data']
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# 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)
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#upload_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Fake endpoint to test inline arbitrary object return by &#39;Find pet by ID&#39;
# Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
# @param pet_id ID of pet that needs to be fetched
@@ -624,28 +494,28 @@ module Petstore
return data, status_code, headers
end
# Fake endpoint to test byte array in body parameter for adding a new pet to the store
# Update an existing pet
#
# @param [Hash] opts the optional parameters
# @option opts [String] :body Pet object in the form of byte array
# @option opts [Pet] :body Pet object that needs to be added to the store
# @return [nil]
def add_pet_using_byte_array(opts = {})
add_pet_using_byte_array_with_http_info(opts)
def update_pet(opts = {})
update_pet_with_http_info(opts)
return nil
end
# Fake endpoint to test byte array in body parameter for adding a new pet to the store
# Update an existing pet
#
# @param [Hash] opts the optional parameters
# @option opts [String] :body Pet object in the form of byte array
# @option opts [Pet] :body Pet object that needs to be added to the store
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def add_pet_using_byte_array_with_http_info(opts = {})
def update_pet_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#add_pet_using_byte_array ..."
@api_client.config.logger.debug "Calling API: PetApi#update_pet ..."
end
# resource path
local_var_path = "/pet?testing_byte_array=true".sub('{format}','json')
local_var_path = "/pet".sub('{format}','json')
# query parameters
query_params = {}
@@ -667,6 +537,71 @@ module Petstore
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:PUT, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#update_pet\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Updates a pet in the store with form data
#
# @param pet_id ID of pet that needs to be updated
# @param [Hash] opts the optional parameters
# @option opts [String] :name Updated name of the pet
# @option opts [String] :status Updated status of the pet
# @return [nil]
def update_pet_with_form(pet_id, opts = {})
update_pet_with_form_with_http_info(pet_id, opts)
return nil
end
# Updates a pet in the store with form data
#
# @param pet_id ID of pet that needs to be updated
# @param [Hash] opts the optional parameters
# @option opts [String] :name Updated name of the pet
# @option opts [String] :status Updated status of the pet
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def update_pet_with_form_with_http_info(pet_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#update_pet_with_form ..."
end
# verify the required parameter 'pet_id' is set
fail "Missing the required parameter 'pet_id' when calling update_pet_with_form" if pet_id.nil?
# resource path
local_var_path = "/pet/{petId}".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = ['application/x-www-form-urlencoded']
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
form_params["name"] = opts[:'name'] if opts[:'name']
form_params["status"] = opts[:'status'] if opts[:'status']
# http body (model)
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
@@ -675,7 +610,72 @@ module Petstore
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#add_pet_using_byte_array\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
@api_client.config.logger.debug "API called: PetApi#update_pet_with_form\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# uploads an image
#
# @param pet_id ID of pet to update
# @param [Hash] opts the optional parameters
# @option opts [String] :additional_metadata Additional data to pass to server
# @option opts [File] :file file to upload
# @return [nil]
def upload_file(pet_id, opts = {})
upload_file_with_http_info(pet_id, opts)
return nil
end
# uploads an image
#
# @param pet_id ID of pet to update
# @param [Hash] opts the optional parameters
# @option opts [String] :additional_metadata Additional data to pass to server
# @option opts [File] :file file to upload
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def upload_file_with_http_info(pet_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: PetApi#upload_file ..."
end
# verify the required parameter 'pet_id' is set
fail "Missing the required parameter 'pet_id' when calling upload_file" if pet_id.nil?
# resource path
local_var_path = "/pet/{petId}/uploadImage".sub('{format}','json').sub('{' + 'petId' + '}', pet_id.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = ['multipart/form-data']
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# 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)
post_body = nil
auth_names = ['petstore_auth']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: PetApi#upload_file\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

View File

@@ -24,6 +24,65 @@ module Petstore
@api_client = api_client
end
# Delete purchase order by ID
# For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
# @param order_id ID of the order that needs to be deleted
# @param [Hash] opts the optional parameters
# @return [nil]
def delete_order(order_id, opts = {})
delete_order_with_http_info(order_id, opts)
return nil
end
# Delete purchase order by ID
# For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
# @param order_id ID of the order that needs to be deleted
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_order_with_http_info(order_id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: StoreApi#delete_order ..."
end
# verify the required parameter 'order_id' is set
fail "Missing the required parameter 'order_id' when calling delete_order" if order_id.nil?
# resource path
local_var_path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: StoreApi#delete_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Finds orders by status
# A single status value can be provided as a string
# @param [Hash] opts the optional parameters
@@ -196,63 +255,6 @@ module Petstore
return data, status_code, headers
end
# Place an order for a pet
#
# @param [Hash] opts the optional parameters
# @option opts [Order] :body order placed for purchasing the pet
# @return [Order]
def place_order(opts = {})
data, status_code, headers = place_order_with_http_info(opts)
return data
end
# Place an order for a pet
#
# @param [Hash] opts the optional parameters
# @option opts [Order] :body order placed for purchasing the pet
# @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers
def place_order_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: StoreApi#place_order ..."
end
# resource path
local_var_path = "/store/order".sub('{format}','json')
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = ['test_api_client_id', 'test_api_client_secret']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'Order')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: StoreApi#place_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Find purchase order by ID
# For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions
# @param order_id ID of pet that needs to be fetched
@@ -313,31 +315,28 @@ module Petstore
return data, status_code, headers
end
# Delete purchase order by ID
# For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
# @param order_id ID of the order that needs to be deleted
# Place an order for a pet
#
# @param [Hash] opts the optional parameters
# @return [nil]
def delete_order(order_id, opts = {})
delete_order_with_http_info(order_id, opts)
return nil
# @option opts [Order] :body order placed for purchasing the pet
# @return [Order]
def place_order(opts = {})
data, status_code, headers = place_order_with_http_info(opts)
return data
end
# Delete purchase order by ID
# For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
# @param order_id ID of the order that needs to be deleted
# Place an order for a pet
#
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_order_with_http_info(order_id, opts = {})
# @option opts [Order] :body order placed for purchasing the pet
# @return [Array<(Order, Fixnum, Hash)>] Order data, response status code and response headers
def place_order_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: StoreApi#delete_order ..."
@api_client.config.logger.debug "Calling API: StoreApi#place_order ..."
end
# verify the required parameter 'order_id' is set
fail "Missing the required parameter 'order_id' when calling delete_order" if order_id.nil?
# resource path
local_var_path = "/store/order/{orderId}".sub('{format}','json').sub('{' + 'orderId' + '}', order_id.to_s)
local_var_path = "/store/order".sub('{format}','json')
# query parameters
query_params = {}
@@ -357,17 +356,18 @@ module Petstore
form_params = {}
# http body (model)
post_body = nil
post_body = @api_client.object_to_http_body(opts[:'body'])
auth_names = []
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
auth_names = ['test_api_client_id', 'test_api_client_secret']
data, status_code, headers = @api_client.call_api(:POST, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
:auth_names => auth_names,
:return_type => 'Order')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: StoreApi#delete_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
@api_client.config.logger.debug "API called: StoreApi#place_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

View File

@@ -192,6 +192,125 @@ module Petstore
return data, status_code, headers
end
# Delete user
# This can only be done by the logged in user.
# @param username The name that needs to be deleted
# @param [Hash] opts the optional parameters
# @return [nil]
def delete_user(username, opts = {})
delete_user_with_http_info(username, opts)
return nil
end
# Delete user
# This can only be done by the logged in user.
# @param username The name that needs to be deleted
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_user_with_http_info(username, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: UserApi#delete_user ..."
end
# verify the required parameter 'username' is set
fail "Missing the required parameter 'username' when calling delete_user" if username.nil?
# resource path
local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UserApi#delete_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get user by user name
#
# @param username The name that needs to be fetched. Use user1 for testing.
# @param [Hash] opts the optional parameters
# @return [User]
def get_user_by_name(username, opts = {})
data, status_code, headers = get_user_by_name_with_http_info(username, opts)
return data
end
# Get user by user name
#
# @param username The name that needs to be fetched. Use user1 for testing.
# @param [Hash] opts the optional parameters
# @return [Array<(User, Fixnum, Hash)>] User data, response status code and response headers
def get_user_by_name_with_http_info(username, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: UserApi#get_user_by_name ..."
end
# verify the required parameter 'username' is set
fail "Missing the required parameter 'username' when calling get_user_by_name" if username.nil?
# resource path
local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'User')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UserApi#get_user_by_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Logs user into the system
#
# @param [Hash] opts the optional parameters
@@ -307,66 +426,6 @@ module Petstore
return data, status_code, headers
end
# Get user by user name
#
# @param username The name that needs to be fetched. Use user1 for testing.
# @param [Hash] opts the optional parameters
# @return [User]
def get_user_by_name(username, opts = {})
data, status_code, headers = get_user_by_name_with_http_info(username, opts)
return data
end
# Get user by user name
#
# @param username The name that needs to be fetched. Use user1 for testing.
# @param [Hash] opts the optional parameters
# @return [Array<(User, Fixnum, Hash)>] User data, response status code and response headers
def get_user_by_name_with_http_info(username, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: UserApi#get_user_by_name ..."
end
# verify the required parameter 'username' is set
fail "Missing the required parameter 'username' when calling get_user_by_name" if username.nil?
# resource path
local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:GET, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => 'User')
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UserApi#get_user_by_name\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Updated user
# This can only be done by the logged in user.
# @param username name that need to be deleted
@@ -427,64 +486,5 @@ module Petstore
end
return data, status_code, headers
end
# Delete user
# This can only be done by the logged in user.
# @param username The name that needs to be deleted
# @param [Hash] opts the optional parameters
# @return [nil]
def delete_user(username, opts = {})
delete_user_with_http_info(username, opts)
return nil
end
# Delete user
# This can only be done by the logged in user.
# @param username The name that needs to be deleted
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def delete_user_with_http_info(username, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: UserApi#delete_user ..."
end
# verify the required parameter 'username' is set
fail "Missing the required parameter 'username' when calling delete_user" if username.nil?
# resource path
local_var_path = "/user/{username}".sub('{format}','json').sub('{' + 'username' + '}', username.to_s)
# query parameters
query_params = {}
# header parameters
header_params = {}
# HTTP header 'Accept' (if needed)
_header_accept = ['application/json', 'application/xml']
_header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result
# HTTP header 'Content-Type'
_header_content_type = []
header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)
# form parameters
form_params = {}
# http body (model)
post_body = nil
auth_names = []
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path,
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: UserApi#delete_user\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end

View File

@@ -18,21 +18,34 @@ require 'date'
module Petstore
class InlineResponse200
attr_accessor :photo_urls
attr_accessor :name
attr_accessor :id
attr_accessor :category
attr_accessor :tags
# pet status in the store
attr_accessor :status
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'photo_urls' => :'photoUrls',
:'name' => :'name',
:'id' => :'id',
:'category' => :'category'
:'category' => :'category',
:'tags' => :'tags',
:'status' => :'status'
}
end
@@ -40,9 +53,12 @@ module Petstore
# Attribute type mapping.
def self.swagger_types
{
:'photo_urls' => :'Array<String>',
:'name' => :'String',
:'id' => :'Integer',
:'category' => :'Object'
:'category' => :'Object',
:'tags' => :'Array<Tag>',
:'status' => :'String'
}
end
@@ -54,6 +70,12 @@ module Petstore
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
if attributes[:'photoUrls']
if (value = attributes[:'photoUrls']).is_a?(Array)
self.photo_urls = value
end
end
if attributes[:'name']
self.name = attributes[:'name']
end
@@ -66,15 +88,37 @@ module Petstore
self.category = attributes[:'category']
end
if attributes[:'tags']
if (value = attributes[:'tags']).is_a?(Array)
self.tags = value
end
end
if attributes[:'status']
self.status = attributes[:'status']
end
end
# Custom attribute writer method checking allowed values (enum).
def status=(status)
allowed_values = ["available", "pending", "sold"]
if status && !allowed_values.include?(status)
fail "invalid value for 'status', must be one of #{allowed_values}"
end
@status = status
end
# Check equality by comparing each attribute.
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
photo_urls == o.photo_urls &&
name == o.name &&
id == o.id &&
category == o.category
category == o.category &&
tags == o.tags &&
status == o.status
end
# @see the `==` method
@@ -84,7 +128,7 @@ module Petstore
# Calculate hash code according to all attributes.
def hash
[name, id, category].hash
[photo_urls, name, id, category, tags, status].hash
end
# build the object from hash

View File

@@ -0,0 +1,165 @@
=begin
Swagger Petstore
This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters
OpenAPI spec version: 1.0.0
Contact: apiteam@swagger.io
Generated by: https://github.com/swagger-api/swagger-codegen.git
License: Apache 2.0
http://www.apache.org/licenses/LICENSE-2.0.html
Terms of Service: http://swagger.io/terms/
=end
require 'date'
module Petstore
class ModelReturn
attr_accessor :_return
# Attribute mapping from ruby-style variable name to JSON key.
def self.attribute_map
{
:'_return' => :'return'
}
end
# Attribute type mapping.
def self.swagger_types
{
:'_return' => :'Integer'
}
end
def initialize(attributes = {})
return unless attributes.is_a?(Hash)
# convert string to symbol for hash key
attributes = attributes.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
if attributes[:'return']
self._return = attributes[:'return']
end
end
# Check equality by comparing each attribute.
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
_return == o._return
end
# @see the `==` method
def eql?(o)
self == o
end
# Calculate hash code according to all attributes.
def hash
[_return].hash
end
# build the object from hash
def build_from_hash(attributes)
return nil unless attributes.is_a?(Hash)
self.class.swagger_types.each_pair do |key, type|
if type =~ /^Array<(.*)>/i
if attributes[self.class.attribute_map[key]].is_a?(Array)
self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
else
#TODO show warning in debug mode
end
elsif !attributes[self.class.attribute_map[key]].nil?
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
else
# data not found in attributes(hash), not an issue as the data can be optional
end
end
self
end
def _deserialize(type, value)
case type.to_sym
when :DateTime
DateTime.parse(value)
when :Date
Date.parse(value)
when :String
value.to_s
when :Integer
value.to_i
when :Float
value.to_f
when :BOOLEAN
if value.to_s =~ /^(true|t|yes|y|1)$/i
true
else
false
end
when :Object
# generic object (usually a Hash), return directly
value
when /\AArray<(?<inner_type>.+)>\z/
inner_type = Regexp.last_match[:inner_type]
value.map { |v| _deserialize(inner_type, v) }
when /\AHash<(?<k_type>.+), (?<v_type>.+)>\z/
k_type = Regexp.last_match[:k_type]
v_type = Regexp.last_match[:v_type]
{}.tap do |hash|
value.each do |k, v|
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
end
end
else # model
_model = Petstore.const_get(type).new
_model.build_from_hash(value)
end
end
def to_s
to_hash.to_s
end
# to_body is an alias to to_body (backward compatibility))
def to_body
to_hash
end
# return the object in the form of hash
def to_hash
hash = {}
self.class.attribute_map.each_pair do |attr, param|
value = self.send(attr)
next if value.nil?
hash[param] = _to_hash(value)
end
hash
end
# Method to output non-array value in the form of hash
# For object, use to_hash. Otherwise, just return the value
def _to_hash(value)
if value.is_a?(Array)
value.compact.map{ |v| _to_hash(v) }
elsif value.is_a?(Hash)
{}.tap do |hash|
value.each { |k, v| hash[k] = _to_hash(v) }
end
elsif value.respond_to? :to_hash
value.to_hash
else
value
end
end
end
end