forked from loafle/openapi-generator-original
Merge branch 'bug-fix-ruby-file-upload' into ruby-api-client
Conflicts: modules/swagger-codegen/src/main/resources/ruby/swagger/request.mustache samples/client/petstore/ruby/lib/petstore/swagger/request.rb
This commit is contained in:
commit
0e2e7838ae
@ -290,7 +290,8 @@ module {{moduleName}}
|
|||||||
|
|
||||||
def build_request_body(header_params, form_params, body)
|
def build_request_body(header_params, form_params, body)
|
||||||
# http form
|
# http form
|
||||||
if header_params['Content-Type'] == 'application/x-www-form-urlencoded'
|
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
||||||
|
header_params['Content-Type'] == 'multipart/form-data'
|
||||||
data = form_params.dup
|
data = form_params.dup
|
||||||
data.each do |key, value|
|
data.each do |key, value|
|
||||||
data[key] = value.to_s if value && !value.is_a?(File)
|
data[key] = value.to_s if value && !value.is_a?(File)
|
||||||
|
1
samples/client/petstore/ruby/hello.txt
Normal file
1
samples/client/petstore/ruby/hello.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
Hello world!
|
@ -13,8 +13,8 @@ require 'petstore/models/order'
|
|||||||
|
|
||||||
# APIs
|
# APIs
|
||||||
require 'petstore/api/user_api'
|
require 'petstore/api/user_api'
|
||||||
require 'petstore/api/pet_api'
|
|
||||||
require 'petstore/api/store_api'
|
require 'petstore/api/store_api'
|
||||||
|
require 'petstore/api/pet_api'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
end
|
end
|
||||||
|
@ -238,7 +238,7 @@ module Petstore
|
|||||||
post_body = nil
|
post_body = nil
|
||||||
|
|
||||||
|
|
||||||
auth_names = ['api_key', 'petstore_auth']
|
auth_names = ['petstore_auth', 'api_key']
|
||||||
result = @api_client.call_api(:GET, path,
|
result = @api_client.call_api(:GET, path,
|
||||||
:header_params => header_params,
|
:header_params => header_params,
|
||||||
:query_params => query_params,
|
:query_params => query_params,
|
||||||
|
@ -290,7 +290,8 @@ module Petstore
|
|||||||
|
|
||||||
def build_request_body(header_params, form_params, body)
|
def build_request_body(header_params, form_params, body)
|
||||||
# http form
|
# http form
|
||||||
if header_params['Content-Type'] == 'application/x-www-form-urlencoded'
|
if header_params['Content-Type'] == 'application/x-www-form-urlencoded' ||
|
||||||
|
header_params['Content-Type'] == 'multipart/form-data'
|
||||||
data = form_params.dup
|
data = form_params.dup
|
||||||
data.each do |key, value|
|
data.each do |key, value|
|
||||||
data[key] = value.to_s if value && !value.is_a?(File)
|
data[key] = value.to_s if value && !value.is_a?(File)
|
||||||
|
@ -105,5 +105,16 @@ describe "Pet" do
|
|||||||
pet.id.should == 10002
|
pet.id.should == 10002
|
||||||
pet.name.should == "RUBY UNIT TESTING"
|
pet.name.should == "RUBY UNIT TESTING"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "should upload a file to a pet" do
|
||||||
|
pet = Petstore::Pet.new('id' => 10002, 'name' => "RUBY UNIT TESTING")
|
||||||
|
result = @pet_api.add_pet(:body => pet)
|
||||||
|
# nothing is returned
|
||||||
|
result.should be_nil
|
||||||
|
|
||||||
|
result = @pet_api.upload_file(10002, file: File.new('hello.txt'))
|
||||||
|
# nothing is returned
|
||||||
|
result.should be_nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user