Merge pull request #3368 from wing328/ruby_fix_rspec

[Ruby] fix default rspec test cases for Ruby API client
This commit is contained in:
wing328 2016-07-14 22:13:34 +08:00 committed by GitHub
commit 2d35743b0d
18 changed files with 167 additions and 295 deletions

View File

@ -43,53 +43,6 @@ describe {{moduleName}}::ApiClient do
end
end
describe "#update_params_for_auth!" do
it "sets header api-key parameter with prefix" do
{{moduleName}}.configure do |c|
c.api_key_prefix['api_key'] = 'PREFIX'
c.api_key['api_key'] = 'special-key'
end
api_client = {{moduleName}}::ApiClient.new
config2 = {{moduleName}}::Configuration.new do |c|
c.api_key_prefix['api_key'] = 'PREFIX2'
c.api_key['api_key'] = 'special-key2'
end
api_client2 = {{moduleName}}::ApiClient.new(config2)
auth_names = ['api_key', 'unknown']
header_params = {}
query_params = {}
api_client.update_params_for_auth! header_params, query_params, auth_names
expect(header_params).to eq({'api_key' => 'PREFIX special-key'})
expect(query_params).to eq({})
header_params = {}
query_params = {}
api_client2.update_params_for_auth! header_params, query_params, auth_names
expect(header_params).to eq({'api_key' => 'PREFIX2 special-key2'})
expect(query_params).to eq({})
end
it "sets header api-key parameter without prefix" do
{{moduleName}}.configure do |c|
c.api_key_prefix['api_key'] = nil
c.api_key['api_key'] = 'special-key'
end
api_client = {{moduleName}}::ApiClient.new
header_params = {}
query_params = {}
auth_names = ['api_key', 'unknown']
api_client.update_params_for_auth! header_params, query_params, auth_names
expect(header_params).to eq({'api_key' => 'special-key'})
expect(query_params).to eq({})
end
end
describe "params_encoding in #build_request" do
let(:config) { {{moduleName}}::Configuration.new }
let(:api_client) { {{moduleName}}::ApiClient.new(config) }
@ -155,49 +108,18 @@ describe {{moduleName}}::ApiClient do
expect(data).to be_instance_of(Hash)
expect(data).to eq({:message => 'Hello'})
end
it "handles Hash<String, Pet>" do
api_client = {{moduleName}}::ApiClient.new
headers = {'Content-Type' => 'application/json'}
response = double('response', headers: headers, body: '{"pet": {"id": 1}}')
data = api_client.deserialize(response, 'Hash<String, Pet>')
expect(data).to be_instance_of(Hash)
expect(data.keys).to eq([:pet])
pet = data[:pet]
expect(pet).to be_instance_of({{moduleName}}::Pet)
expect(pet.id).to eq(1)
end
it "handles Hash<String, Hash<String, Pet>>" do
api_client = {{moduleName}}::ApiClient.new
headers = {'Content-Type' => 'application/json'}
response = double('response', headers: headers, body: '{"data": {"pet": {"id": 1}}}')
result = api_client.deserialize(response, 'Hash<String, Hash<String, Pet>>')
expect(result).to be_instance_of(Hash)
expect(result.keys).to match_array([:data])
data = result[:data]
expect(data).to be_instance_of(Hash)
expect(data.keys).to match_array([:pet])
pet = data[:pet]
expect(pet).to be_instance_of({{moduleName}}::Pet)
expect(pet.id).to eq(1)
end
end
describe "#object_to_hash" do
it "ignores nils and includes empty arrays" do
api_client = {{moduleName}}::ApiClient.new
pet = {{moduleName}}::Pet.new
pet.id = 1
pet.name = ''
pet.status = nil
pet.photo_urls = nil
pet.tags = []
expected = {id: 1, name: '', tags: []}
expect(api_client.object_to_hash(pet)).to eq(expected)
# uncomment below to test object_to_hash for model
#api_client = {{moduleName}}::ApiClient.new
#_model = {{moduleName}}::ModelName.new
# update the model attribute below
#_model.id = 1
# update the expected value (hash) below
#expected = {id: 1, name: '', tags: []}
#expect(api_client.object_to_hash(_model)).to eq(expected)
end
end

