mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
Merge branch 'ruby-void-response' of ssh://github.com/xhh/swagger-codegen into xhh-ruby-void-response
This commit is contained in:
commit
3cb9d094d3
@ -12,7 +12,7 @@ module {{moduleName}}
|
||||
{{#allParams}}{{#required}} # @param {{paramName}} {{description}}
|
||||
{{/required}}{{/allParams}} # @param [Hash] opts the optional parameters
|
||||
{{#allParams}}{{^required}} # @option opts [{{dataType}}] :{{paramName}} {{description}}
|
||||
{{/required}}{{/allParams}} # @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}
|
||||
{{/required}}{{/allParams}} # @return [{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}nil{{/returnType}}]
|
||||
def self.{{nickname}}({{#allParams}}{{#required}}{{paramName}}, {{/required}}{{/allParams}}opts = {})
|
||||
{{#allParams}}{{#required}}
|
||||
# verify the required parameter '{{paramName}}' is set
|
||||
@ -51,8 +51,9 @@ module {{moduleName}}
|
||||
{{/bodyParam}}
|
||||
|
||||
{{#returnType}}response = Swagger::Request.new(:{{httpMethod}}, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||
{{#returnContainer}}response.map {|response| {{/returnContainer}}obj = {{returnBaseType}}.new() and obj.build_from_hash(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}}
|
||||
end
|
||||
{{#returnContainer}}response.map {|response| {{/returnContainer}}obj = {{returnBaseType}}.new() and obj.build_from_hash(response){{#returnContainer}} }{{/returnContainer}}{{/returnType}}{{^returnType}}Swagger::Request.new(:{{httpMethod}}, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
nil{{/returnType}}
|
||||
end
|
||||
{{/operation}}
|
||||
end
|
||||
{{/operations}}
|
||||
|
@ -9,7 +9,7 @@ module SwaggerClient
|
||||
#
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [Pet] :body Pet object that needs to be added to the store
|
||||
# @return void
|
||||
# @return [nil]
|
||||
def self.update_pet(opts = {})
|
||||
|
||||
|
||||
@ -37,14 +37,15 @@ module SwaggerClient
|
||||
post_body = Swagger::Request.object_to_http_body(opts[:'body'])
|
||||
|
||||
|
||||
Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
end
|
||||
Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
nil
|
||||
end
|
||||
|
||||
# Add a new pet 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 [nil]
|
||||
def self.add_pet(opts = {})
|
||||
|
||||
|
||||
@ -72,14 +73,15 @@ module SwaggerClient
|
||||
post_body = Swagger::Request.object_to_http_body(opts[:'body'])
|
||||
|
||||
|
||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
end
|
||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
nil
|
||||
end
|
||||
|
||||
# Finds Pets by status
|
||||
# Multiple status values can be provided with comma seperated strings
|
||||
# @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.find_pets_by_status(opts = {})
|
||||
|
||||
|
||||
@ -110,13 +112,13 @@ module SwaggerClient
|
||||
|
||||
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||
response.map {|response| obj = Pet.new() and obj.build_from_hash(response) }
|
||||
end
|
||||
end
|
||||
|
||||
# Finds Pets by tags
|
||||
# Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [array[string]] :tags Tags to filter by
|
||||
# @return array[Pet]
|
||||
# @return [array[Pet]]
|
||||
def self.find_pets_by_tags(opts = {})
|
||||
|
||||
|
||||
@ -147,13 +149,13 @@ module SwaggerClient
|
||||
|
||||
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||
response.map {|response| obj = Pet.new() and obj.build_from_hash(response) }
|
||||
end
|
||||
end
|
||||
|
||||
# Find pet by ID
|
||||
# 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 [Hash] opts the optional parameters
|
||||
# @return Pet
|
||||
# @return [Pet]
|
||||
def self.get_pet_by_id(pet_id, opts = {})
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
@ -186,7 +188,7 @@ module SwaggerClient
|
||||
|
||||
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||
obj = Pet.new() and obj.build_from_hash(response)
|
||||
end
|
||||
end
|
||||
|
||||
# Updates a pet in the store with form data
|
||||
#
|
||||
@ -194,7 +196,7 @@ module SwaggerClient
|
||||
# @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 void
|
||||
# @return [nil]
|
||||
def self.update_pet_with_form(pet_id, opts = {})
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
@ -227,15 +229,16 @@ module SwaggerClient
|
||||
post_body = nil
|
||||
|
||||
|
||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
end
|
||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
nil
|
||||
end
|
||||
|
||||
# Deletes a pet
|
||||
#
|
||||
# @param pet_id Pet id to delete
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [string] :api_key
|
||||
# @return void
|
||||
# @return [nil]
|
||||
def self.delete_pet(pet_id, opts = {})
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
@ -267,8 +270,9 @@ module SwaggerClient
|
||||
post_body = nil
|
||||
|
||||
|
||||
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
end
|
||||
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
nil
|
||||
end
|
||||
|
||||
# uploads an image
|
||||
#
|
||||
@ -276,7 +280,7 @@ module SwaggerClient
|
||||
# @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 void
|
||||
# @return [nil]
|
||||
def self.upload_file(pet_id, opts = {})
|
||||
|
||||
# verify the required parameter 'pet_id' is set
|
||||
@ -309,7 +313,8 @@ module SwaggerClient
|
||||
post_body = nil
|
||||
|
||||
|
||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
end
|
||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -8,7 +8,7 @@ module SwaggerClient
|
||||
# Returns pet inventories by status
|
||||
# Returns a map of status codes to quantities
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return map[string,int]
|
||||
# @return [map[string,int]]
|
||||
def self.get_inventory(opts = {})
|
||||
|
||||
|
||||
@ -38,13 +38,13 @@ module SwaggerClient
|
||||
|
||||
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||
response.map {|response| obj = map.new() and obj.build_from_hash(response) }
|
||||
end
|
||||
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
|
||||
# @return [Order]
|
||||
def self.place_order(opts = {})
|
||||
|
||||
|
||||
@ -74,13 +74,13 @@ module SwaggerClient
|
||||
|
||||
response = Swagger::Request.new(:POST, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||
obj = Order.new() and obj.build_from_hash(response)
|
||||
end
|
||||
end
|
||||
|
||||
# Find purchase order by ID
|
||||
# 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 [Hash] opts the optional parameters
|
||||
# @return Order
|
||||
# @return [Order]
|
||||
def self.get_order_by_id(order_id, opts = {})
|
||||
|
||||
# verify the required parameter 'order_id' is set
|
||||
@ -113,13 +113,13 @@ module SwaggerClient
|
||||
|
||||
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||
obj = Order.new() and obj.build_from_hash(response)
|
||||
end
|
||||
end
|
||||
|
||||
# Delete purchase order by ID
|
||||
# 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 [Hash] opts the optional parameters
|
||||
# @return void
|
||||
# @return [nil]
|
||||
def self.delete_order(order_id, opts = {})
|
||||
|
||||
# verify the required parameter 'order_id' is set
|
||||
@ -150,7 +150,8 @@ module SwaggerClient
|
||||
post_body = nil
|
||||
|
||||
|
||||
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
end
|
||||
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -9,7 +9,7 @@ module SwaggerClient
|
||||
# This can only be done by the logged in user.
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [User] :body Created user object
|
||||
# @return void
|
||||
# @return [nil]
|
||||
def self.create_user(opts = {})
|
||||
|
||||
|
||||
@ -37,14 +37,15 @@ module SwaggerClient
|
||||
post_body = Swagger::Request.object_to_http_body(opts[:'body'])
|
||||
|
||||
|
||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
end
|
||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
nil
|
||||
end
|
||||
|
||||
# Creates list of users with given input array
|
||||
#
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [array[User]] :body List of user object
|
||||
# @return void
|
||||
# @return [nil]
|
||||
def self.create_users_with_array_input(opts = {})
|
||||
|
||||
|
||||
@ -72,14 +73,15 @@ module SwaggerClient
|
||||
post_body = Swagger::Request.object_to_http_body(opts[:'body'])
|
||||
|
||||
|
||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
end
|
||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
nil
|
||||
end
|
||||
|
||||
# Creates list of users with given input array
|
||||
#
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [array[User]] :body List of user object
|
||||
# @return void
|
||||
# @return [nil]
|
||||
def self.create_users_with_list_input(opts = {})
|
||||
|
||||
|
||||
@ -107,15 +109,16 @@ module SwaggerClient
|
||||
post_body = Swagger::Request.object_to_http_body(opts[:'body'])
|
||||
|
||||
|
||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
end
|
||||
Swagger::Request.new(:POST, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
nil
|
||||
end
|
||||
|
||||
# Logs user into the system
|
||||
#
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @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.login_user(opts = {})
|
||||
|
||||
|
||||
@ -147,12 +150,12 @@ module SwaggerClient
|
||||
|
||||
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||
obj = string.new() and obj.build_from_hash(response)
|
||||
end
|
||||
end
|
||||
|
||||
# Logs out current logged in user session
|
||||
#
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @return void
|
||||
# @return [nil]
|
||||
def self.logout_user(opts = {})
|
||||
|
||||
|
||||
@ -180,14 +183,15 @@ module SwaggerClient
|
||||
post_body = nil
|
||||
|
||||
|
||||
Swagger::Request.new(:GET, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
end
|
||||
Swagger::Request.new(:GET, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
nil
|
||||
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
|
||||
# @return [User]
|
||||
def self.get_user_by_name(username, opts = {})
|
||||
|
||||
# verify the required parameter 'username' is set
|
||||
@ -220,14 +224,14 @@ module SwaggerClient
|
||||
|
||||
response = Swagger::Request.new(:GET, path, {:params => query_params, :headers => header_params, :form_params => form_params, :body => post_body}).make.body
|
||||
obj = User.new() and obj.build_from_hash(response)
|
||||
end
|
||||
end
|
||||
|
||||
# Updated user
|
||||
# This can only be done by the logged in user.
|
||||
# @param username name that need to be deleted
|
||||
# @param [Hash] opts the optional parameters
|
||||
# @option opts [User] :body Updated user object
|
||||
# @return void
|
||||
# @return [nil]
|
||||
def self.update_user(username, opts = {})
|
||||
|
||||
# verify the required parameter 'username' is set
|
||||
@ -258,14 +262,15 @@ module SwaggerClient
|
||||
post_body = Swagger::Request.object_to_http_body(opts[:'body'])
|
||||
|
||||
|
||||
Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
end
|
||||
Swagger::Request.new(:PUT, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
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 void
|
||||
# @return [nil]
|
||||
def self.delete_user(username, opts = {})
|
||||
|
||||
# verify the required parameter 'username' is set
|
||||
@ -296,7 +301,8 @@ module SwaggerClient
|
||||
post_body = nil
|
||||
|
||||
|
||||
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
end
|
||||
Swagger::Request.new(:DELETE, path, {:params => query_params,:headers => header_params, :form_params => form_params, :body => post_body}).make
|
||||
nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -75,7 +75,9 @@ describe "Pet" do
|
||||
|
||||
it "should create a pet" do
|
||||
pet = SwaggerClient::Pet.new('id' => 10002, 'name' => "RUBY UNIT TESTING")
|
||||
SwaggerClient::PetApi.add_pet(:body => pet)
|
||||
result = SwaggerClient::PetApi.add_pet(:body => pet)
|
||||
# nothing is returned
|
||||
result.should be_nil
|
||||
|
||||
pet = SwaggerClient::PetApi.get_pet_by_id(10002)
|
||||
pet.id.should == 10002
|
||||
|
Loading…
Reference in New Issue
Block a user