mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-04 14:40:53 +00:00
Merge pull request #3368 from wing328/ruby_fix_rspec
[Ruby] fix default rspec test cases for Ruby API client
This commit is contained in:
commit
2d35743b0d
@ -43,53 +43,6 @@ describe {{moduleName}}::ApiClient do
|
|||||||
end
|
end
|
||||||
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
|
describe "params_encoding in #build_request" do
|
||||||
let(:config) { {{moduleName}}::Configuration.new }
|
let(:config) { {{moduleName}}::Configuration.new }
|
||||||
let(:api_client) { {{moduleName}}::ApiClient.new(config) }
|
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 be_instance_of(Hash)
|
||||||
expect(data).to eq({:message => 'Hello'})
|
expect(data).to eq({:message => 'Hello'})
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "#object_to_hash" do
|
describe "#object_to_hash" do
|
||||||
it "ignores nils and includes empty arrays" do
|
it "ignores nils and includes empty arrays" do
|
||||||
api_client = {{moduleName}}::ApiClient.new
|
# uncomment below to test object_to_hash for model
|
||||||
pet = {{moduleName}}::Pet.new
|
#api_client = {{moduleName}}::ApiClient.new
|
||||||
pet.id = 1
|
#_model = {{moduleName}}::ModelName.new
|
||||||
pet.name = ''
|
# update the model attribute below
|
||||||
pet.status = nil
|
#_model.id = 1
|
||||||
pet.photo_urls = nil
|
# update the expected value (hash) below
|
||||||
pet.tags = []
|
#expected = {id: 1, name: '', tags: []}
|
||||||
expected = {id: 1, name: '', tags: []}
|
#expect(api_client.object_to_hash(_model)).to eq(expected)
|
||||||
expect(api_client.object_to_hash(pet)).to eq(expected)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -8,21 +8,26 @@ describe {{moduleName}}::Configuration do
|
|||||||
let(:config) { {{moduleName}}::Configuration.default }
|
let(:config) { {{moduleName}}::Configuration.default }
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
{{moduleName}}.configure do |c|
|
# uncomment below to setup host and base_path
|
||||||
c.host = 'petstore.swagger.io'
|
#require 'URI'
|
||||||
c.base_path = 'v2'
|
#uri = URI.parse("{{{basePath}}}")
|
||||||
end
|
#{{moduleName}}.configure do |c|
|
||||||
|
# c.host = uri.host
|
||||||
|
# c.base_path = uri.path
|
||||||
|
#end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#base_url' do
|
describe '#base_url' do
|
||||||
it 'should have the default value' 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
|
end
|
||||||
|
|
||||||
it 'should remove trailing slashes' do
|
it 'should remove trailing slashes' do
|
||||||
[nil, '', '/', '//'].each do |base_path|
|
[nil, '', '/', '//'].each do |base_path|
|
||||||
config.base_path = 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
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
# petstore
|
# petstore
|
||||||
|
|
||||||
Petstore - the Ruby gem for the Swagger Petstore */ ' \"
|
Petstore - the Ruby gem for the 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 --
|
||||||
|
|
||||||
This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
|
This SDK is automatically generated by the [Swagger Codegen](https://github.com/swagger-api/swagger-codegen) project:
|
||||||
|
|
||||||
- API version: 1.0.0 */ ' \"
|
- API version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
- Package version: 1.0.0
|
- 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
|
- Build package: class io.swagger.codegen.languages.RubyClientCodegen
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
@ -58,25 +58,25 @@ require 'petstore'
|
|||||||
api_instance = Petstore::FakeApi.new
|
api_instance = Petstore::FakeApi.new
|
||||||
|
|
||||||
opts = {
|
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
|
begin
|
||||||
#To test code injection */ ' \"
|
#To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
api_instance.test_code_inject____end(opts)
|
api_instance.test_code_inject____end__rn_n_r(opts)
|
||||||
rescue Petstore::ApiError => e
|
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
|
end
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Documentation for API Endpoints
|
## Documentation for API Endpoints
|
||||||
|
|
||||||
All URIs are relative to *https://petstore.swagger.io */ ' " =end/v2 */ ' " =end*
|
All URIs are relative to *https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r*
|
||||||
|
|
||||||
Class | Method | HTTP request | Description
|
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
|
## Documentation for Models
|
||||||
@ -90,7 +90,7 @@ Class | Method | HTTP request | Description
|
|||||||
### api_key
|
### api_key
|
||||||
|
|
||||||
- **Type**: API key
|
- **Type**: API key
|
||||||
- **API key parameter name**: api_key */ ' " =end
|
- **API key parameter name**: api_key */ ' " =end -- \r\n \n \r
|
||||||
- **Location**: HTTP header
|
- **Location**: HTTP header
|
||||||
|
|
||||||
### petstore_auth
|
### petstore_auth
|
||||||
@ -99,6 +99,6 @@ Class | Method | HTTP request | Description
|
|||||||
- **Flow**: implicit
|
- **Flow**: implicit
|
||||||
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
- **Authorization URL**: http://petstore.swagger.io/api/oauth/dialog
|
||||||
- **Scopes**:
|
- **Scopes**:
|
||||||
- write:pets: modify pets in your account */ ' " =end
|
- write:pets: modify pets in your account */ ' " =end -- \r\n \n \r
|
||||||
- read:pets: read your pets */ ' " =end
|
- read:pets: read your pets */ ' " =end -- \r\n \n \r
|
||||||
|
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
# Petstore::FakeApi
|
# Petstore::FakeApi
|
||||||
|
|
||||||
All URIs are relative to *https://petstore.swagger.io */ ' " =end/v2 */ ' " =end*
|
All URIs are relative to *https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r*
|
||||||
|
|
||||||
Method | HTTP request | Description
|
Method | HTTP request | Description
|
||||||
------------- | ------------- | -------------
|
------------- | ------------- | -------------
|
||||||
[**test_code_inject____end**](FakeApi.md#test_code_inject____end) | **PUT** /fake | To test code injection */ ' \"
|
[**test_code_inject____end__rn_n_r**](FakeApi.md#test_code_inject____end__rn_n_r) | **PUT** /fake | To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
|
|
||||||
|
|
||||||
# **test_code_inject____end**
|
# **test_code_inject____end__rn_n_r**
|
||||||
> test_code_inject____end(opts)
|
> test_code_inject____end__rn_n_r(opts)
|
||||||
|
|
||||||
To test code injection */ ' \"
|
To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
```ruby
|
```ruby
|
||||||
@ -20,14 +20,14 @@ require 'petstore'
|
|||||||
api_instance = Petstore::FakeApi.new
|
api_instance = Petstore::FakeApi.new
|
||||||
|
|
||||||
opts = {
|
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
|
begin
|
||||||
#To test code injection */ ' \"
|
#To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
api_instance.test_code_inject____end(opts)
|
api_instance.test_code_inject____end__rn_n_r(opts)
|
||||||
rescue Petstore::ApiError => e
|
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
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ end
|
|||||||
|
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------- | ------------- | ------------- | -------------
|
------------- | ------------- | ------------- | -------------
|
||||||
**test_code_inject____end** | **String**| To test code injection */ ' \" | [optional]
|
**test_code_inject____end____rn_n_r** | **String**| To test code injection */ ' \" =_end -- \\r\\n \\n \\r | [optional]
|
||||||
|
|
||||||
### Return type
|
### Return type
|
||||||
|
|
||||||
@ -47,8 +47,8 @@ No authorization required
|
|||||||
|
|
||||||
### HTTP request headers
|
### HTTP request headers
|
||||||
|
|
||||||
- **Content-Type**: application/json, */ " =end
|
- **Content-Type**: application/json, */ \" =_end --
|
||||||
- **Accept**: application/json, */ " =end
|
- **Accept**: application/json, */ \" =_end --
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,6 @@
|
|||||||
## Properties
|
## Properties
|
||||||
Name | Type | Description | Notes
|
Name | Type | Description | Notes
|
||||||
------------ | ------------- | ------------- | -------------
|
------------ | ------------- | ------------- | -------------
|
||||||
**_return** | **Integer** | property description */ ' \" | [optional]
|
**_return** | **Integer** | property description */ ' \" =_end -- \\r\\n \\n \\r | [optional]
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
=begin
|
=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 */ ' \"
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \"
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
=begin
|
=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 */ ' \"
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \"
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -31,24 +31,24 @@ module Petstore
|
|||||||
@api_client = api_client
|
@api_client = api_client
|
||||||
end
|
end
|
||||||
|
|
||||||
# To test code injection */ ' \"
|
# To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
#
|
#
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @option opts [String] :test_code_inject____end To test code injection */ ' \"
|
# @option opts [String] :test_code_inject____end____rn_n_r To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
# @return [nil]
|
# @return [nil]
|
||||||
def test_code_inject____end(opts = {})
|
def test_code_inject____end__rn_n_r(opts = {})
|
||||||
test_code_inject____end_with_http_info(opts)
|
test_code_inject____end__rn_n_r_with_http_info(opts)
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# To test code injection */ ' \"
|
# To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
#
|
#
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @option opts [String] :test_code_inject____end To test code injection */ ' \"
|
# @option opts [String] :test_code_inject____end____rn_n_r To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
# @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
|
# @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
|
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
|
end
|
||||||
# resource path
|
# resource path
|
||||||
local_var_path = "/fake".sub('{format}','json')
|
local_var_path = "/fake".sub('{format}','json')
|
||||||
@ -60,16 +60,16 @@ module Petstore
|
|||||||
header_params = {}
|
header_params = {}
|
||||||
|
|
||||||
# HTTP header 'Accept' (if needed)
|
# 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
|
local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result
|
||||||
|
|
||||||
# HTTP header 'Content-Type'
|
# 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)
|
header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)
|
||||||
|
|
||||||
# form parameters
|
# form parameters
|
||||||
form_params = {}
|
form_params = {}
|
||||||
form_params["test code inject */ ' " =end"] = opts[:'test_code_inject____end'] if !opts[:'test_code_inject____end'].nil?
|
form_params["test code inject */ ' " =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)
|
# http body (model)
|
||||||
post_body = nil
|
post_body = nil
|
||||||
@ -81,7 +81,7 @@ module Petstore
|
|||||||
:body => post_body,
|
:body => post_body,
|
||||||
:auth_names => auth_names)
|
:auth_names => auth_names)
|
||||||
if @api_client.config.debugging
|
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
|
end
|
||||||
return data, status_code, headers
|
return data, status_code, headers
|
||||||
end
|
end
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
=begin
|
=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 */ ' \"
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \"
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
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]
|
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 = {
|
req_opts = {
|
||||||
:method => http_method,
|
:method => http_method,
|
||||||
:headers => header_params,
|
:headers => header_params,
|
||||||
@ -106,11 +109,13 @@ module Petstore
|
|||||||
:params_encoding => @config.params_encoding,
|
:params_encoding => @config.params_encoding,
|
||||||
:timeout => @config.timeout,
|
:timeout => @config.timeout,
|
||||||
:ssl_verifypeer => @config.verify_ssl,
|
:ssl_verifypeer => @config.verify_ssl,
|
||||||
|
:ssl_verifyhost => _verify_ssl_host,
|
||||||
:sslcert => @config.cert_file,
|
:sslcert => @config.cert_file,
|
||||||
:sslkey => @config.key_file,
|
:sslkey => @config.key_file,
|
||||||
:verbose => @config.debugging
|
:verbose => @config.debugging
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# set custom cert, if provided
|
||||||
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
|
req_opts[:cainfo] = @config.ssl_ca_cert if @config.ssl_ca_cert
|
||||||
|
|
||||||
if [:post, :patch, :put, :delete].include?(http_method)
|
if [:post, :patch, :put, :delete].include?(http_method)
|
||||||
@ -216,7 +221,7 @@ module Petstore
|
|||||||
# @return [Tempfile] the file downloaded
|
# @return [Tempfile] the file downloaded
|
||||||
def download_file(response)
|
def download_file(response)
|
||||||
content_disposition = response.headers['Content-Disposition']
|
content_disposition = response.headers['Content-Disposition']
|
||||||
if content_disposition
|
if content_disposition and content_disposition =~ /filename=/i
|
||||||
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
|
||||||
prefix = sanitize_filename(filename)
|
prefix = sanitize_filename(filename)
|
||||||
else
|
else
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
=begin
|
=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 */ ' \"
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \"
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
=begin
|
=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 */ ' \"
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \"
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -87,7 +87,7 @@ module Petstore
|
|||||||
# Default to 0 (never times out).
|
# Default to 0 (never times out).
|
||||||
attr_accessor :timeout
|
attr_accessor :timeout
|
||||||
|
|
||||||
### TLS/SSL
|
### TLS/SSL setting
|
||||||
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
# Set this to false to skip verifying SSL certificate when calling API from https server.
|
||||||
# Default to true.
|
# Default to true.
|
||||||
#
|
#
|
||||||
@ -96,13 +96,16 @@ module Petstore
|
|||||||
# @return [true, false]
|
# @return [true, false]
|
||||||
attr_accessor :verify_ssl
|
attr_accessor :verify_ssl
|
||||||
|
|
||||||
# Set this to customize parameters encoding of array parameter with multi collectionFormat.
|
### TLS/SSL setting
|
||||||
# Default to nil.
|
# Set this to false to skip verifying SSL host name
|
||||||
|
# Default to true.
|
||||||
#
|
#
|
||||||
# @see The params_encoding option of Ethon. Related source code:
|
# @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
|
||||||
# https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
|
#
|
||||||
attr_accessor :params_encoding
|
# @return [true, false]
|
||||||
|
attr_accessor :verify_ssl_host
|
||||||
|
|
||||||
|
### TLS/SSL setting
|
||||||
# Set this to customize the certificate file to verify the peer.
|
# Set this to customize the certificate file to verify the peer.
|
||||||
#
|
#
|
||||||
# @return [String] the path to the certificate file
|
# @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
|
# https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
|
||||||
attr_accessor :ssl_ca_cert
|
attr_accessor :ssl_ca_cert
|
||||||
|
|
||||||
|
### TLS/SSL setting
|
||||||
# Client certificate file (for client certificate)
|
# Client certificate file (for client certificate)
|
||||||
attr_accessor :cert_file
|
attr_accessor :cert_file
|
||||||
|
|
||||||
|
### TLS/SSL setting
|
||||||
# Client private key file (for client certificate)
|
# Client private key file (for client certificate)
|
||||||
attr_accessor :key_file
|
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 :inject_format
|
||||||
|
|
||||||
attr_accessor :force_ending_format
|
attr_accessor :force_ending_format
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@scheme = 'https'
|
@scheme = 'https'
|
||||||
@host = 'petstore.swagger.io */ ' " =end'
|
@host = 'petstore.swagger.io */ ' " =end -- \r\n \n \r'
|
||||||
@base_path = '/v2 */ ' " =end'
|
@base_path = '/v2 */ ' \" =_end -- \\r\\n \\n \\r'
|
||||||
@api_key = {}
|
@api_key = {}
|
||||||
@api_key_prefix = {}
|
@api_key_prefix = {}
|
||||||
@timeout = 0
|
@timeout = 0
|
||||||
@verify_ssl = true
|
@verify_ssl = true
|
||||||
|
@verify_ssl_host = true
|
||||||
@params_encoding = nil
|
@params_encoding = nil
|
||||||
@cert_file = nil
|
@cert_file = nil
|
||||||
@key_file = nil
|
@key_file = nil
|
||||||
@ -192,8 +205,8 @@ module Petstore
|
|||||||
{
|
{
|
||||||
type: 'api_key',
|
type: 'api_key',
|
||||||
in: 'header',
|
in: 'header',
|
||||||
key: 'api_key */ ' " =end',
|
key: 'api_key */ ' " =end -- \r\n \n \r',
|
||||||
value: api_key_with_prefix('api_key */ ' " =end')
|
value: api_key_with_prefix('api_key */ ' " =end -- \r\n \n \r')
|
||||||
},
|
},
|
||||||
'petstore_auth' =>
|
'petstore_auth' =>
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
=begin
|
=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 */ ' \"
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \"
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -24,9 +24,9 @@ limitations under the License.
|
|||||||
require 'date'
|
require 'date'
|
||||||
|
|
||||||
module Petstore
|
module Petstore
|
||||||
# Model for testing reserved words */ ' \"
|
# Model for testing reserved words */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
class ModelReturn
|
class ModelReturn
|
||||||
# property description */ ' \"
|
# property description */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
attr_accessor :_return
|
attr_accessor :_return
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
=begin
|
=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 */ ' \"
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \"
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
#
|
#
|
||||||
=begin
|
=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 */ ' \"
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \"
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -31,11 +31,11 @@ Gem::Specification.new do |s|
|
|||||||
s.version = Petstore::VERSION
|
s.version = Petstore::VERSION
|
||||||
s.platform = Gem::Platform::RUBY
|
s.platform = Gem::Platform::RUBY
|
||||||
s.authors = ["Swagger-Codegen"]
|
s.authors = ["Swagger-Codegen"]
|
||||||
s.email = ["apiteam@swagger.io */ ' \" "]
|
s.email = ["apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r"]
|
||||||
s.homepage = "https://github.com/swagger-api/swagger-codegen"
|
s.homepage = "https://github.com/swagger-api/swagger-codegen"
|
||||||
s.summary = "Swagger Petstore */ ' \" Ruby Gem"
|
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: \" \\ */ ' \" "
|
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 */ ' \" "
|
s.license = "Apache 2.0 */ ' \" =_end -- \\r\\n \\n \\r"
|
||||||
|
|
||||||
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
||||||
s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3'
|
s.add_runtime_dependency 'json', '~> 1.8', '>= 1.8.3'
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
=begin
|
=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 */ ' \" =end
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \" =end
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -43,13 +43,13 @@ describe 'FakeApi' do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# unit tests for test_code_inject____end
|
# unit tests for test_code_inject____end__rn_n_r
|
||||||
# To test code injection */ ' \" =end
|
# To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
#
|
#
|
||||||
# @param [Hash] opts the optional parameters
|
# @param [Hash] opts the optional parameters
|
||||||
# @option opts [String] :test_code_inject____end To test code injection */ ' \" =end
|
# @option opts [String] :test_code_inject____end____rn_n_r To test code injection */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
# @return [nil]
|
# @return [nil]
|
||||||
describe 'test_code_inject____end test' do
|
describe 'test_code_inject____end__rn_n_r test' do
|
||||||
it "should work" do
|
it "should work" do
|
||||||
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
# assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
|
||||||
end
|
end
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
=begin
|
=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 */ ' \" =end
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \" =end
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -62,53 +62,6 @@ describe Petstore::ApiClient do
|
|||||||
end
|
end
|
||||||
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
|
describe "params_encoding in #build_request" do
|
||||||
let(:config) { Petstore::Configuration.new }
|
let(:config) { Petstore::Configuration.new }
|
||||||
let(:api_client) { Petstore::ApiClient.new(config) }
|
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 be_instance_of(Hash)
|
||||||
expect(data).to eq({:message => 'Hello'})
|
expect(data).to eq({:message => 'Hello'})
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
describe "#object_to_hash" do
|
describe "#object_to_hash" do
|
||||||
it "ignores nils and includes empty arrays" do
|
it "ignores nils and includes empty arrays" do
|
||||||
api_client = Petstore::ApiClient.new
|
# uncomment below to test object_to_hash for model
|
||||||
pet = Petstore::Pet.new
|
#api_client = Petstore::ApiClient.new
|
||||||
pet.id = 1
|
#_model = Petstore::ModelName.new
|
||||||
pet.name = ''
|
# update the model attribute below
|
||||||
pet.status = nil
|
#_model.id = 1
|
||||||
pet.photo_urls = nil
|
# update the expected value (hash) below
|
||||||
pet.tags = []
|
#expected = {id: 1, name: '', tags: []}
|
||||||
expected = {id: 1, name: '', tags: []}
|
#expect(api_client.object_to_hash(_model)).to eq(expected)
|
||||||
expect(api_client.object_to_hash(pet)).to eq(expected)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
=begin
|
=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 */ ' \" =end
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \" =end
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
@ -27,21 +27,26 @@ describe Petstore::Configuration do
|
|||||||
let(:config) { Petstore::Configuration.default }
|
let(:config) { Petstore::Configuration.default }
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
Petstore.configure do |c|
|
# uncomment below to setup host and base_path
|
||||||
c.host = 'petstore.swagger.io'
|
#require 'URI'
|
||||||
c.base_path = 'v2'
|
#uri = URI.parse("https://petstore.swagger.io */ ' \" =_end -- \\r\\n \\n \\r/v2 */ ' \" =_end -- \\r\\n \\n \\r")
|
||||||
end
|
#Petstore.configure do |c|
|
||||||
|
# c.host = uri.host
|
||||||
|
# c.base_path = uri.path
|
||||||
|
#end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#base_url' do
|
describe '#base_url' do
|
||||||
it 'should have the default value' 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
|
end
|
||||||
|
|
||||||
it 'should remove trailing slashes' do
|
it 'should remove trailing slashes' do
|
||||||
[nil, '', '/', '//'].each do |base_path|
|
[nil, '', '/', '//'].each do |base_path|
|
||||||
config.base_path = 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
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
=begin
|
=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 */ ' \" =end
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \" =end
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
=begin
|
=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 */ ' \" =end
|
OpenAPI spec version: 1.0.0 */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Contact: apiteam@swagger.io */ ' \" =end
|
Contact: apiteam@swagger.io */ ' \" =_end -- \\r\\n \\n \\r
|
||||||
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user