View File

@ -8,21 +8,26 @@ describe {{moduleName}}::Configuration do
let(:config) { {{moduleName}}::Configuration.default }
before(:each) do
{{moduleName}}.configure do |c|
c.host = 'petstore.swagger.io'
c.base_path = 'v2'
end
# uncomment below to setup host and base_path
#require 'URI'
#uri = URI.parse("{{{basePath}}}")
#{{moduleName}}.configure do |c|
# c.host = uri.host
# c.base_path = uri.path
#end
end
describe '#base_url' do
it 'should have the default value' do
expect(config.base_url).to eq('http://petstore.swagger.io/v2')
# uncomment below to test default value of the base path
#expect(config.base_url).to eq("{{{basePath}}}")
end
it 'should remove trailing slashes' do
[nil, '', '/', '//'].each do |base_path|
config.base_path = base_path
expect(config.base_url).to eq('http://petstore.swagger.io')
# uncomment below to test trailing slashes
#expect(config.base_url).to eq("{{{basePath}}}")
end
end
end

View File

@ -1,14 +1,14 @@
# petstore
Petstore - the Ruby gem for the Swagger Petstore */ &#39; \&quot;
Petstore - the Ruby gem for the Swagger Petstore */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \"
This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end --
This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
- API version: 1.0.0 */ &#39; \&quot;
- API version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
- Package version: 1.0.0
- Build date: 2016-06-28T17:34:19.923+08:00
- Build date: 2016-07-14T18:21:54.437+08:00
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
## Installation
@ -58,25 +58,25 @@ require 'petstore'
api_instance = Petstore::FakeApi.new
opts = {
test_code_inject____end: "test_code_inject____end_example" # String | To test code injection */ ' \"
test_code_inject____end____rn_n_r: "test_code_inject____end____rn_n_r_example" # String | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
}
begin
#To test code injection */ ' \"
api_instance.test_code_inject____end(opts)
#To test code injection */ ' \" =_end -- \\r\\n \\n \\r
api_instance.test_code_inject____end__rn_n_r(opts)
rescue Petstore::ApiError => e
puts "Exception when calling FakeApi->test_code_inject____end: #{e}"
puts "Exception when calling FakeApi->test_code_inject____end__rn_n_r: #{e}"
end
```
## Documentation for API Endpoints
All URIs are relative to *https://petstore.swagger.io */ &#39; &quot; &#x3D;end/v2 */ &#39; &quot; &#x3D;end*
All URIs are relative to *https://petstore.swagger.io */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r/v2 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r*
Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*Petstore::FakeApi* | [**test_code_inject____end**](docs/FakeApi.md#test_code_inject____end) | **PUT** /fake | To test code injection */ ' \"
*Petstore::FakeApi* | [**test_code_inject____end__rn_n_r**](docs/FakeApi.md#test_code_inject____end__rn_n_r) | **PUT** /fake | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
## Documentation for Models
@ -90,7 +90,7 @@ Class | Method | HTTP request | Description
### api_key
- **Type**: API key
- **API key parameter name**: api_key */ &#39; &quot; &#x3D;end
- **API key parameter name**: api_key */ &#39; &quot; &#x3D;end -- \r\n \n \r
- **Location**: HTTP header
### petstore_auth
@ -99,6 +99,6 @@ Class | Method | HTTP request | Description
- **Flow**: implicit
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
- **Scopes**:
- write:pets: modify pets in your account */ &#39; &quot; &#x3D;end
- read:pets: read your pets */ &#39; &quot; &#x3D;end
- write:pets: modify pets in your account */ &#39; &quot; &#x3D;end -- \r\n \n \r
- read:pets: read your pets */ &#39; &quot; &#x3D;end -- \r\n \n \r

View File

@ -1,16 +1,16 @@
# Petstore::FakeApi
All URIs are relative to *https://petstore.swagger.io */ &#39; &quot; &#x3D;end/v2 */ &#39; &quot; &#x3D;end*
All URIs are relative to *https://petstore.swagger.io */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r/v2 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r*
Method | HTTP request | Description
------------- | ------------- | -------------
[**test_code_inject____end**](FakeApi.md#test_code_inject____end) | **PUT** /fake | To test code injection */ &#39; \&quot;
[**test_code_inject____end__rn_n_r**](FakeApi.md#test_code_inject____end__rn_n_r) | **PUT** /fake | To test code injection */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
# **test_code_inject____end**
> test_code_inject____end(opts)
# **test_code_inject____end__rn_n_r**
> test_code_inject____end__rn_n_r(opts)
To test code injection */ ' \"
To test code injection */ ' \" =_end -- \\r\\n \\n \\r
### Example
```ruby
@ -20,14 +20,14 @@ require 'petstore'
api_instance = Petstore::FakeApi.new
opts = {
test_code_inject____end: "test_code_inject____end_example" # String | To test code injection */ ' \"
test_code_inject____end____rn_n_r: "test_code_inject____end____rn_n_r_example" # String | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
}
begin
#To test code injection */ ' \"
api_instance.test_code_inject____end(opts)
#To test code injection */ ' \" =_end -- \\r\\n \\n \\r
api_instance.test_code_inject____end__rn_n_r(opts)
rescue Petstore::ApiError => e
puts "Exception when calling FakeApi->test_code_inject____end: #{e}"
puts "Exception when calling FakeApi->test_code_inject____end__rn_n_r: #{e}"
end
```
@ -35,7 +35,7 @@ end
Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**test_code_inject____end** | **String**| To test code injection */ &#39; \&quot; | [optional]
**test_code_inject____end____rn_n_r** | **String**| To test code injection */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r | [optional]
### Return type
@ -47,8 +47,8 @@ No authorization required
### HTTP request headers
- **Content-Type**: application/json, */ " =end
- **Accept**: application/json, */ " =end
- **Content-Type**: application/json, */ \" =_end --
- **Accept**: application/json, */ \" =_end --

View File

@ -3,6 +3,6 @@
## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**_return** | **Integer** | property description */ &#39; \&quot; | [optional]
**_return** | **Integer** | property description */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r | [optional]

View File

@ -1,10 +1,10 @@
=begin
#Swagger Petstore */ ' \"
#Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \"
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,10 +1,10 @@
=begin
#Swagger Petstore */ ' \"
#Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \"
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
@ -31,24 +31,24 @@ module Petstore
@api_client = api_client
end
# To test code injection */ ' \"
# To test code injection */ ' \" =_end -- \\r\\n \\n \\r
#
# @param [Hash] opts the optional parameters
# @option opts [String] :test_code_inject____end To test code injection */ &#39; \&quot;
# @option opts [String] :test_code_inject____end____rn_n_r To test code injection */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
# @return [nil]
def test_code_inject____end(opts = {})
test_code_inject____end_with_http_info(opts)
def test_code_inject____end__rn_n_r(opts = {})
test_code_inject____end__rn_n_r_with_http_info(opts)
return nil
end
# To test code injection */ &#39; \&quot;
# To test code injection */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
#
# @param [Hash] opts the optional parameters
# @option opts [String] :test_code_inject____end To test code injection */ &#39; \&quot;
# @option opts [String] :test_code_inject____end____rn_n_r To test code injection */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
def test_code_inject____end_with_http_info(opts = {})
def test_code_inject____end__rn_n_r_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug "Calling API: FakeApi.test_code_inject____end ..."
@api_client.config.logger.debug "Calling API: FakeApi.test_code_inject____end__rn_n_r ..."
end
# resource path
local_var_path = "/fake".sub('{format}','json')
@ -60,16 +60,16 @@ module Petstore
header_params = {}
# HTTP header 'Accept' (if needed)
local_header_accept = ['application/json', '*/ " =end']
local_header_accept = ['application/json', '*/ \" =_end -- ']
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
# HTTP header 'Content-Type'
local_header_content_type = ['application/json', '*/ " =end']
local_header_content_type = ['application/json', '*/ \" =_end -- ']
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
# form parameters
form_params = {}
form_params["test code inject */ &#39; &quot; &#x3D;end"] = opts[:'test_code_inject____end'] if !opts[:'test_code_inject____end'].nil?
form_params["test code inject */ &#39; &quot; &#x3D;end -- \r\n \n \r"] = opts[:'test_code_inject____end____rn_n_r'] if !opts[:'test_code_inject____end____rn_n_r'].nil?
# http body (model)
post_body = nil
@ -81,7 +81,7 @@ module Petstore
:body => post_body,
:auth_names => auth_names)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: FakeApi#test_code_inject____end\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
@api_client.config.logger.debug "API called: FakeApi#test_code_inject____end__rn_n_r\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end

View File

@ -1,10 +1,10 @@
=begin
#Swagger Petstore */ ' \"
#Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \"
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
@ -99,6 +99,9 @@ module Petstore
update_params_for_auth! header_params, query_params, opts[:auth_names]
# set ssl_verifyhosts option based on @config.verify_ssl_host (true/false)
_verify_ssl_host = @config.verify_ssl_host ? 2 : 0
req_opts = {
:method => http_method,
:headers => header_params,
@ -106,11 +109,13 @@ module Petstore
:params_encoding => @config.params_encoding,
:timeout => @config.timeout,
:ssl_verifypeer => @config.verify_ssl,
:ssl_verifyhost => _verify_ssl_host,
:sslcert => @config.cert_file,
:sslkey => @config.key_file,
:verbose => @config.debugging
}
# set custom cert, if provided
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
if [:post, :patch, :put, :delete].include?(http_method)
@ -216,7 +221,7 @@ module Petstore
# @return [Tempfile] the file downloaded
def download_file(response)
content_disposition = response.headers['Content-Disposition']
if content_disposition
if content_disposition and content_disposition =~ /filename=/i
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
prefix = sanitize_filename(filename)
else

View File

@ -1,10 +1,10 @@
=begin
#Swagger Petstore */ ' \"
#Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \"
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,10 +1,10 @@
=begin
#Swagger Petstore */ ' \"
#Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \"
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
@ -87,7 +87,7 @@ module Petstore
# Default to 0 (never times out).
attr_accessor :timeout
### TLS/SSL
### TLS/SSL setting
# Set this to false to skip verifying SSL certificate when calling API from https server.
# Default to true.
#
@ -96,13 +96,16 @@ module Petstore
# @return [true, false]
attr_accessor :verify_ssl
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
# Default to nil.
### TLS/SSL setting
# Set this to false to skip verifying SSL host name
# Default to true.
#
# @see The params_encoding option of Ethon. Related source code:
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
attr_accessor :params_encoding
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
#
# @return [true, false]
attr_accessor :verify_ssl_host
### TLS/SSL setting
# Set this to customize the certificate file to verify the peer.
#
# @return [String] the path to the certificate file
@ -111,24 +114,34 @@ module Petstore
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
attr_accessor :ssl_ca_cert
### TLS/SSL setting
# Client certificate file (for client certificate)
attr_accessor :cert_file
### TLS/SSL setting
# Client private key file (for client certificate)
attr_accessor :key_file
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
# Default to nil.
#
# @see The params_encoding option of Ethon. Related source code:
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
attr_accessor :params_encoding
attr_accessor :inject_format
attr_accessor :force_ending_format
def initialize
@scheme = 'https'
@host = 'petstore.swagger.io */ &#39; &quot; &#x3D;end'
@base_path = '/v2 */ &#39; &quot; &#x3D;end'
@host = 'petstore.swagger.io */ &#39; &quot; &#x3D;end -- \r\n \n \r'
@base_path = '/v2 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r'
@api_key = {}
@api_key_prefix = {}
@timeout = 0
@verify_ssl = true
@verify_ssl_host = true
@params_encoding = nil
@cert_file = nil
@key_file = nil
@ -192,8 +205,8 @@ module Petstore
{
type: 'api_key',
in: 'header',
key: 'api_key */ &#39; &quot; &#x3D;end',
value: api_key_with_prefix('api_key */ &#39; &quot; &#x3D;end')
key: 'api_key */ &#39; &quot; &#x3D;end -- \r\n \n \r',
value: api_key_with_prefix('api_key */ &#39; &quot; &#x3D;end -- \r\n \n \r')
},
'petstore_auth' =>
{

View File

@ -1,10 +1,10 @@
=begin
#Swagger Petstore */ ' \"
#Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \"
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
@ -24,9 +24,9 @@ limitations under the License.
require 'date'
module Petstore
# Model for testing reserved words */ ' \"
# Model for testing reserved words */ ' \" =_end -- \\r\\n \\n \\r
class ModelReturn
# property description */ ' \"
# property description */ ' \" =_end -- \\r\\n \\n \\r
attr_accessor :_return

View File

@ -1,10 +1,10 @@
=begin
#Swagger Petstore */ ' \"
#Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \"
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,12 +1,12 @@
# -*- encoding: utf-8 -*-
#
=begin
#Swagger Petstore */ ' \"
#Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \"
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ &#39; \&quot;
Contact: apiteam@swagger.io */ ' \"
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
@ -31,11 +31,11 @@ Gem::Specification.new do |s|
s.version = Petstore::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Swagger-Codegen"]
s.email = ["apiteam@swagger.io */ &#39; \&quot; "]
s.email = ["apiteam@swagger.io */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r"]
s.homepage = "https://github.com/swagger-api/swagger-codegen"
s.summary = "Swagger Petstore */ ' \" Ruby Gem"
s.description = "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" "
s.license = "Apache 2.0 */ ' \" "
s.summary = "Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r Ruby Gem"
s.description = "This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end -- "
s.license = "Apache 2.0 */ ' \" =_end -- \\r\\n \\n \\r"
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3'

View File

@ -1,10 +1,10 @@
=begin
#Swagger Petstore */ ' \" =end
#Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;end
Contact: apiteam@swagger.io */ ' \" =end
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
@ -43,13 +43,13 @@ describe 'FakeApi' do
end
end
# unit tests for test_code_inject____end
# To test code injection */ &#39; \&quot; &#x3D;end
# unit tests for test_code_inject____end__rn_n_r
# To test code injection */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
#
# @param [Hash] opts the optional parameters
# @option opts [String] :test_code_inject____end To test code injection */ &#39; \&quot; &#x3D;end
# @option opts [String] :test_code_inject____end____rn_n_r To test code injection */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
# @return [nil]
describe 'test_code_inject____end test' do
describe 'test_code_inject____end__rn_n_r test' do
it "should work" do
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
end

View File

@ -1,10 +1,10 @@
=begin
#Swagger Petstore */ ' \" =end
#Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;end
Contact: apiteam@swagger.io */ ' \" =end
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
@ -62,53 +62,6 @@ describe Petstore::ApiClient do
end
end
describe "#update_params_for_auth!" do
it "sets header api-key parameter with prefix" do
Petstore.configure do |c|
c.api_key_prefix['api_key'] = 'PREFIX'
c.api_key['api_key'] = 'special-key'
end
api_client = Petstore::ApiClient.new
config2 = Petstore::Configuration.new do |c|
c.api_key_prefix['api_key'] = 'PREFIX2'
c.api_key['api_key'] = 'special-key2'
end
api_client2 = Petstore::ApiClient.new(config2)
auth_names = ['api_key', 'unknown']
header_params = {}
query_params = {}
api_client.update_params_for_auth! header_params, query_params, auth_names
expect(header_params).to eq({'api_key' => 'PREFIX special-key'})
expect(query_params).to eq({})
header_params = {}
query_params = {}
api_client2.update_params_for_auth! header_params, query_params, auth_names
expect(header_params).to eq({'api_key' => 'PREFIX2 special-key2'})
expect(query_params).to eq({})
end
it "sets header api-key parameter without prefix" do
Petstore.configure do |c|
c.api_key_prefix['api_key'] = nil
c.api_key['api_key'] = 'special-key'
end
api_client = Petstore::ApiClient.new
header_params = {}
query_params = {}
auth_names = ['api_key', 'unknown']
api_client.update_params_for_auth! header_params, query_params, auth_names
expect(header_params).to eq({'api_key' => 'special-key'})
expect(query_params).to eq({})
end
end
describe "params_encoding in #build_request" do
let(:config) { Petstore::Configuration.new }
let(:api_client) { Petstore::ApiClient.new(config) }
@ -174,49 +127,18 @@ describe Petstore::ApiClient do
expect(data).to be_instance_of(Hash)
expect(data).to eq({:message => 'Hello'})
end
it "handles Hash<String, Pet>" do
api_client = Petstore::ApiClient.new
headers = {'Content-Type' => 'application/json'}
response = double('response', headers: headers, body: '{"pet": {"id": 1}}')
data = api_client.deserialize(response, 'Hash<String, Pet>')
expect(data).to be_instance_of(Hash)
expect(data.keys).to eq([:pet])
pet = data[:pet]
expect(pet).to be_instance_of(Petstore::Pet)
expect(pet.id).to eq(1)
end
it "handles Hash<String, Hash<String, Pet>>" do
api_client = Petstore::ApiClient.new
headers = {'Content-Type' => 'application/json'}
response = double('response', headers: headers, body: '{"data": {"pet": {"id": 1}}}')
result = api_client.deserialize(response, 'Hash<String, Hash<String, Pet>>')
expect(result).to be_instance_of(Hash)
expect(result.keys).to match_array([:data])
data = result[:data]
expect(data).to be_instance_of(Hash)
expect(data.keys).to match_array([:pet])
pet = data[:pet]
expect(pet).to be_instance_of(Petstore::Pet)
expect(pet.id).to eq(1)
end
end
describe "#object_to_hash" do
it "ignores nils and includes empty arrays" do
api_client = Petstore::ApiClient.new
pet = Petstore::Pet.new
pet.id = 1
pet.name = ''
pet.status = nil
pet.photo_urls = nil
pet.tags = []
expected = {id: 1, name: '', tags: []}
expect(api_client.object_to_hash(pet)).to eq(expected)
# uncomment below to test object_to_hash for model
#api_client = Petstore::ApiClient.new
#_model = Petstore::ModelName.new
# update the model attribute below
#_model.id = 1
# update the expected value (hash) below
#expected = {id: 1, name: '', tags: []}
#expect(api_client.object_to_hash(_model)).to eq(expected)
end
end

View File

@ -1,10 +1,10 @@
=begin
#Swagger Petstore */ ' \" =end
#Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;end
Contact: apiteam@swagger.io */ ' \" =end
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");
@ -27,21 +27,26 @@ describe Petstore::Configuration do
let(:config) { Petstore::Configuration.default }
before(:each) do
Petstore.configure do |c|
c.host = 'petstore.swagger.io'
c.base_path = 'v2'
end
# uncomment below to setup host and base_path
#require 'URI'
#uri = URI.parse("https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r")
#Petstore.configure do |c|
# c.host = uri.host
# c.base_path = uri.path
#end
end
describe '#base_url' do
it 'should have the default value' do
expect(config.base_url).to eq('http://petstore.swagger.io/v2')
# uncomment below to test default value of the base path
#expect(config.base_url).to eq("https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r")
end
it 'should remove trailing slashes' do
[nil, '', '/', '//'].each do |base_path|
config.base_path = base_path
expect(config.base_url).to eq('http://petstore.swagger.io')
# uncomment below to test trailing slashes
#expect(config.base_url).to eq("https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r")
end
end
end

View File

@ -1,10 +1,10 @@
=begin
#Swagger Petstore */ ' \" =end
#Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;end
Contact: apiteam@swagger.io */ ' \" =end
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,10 +1,10 @@
=begin
#Swagger Petstore */ ' \" =end
#Swagger Petstore */ ' \" =_end -- \\r\\n \\n \\r
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =end
#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ */ ' \" =_end --
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;end
Contact: apiteam@swagger.io */ ' \" =end
OpenAPI spec version: 1.0.0 */ &#39; \&quot; &#x3D;_end -- \\r\\n \\n \\r
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
Generated by: https://github.com/swagger-api/swagger-codegen.git
Licensed under the Apache License, Version 2.0 (the "License");