forked from loafle/openapi-generator-original
[Ruby] Add Flag to Allow Ignoring Operation Servers (#18934)
* [Ruby] Add Flag to Allow Ignoring Operation Servers * update samples * add tests * fix tests
This commit is contained in:
parent
5bc7aa3cd6
commit
9919c23267
@ -71,6 +71,14 @@ module {{moduleName}}
|
|||||||
# @return [true, false]
|
# @return [true, false]
|
||||||
attr_accessor :debugging
|
attr_accessor :debugging
|
||||||
|
|
||||||
|
# Set this to ignore operation servers for the API client. This is useful when you need to
|
||||||
|
# send requests to a different server than the one specified in the OpenAPI document.
|
||||||
|
# Will default to the base url defined in the spec but can be overridden by setting
|
||||||
|
# `scheme`, `host`, `base_path` directly.
|
||||||
|
# Default to false.
|
||||||
|
# @return [true, false]
|
||||||
|
attr_accessor :ignore_operation_servers
|
||||||
|
|
||||||
# Defines the logger used for debugging.
|
# Defines the logger used for debugging.
|
||||||
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
||||||
#
|
#
|
||||||
@ -146,6 +154,7 @@ module {{moduleName}}
|
|||||||
@configure_session_blocks = []
|
@configure_session_blocks = []
|
||||||
{{/isHttpx}}
|
{{/isHttpx}}
|
||||||
@debugging = false
|
@debugging = false
|
||||||
|
@ignore_operation_servers = false
|
||||||
@inject_format = false
|
@inject_format = false
|
||||||
@force_ending_format = false
|
@force_ending_format = false
|
||||||
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
||||||
@ -180,6 +189,7 @@ module {{moduleName}}
|
|||||||
|
|
||||||
# Returns base URL for specified operation based on server settings
|
# Returns base URL for specified operation based on server settings
|
||||||
def base_url(operation = nil)
|
def base_url(operation = nil)
|
||||||
|
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
|
||||||
if operation_server_settings.key?(operation) then
|
if operation_server_settings.key?(operation) then
|
||||||
index = server_operation_index.fetch(operation, server_index)
|
index = server_operation_index.fetch(operation, server_index)
|
||||||
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
||||||
|
@ -79,6 +79,14 @@ module OpenapiClient
|
|||||||
# @return [true, false]
|
# @return [true, false]
|
||||||
attr_accessor :debugging
|
attr_accessor :debugging
|
||||||
|
|
||||||
|
# Set this to ignore operation servers for the API client. This is useful when you need to
|
||||||
|
# send requests to a different server than the one specified in the OpenAPI document.
|
||||||
|
# Will default to the base url defined in the spec but can be overridden by setting
|
||||||
|
# `scheme`, `host`, `base_path` directly.
|
||||||
|
# Default to false.
|
||||||
|
# @return [true, false]
|
||||||
|
attr_accessor :ignore_operation_servers
|
||||||
|
|
||||||
# Defines the logger used for debugging.
|
# Defines the logger used for debugging.
|
||||||
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
||||||
#
|
#
|
||||||
@ -170,6 +178,7 @@ module OpenapiClient
|
|||||||
@return_binary_data = false
|
@return_binary_data = false
|
||||||
@params_encoder = nil
|
@params_encoder = nil
|
||||||
@debugging = false
|
@debugging = false
|
||||||
|
@ignore_operation_servers = false
|
||||||
@inject_format = false
|
@inject_format = false
|
||||||
@force_ending_format = false
|
@force_ending_format = false
|
||||||
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
||||||
@ -204,6 +213,7 @@ module OpenapiClient
|
|||||||
|
|
||||||
# Returns base URL for specified operation based on server settings
|
# Returns base URL for specified operation based on server settings
|
||||||
def base_url(operation = nil)
|
def base_url(operation = nil)
|
||||||
|
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
|
||||||
if operation_server_settings.key?(operation) then
|
if operation_server_settings.key?(operation) then
|
||||||
index = server_operation_index.fetch(operation, server_index)
|
index = server_operation_index.fetch(operation, server_index)
|
||||||
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
||||||
|
@ -79,6 +79,14 @@ module OpenapiClient
|
|||||||
# @return [true, false]
|
# @return [true, false]
|
||||||
attr_accessor :debugging
|
attr_accessor :debugging
|
||||||
|
|
||||||
|
# Set this to ignore operation servers for the API client. This is useful when you need to
|
||||||
|
# send requests to a different server than the one specified in the OpenAPI document.
|
||||||
|
# Will default to the base url defined in the spec but can be overridden by setting
|
||||||
|
# `scheme`, `host`, `base_path` directly.
|
||||||
|
# Default to false.
|
||||||
|
# @return [true, false]
|
||||||
|
attr_accessor :ignore_operation_servers
|
||||||
|
|
||||||
# Defines the logger used for debugging.
|
# Defines the logger used for debugging.
|
||||||
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
||||||
#
|
#
|
||||||
@ -134,6 +142,7 @@ module OpenapiClient
|
|||||||
@timeout = 60
|
@timeout = 60
|
||||||
@configure_session_blocks = []
|
@configure_session_blocks = []
|
||||||
@debugging = false
|
@debugging = false
|
||||||
|
@ignore_operation_servers = false
|
||||||
@inject_format = false
|
@inject_format = false
|
||||||
@force_ending_format = false
|
@force_ending_format = false
|
||||||
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
||||||
@ -168,6 +177,7 @@ module OpenapiClient
|
|||||||
|
|
||||||
# Returns base URL for specified operation based on server settings
|
# Returns base URL for specified operation based on server settings
|
||||||
def base_url(operation = nil)
|
def base_url(operation = nil)
|
||||||
|
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
|
||||||
if operation_server_settings.key?(operation) then
|
if operation_server_settings.key?(operation) then
|
||||||
index = server_operation_index.fetch(operation, server_index)
|
index = server_operation_index.fetch(operation, server_index)
|
||||||
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
||||||
|
@ -79,6 +79,14 @@ module OpenapiClient
|
|||||||
# @return [true, false]
|
# @return [true, false]
|
||||||
attr_accessor :debugging
|
attr_accessor :debugging
|
||||||
|
|
||||||
|
# Set this to ignore operation servers for the API client. This is useful when you need to
|
||||||
|
# send requests to a different server than the one specified in the OpenAPI document.
|
||||||
|
# Will default to the base url defined in the spec but can be overridden by setting
|
||||||
|
# `scheme`, `host`, `base_path` directly.
|
||||||
|
# Default to false.
|
||||||
|
# @return [true, false]
|
||||||
|
attr_accessor :ignore_operation_servers
|
||||||
|
|
||||||
# Defines the logger used for debugging.
|
# Defines the logger used for debugging.
|
||||||
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
||||||
#
|
#
|
||||||
@ -166,6 +174,7 @@ module OpenapiClient
|
|||||||
@timeout = 0
|
@timeout = 0
|
||||||
@params_encoding = nil
|
@params_encoding = nil
|
||||||
@debugging = false
|
@debugging = false
|
||||||
|
@ignore_operation_servers = false
|
||||||
@inject_format = false
|
@inject_format = false
|
||||||
@force_ending_format = false
|
@force_ending_format = false
|
||||||
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
||||||
@ -200,6 +209,7 @@ module OpenapiClient
|
|||||||
|
|
||||||
# Returns base URL for specified operation based on server settings
|
# Returns base URL for specified operation based on server settings
|
||||||
def base_url(operation = nil)
|
def base_url(operation = nil)
|
||||||
|
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
|
||||||
if operation_server_settings.key?(operation) then
|
if operation_server_settings.key?(operation) then
|
||||||
index = server_operation_index.fetch(operation, server_index)
|
index = server_operation_index.fetch(operation, server_index)
|
||||||
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
||||||
|
@ -79,6 +79,14 @@ module Petstore
|
|||||||
# @return [true, false]
|
# @return [true, false]
|
||||||
attr_accessor :debugging
|
attr_accessor :debugging
|
||||||
|
|
||||||
|
# Set this to ignore operation servers for the API client. This is useful when you need to
|
||||||
|
# send requests to a different server than the one specified in the OpenAPI document.
|
||||||
|
# Will default to the base url defined in the spec but can be overridden by setting
|
||||||
|
# `scheme`, `host`, `base_path` directly.
|
||||||
|
# Default to false.
|
||||||
|
# @return [true, false]
|
||||||
|
attr_accessor :ignore_operation_servers
|
||||||
|
|
||||||
# Defines the logger used for debugging.
|
# Defines the logger used for debugging.
|
||||||
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
||||||
#
|
#
|
||||||
@ -166,6 +174,7 @@ module Petstore
|
|||||||
@timeout = 0
|
@timeout = 0
|
||||||
@params_encoding = nil
|
@params_encoding = nil
|
||||||
@debugging = false
|
@debugging = false
|
||||||
|
@ignore_operation_servers = false
|
||||||
@inject_format = false
|
@inject_format = false
|
||||||
@force_ending_format = false
|
@force_ending_format = false
|
||||||
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
||||||
@ -200,6 +209,7 @@ module Petstore
|
|||||||
|
|
||||||
# Returns base URL for specified operation based on server settings
|
# Returns base URL for specified operation based on server settings
|
||||||
def base_url(operation = nil)
|
def base_url(operation = nil)
|
||||||
|
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
|
||||||
if operation_server_settings.key?(operation) then
|
if operation_server_settings.key?(operation) then
|
||||||
index = server_operation_index.fetch(operation, server_index)
|
index = server_operation_index.fetch(operation, server_index)
|
||||||
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
||||||
|
@ -79,6 +79,14 @@ module Petstore
|
|||||||
# @return [true, false]
|
# @return [true, false]
|
||||||
attr_accessor :debugging
|
attr_accessor :debugging
|
||||||
|
|
||||||
|
# Set this to ignore operation servers for the API client. This is useful when you need to
|
||||||
|
# send requests to a different server than the one specified in the OpenAPI document.
|
||||||
|
# Will default to the base url defined in the spec but can be overridden by setting
|
||||||
|
# `scheme`, `host`, `base_path` directly.
|
||||||
|
# Default to false.
|
||||||
|
# @return [true, false]
|
||||||
|
attr_accessor :ignore_operation_servers
|
||||||
|
|
||||||
# Defines the logger used for debugging.
|
# Defines the logger used for debugging.
|
||||||
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
||||||
#
|
#
|
||||||
@ -170,6 +178,7 @@ module Petstore
|
|||||||
@return_binary_data = false
|
@return_binary_data = false
|
||||||
@params_encoder = nil
|
@params_encoder = nil
|
||||||
@debugging = false
|
@debugging = false
|
||||||
|
@ignore_operation_servers = false
|
||||||
@inject_format = false
|
@inject_format = false
|
||||||
@force_ending_format = false
|
@force_ending_format = false
|
||||||
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
||||||
@ -204,6 +213,7 @@ module Petstore
|
|||||||
|
|
||||||
# Returns base URL for specified operation based on server settings
|
# Returns base URL for specified operation based on server settings
|
||||||
def base_url(operation = nil)
|
def base_url(operation = nil)
|
||||||
|
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
|
||||||
if operation_server_settings.key?(operation) then
|
if operation_server_settings.key?(operation) then
|
||||||
index = server_operation_index.fetch(operation, server_index)
|
index = server_operation_index.fetch(operation, server_index)
|
||||||
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
||||||
|
@ -55,6 +55,15 @@ describe Petstore::Configuration do
|
|||||||
expect(config.base_url).to eq('https://localhost:8080/v2')
|
expect(config.base_url).to eq('https://localhost:8080/v2')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'ignores the operation server settings and uses the custom base url' do
|
||||||
|
config.scheme = 'https'
|
||||||
|
config.host = 'api.example.com'
|
||||||
|
config.base_path = '/v2'
|
||||||
|
config.ignore_operation_servers = true
|
||||||
|
expect(config.base_url).to eq('https://api.example.com/v2')
|
||||||
|
expect(config.base_url(:'PetApi.add_pet')).to eq('https://api.example.com/v2')
|
||||||
|
end
|
||||||
|
|
||||||
it 'throws argument error when attempting to use a server index that is out of bounds' do
|
it 'throws argument error when attempting to use a server index that is out of bounds' do
|
||||||
config.server_operation_index = {
|
config.server_operation_index = {
|
||||||
:'PetApi.add_pet' => 10
|
:'PetApi.add_pet' => 10
|
||||||
|
@ -79,6 +79,14 @@ module Petstore
|
|||||||
# @return [true, false]
|
# @return [true, false]
|
||||||
attr_accessor :debugging
|
attr_accessor :debugging
|
||||||
|
|
||||||
|
# Set this to ignore operation servers for the API client. This is useful when you need to
|
||||||
|
# send requests to a different server than the one specified in the OpenAPI document.
|
||||||
|
# Will default to the base url defined in the spec but can be overridden by setting
|
||||||
|
# `scheme`, `host`, `base_path` directly.
|
||||||
|
# Default to false.
|
||||||
|
# @return [true, false]
|
||||||
|
attr_accessor :ignore_operation_servers
|
||||||
|
|
||||||
# Defines the logger used for debugging.
|
# Defines the logger used for debugging.
|
||||||
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
||||||
#
|
#
|
||||||
@ -134,6 +142,7 @@ module Petstore
|
|||||||
@timeout = 60
|
@timeout = 60
|
||||||
@configure_session_blocks = []
|
@configure_session_blocks = []
|
||||||
@debugging = false
|
@debugging = false
|
||||||
|
@ignore_operation_servers = false
|
||||||
@inject_format = false
|
@inject_format = false
|
||||||
@force_ending_format = false
|
@force_ending_format = false
|
||||||
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
||||||
@ -168,6 +177,7 @@ module Petstore
|
|||||||
|
|
||||||
# Returns base URL for specified operation based on server settings
|
# Returns base URL for specified operation based on server settings
|
||||||
def base_url(operation = nil)
|
def base_url(operation = nil)
|
||||||
|
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
|
||||||
if operation_server_settings.key?(operation) then
|
if operation_server_settings.key?(operation) then
|
||||||
index = server_operation_index.fetch(operation, server_index)
|
index = server_operation_index.fetch(operation, server_index)
|
||||||
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
||||||
|
@ -79,6 +79,14 @@ module Petstore
|
|||||||
# @return [true, false]
|
# @return [true, false]
|
||||||
attr_accessor :debugging
|
attr_accessor :debugging
|
||||||
|
|
||||||
|
# Set this to ignore operation servers for the API client. This is useful when you need to
|
||||||
|
# send requests to a different server than the one specified in the OpenAPI document.
|
||||||
|
# Will default to the base url defined in the spec but can be overridden by setting
|
||||||
|
# `scheme`, `host`, `base_path` directly.
|
||||||
|
# Default to false.
|
||||||
|
# @return [true, false]
|
||||||
|
attr_accessor :ignore_operation_servers
|
||||||
|
|
||||||
# Defines the logger used for debugging.
|
# Defines the logger used for debugging.
|
||||||
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
||||||
#
|
#
|
||||||
@ -166,6 +174,7 @@ module Petstore
|
|||||||
@timeout = 0
|
@timeout = 0
|
||||||
@params_encoding = nil
|
@params_encoding = nil
|
||||||
@debugging = false
|
@debugging = false
|
||||||
|
@ignore_operation_servers = false
|
||||||
@inject_format = false
|
@inject_format = false
|
||||||
@force_ending_format = false
|
@force_ending_format = false
|
||||||
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
||||||
@ -200,6 +209,7 @@ module Petstore
|
|||||||
|
|
||||||
# Returns base URL for specified operation based on server settings
|
# Returns base URL for specified operation based on server settings
|
||||||
def base_url(operation = nil)
|
def base_url(operation = nil)
|
||||||
|
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
|
||||||
if operation_server_settings.key?(operation) then
|
if operation_server_settings.key?(operation) then
|
||||||
index = server_operation_index.fetch(operation, server_index)
|
index = server_operation_index.fetch(operation, server_index)
|
||||||
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
||||||
|
@ -55,6 +55,15 @@ describe Petstore::Configuration do
|
|||||||
expect(config.base_url).to eq('https://localhost:8080/v2')
|
expect(config.base_url).to eq('https://localhost:8080/v2')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'ignores the operation server settings and uses the custom base url' do
|
||||||
|
config.scheme = 'https'
|
||||||
|
config.host = 'api.example.com'
|
||||||
|
config.base_path = '/v2'
|
||||||
|
config.ignore_operation_servers = true
|
||||||
|
expect(config.base_url).to eq('https://api.example.com/v2')
|
||||||
|
expect(config.base_url(:'PetApi.add_pet')).to eq('https://api.example.com/v2')
|
||||||
|
end
|
||||||
|
|
||||||
it 'throws argument error when attempting to use a server index that is out of bounds' do
|
it 'throws argument error when attempting to use a server index that is out of bounds' do
|
||||||
config.server_operation_index = {
|
config.server_operation_index = {
|
||||||
:'PetApi.add_pet' => 10
|
:'PetApi.add_pet' => 10
|
||||||
|
@ -79,6 +79,14 @@ module XAuthIDAlias
|
|||||||
# @return [true, false]
|
# @return [true, false]
|
||||||
attr_accessor :debugging
|
attr_accessor :debugging
|
||||||
|
|
||||||
|
# Set this to ignore operation servers for the API client. This is useful when you need to
|
||||||
|
# send requests to a different server than the one specified in the OpenAPI document.
|
||||||
|
# Will default to the base url defined in the spec but can be overridden by setting
|
||||||
|
# `scheme`, `host`, `base_path` directly.
|
||||||
|
# Default to false.
|
||||||
|
# @return [true, false]
|
||||||
|
attr_accessor :ignore_operation_servers
|
||||||
|
|
||||||
# Defines the logger used for debugging.
|
# Defines the logger used for debugging.
|
||||||
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
||||||
#
|
#
|
||||||
@ -166,6 +174,7 @@ module XAuthIDAlias
|
|||||||
@timeout = 0
|
@timeout = 0
|
||||||
@params_encoding = nil
|
@params_encoding = nil
|
||||||
@debugging = false
|
@debugging = false
|
||||||
|
@ignore_operation_servers = false
|
||||||
@inject_format = false
|
@inject_format = false
|
||||||
@force_ending_format = false
|
@force_ending_format = false
|
||||||
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
||||||
@ -200,6 +209,7 @@ module XAuthIDAlias
|
|||||||
|
|
||||||
# Returns base URL for specified operation based on server settings
|
# Returns base URL for specified operation based on server settings
|
||||||
def base_url(operation = nil)
|
def base_url(operation = nil)
|
||||||
|
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
|
||||||
if operation_server_settings.key?(operation) then
|
if operation_server_settings.key?(operation) then
|
||||||
index = server_operation_index.fetch(operation, server_index)
|
index = server_operation_index.fetch(operation, server_index)
|
||||||
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
||||||
|
@ -79,6 +79,14 @@ module DynamicServers
|
|||||||
# @return [true, false]
|
# @return [true, false]
|
||||||
attr_accessor :debugging
|
attr_accessor :debugging
|
||||||
|
|
||||||
|
# Set this to ignore operation servers for the API client. This is useful when you need to
|
||||||
|
# send requests to a different server than the one specified in the OpenAPI document.
|
||||||
|
# Will default to the base url defined in the spec but can be overridden by setting
|
||||||
|
# `scheme`, `host`, `base_path` directly.
|
||||||
|
# Default to false.
|
||||||
|
# @return [true, false]
|
||||||
|
attr_accessor :ignore_operation_servers
|
||||||
|
|
||||||
# Defines the logger used for debugging.
|
# Defines the logger used for debugging.
|
||||||
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
||||||
#
|
#
|
||||||
@ -166,6 +174,7 @@ module DynamicServers
|
|||||||
@timeout = 0
|
@timeout = 0
|
||||||
@params_encoding = nil
|
@params_encoding = nil
|
||||||
@debugging = false
|
@debugging = false
|
||||||
|
@ignore_operation_servers = false
|
||||||
@inject_format = false
|
@inject_format = false
|
||||||
@force_ending_format = false
|
@force_ending_format = false
|
||||||
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
||||||
@ -200,6 +209,7 @@ module DynamicServers
|
|||||||
|
|
||||||
# Returns base URL for specified operation based on server settings
|
# Returns base URL for specified operation based on server settings
|
||||||
def base_url(operation = nil)
|
def base_url(operation = nil)
|
||||||
|
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
|
||||||
if operation_server_settings.key?(operation) then
|
if operation_server_settings.key?(operation) then
|
||||||
index = server_operation_index.fetch(operation, server_index)
|
index = server_operation_index.fetch(operation, server_index)
|
||||||
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
||||||
|
@ -79,6 +79,14 @@ module Petstore
|
|||||||
# @return [true, false]
|
# @return [true, false]
|
||||||
attr_accessor :debugging
|
attr_accessor :debugging
|
||||||
|
|
||||||
|
# Set this to ignore operation servers for the API client. This is useful when you need to
|
||||||
|
# send requests to a different server than the one specified in the OpenAPI document.
|
||||||
|
# Will default to the base url defined in the spec but can be overridden by setting
|
||||||
|
# `scheme`, `host`, `base_path` directly.
|
||||||
|
# Default to false.
|
||||||
|
# @return [true, false]
|
||||||
|
attr_accessor :ignore_operation_servers
|
||||||
|
|
||||||
# Defines the logger used for debugging.
|
# Defines the logger used for debugging.
|
||||||
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
# Default to `Rails.logger` (when in Rails) or logging to STDOUT.
|
||||||
#
|
#
|
||||||
@ -166,6 +174,7 @@ module Petstore
|
|||||||
@timeout = 0
|
@timeout = 0
|
||||||
@params_encoding = nil
|
@params_encoding = nil
|
||||||
@debugging = false
|
@debugging = false
|
||||||
|
@ignore_operation_servers = false
|
||||||
@inject_format = false
|
@inject_format = false
|
||||||
@force_ending_format = false
|
@force_ending_format = false
|
||||||
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
||||||
@ -200,6 +209,7 @@ module Petstore
|
|||||||
|
|
||||||
# Returns base URL for specified operation based on server settings
|
# Returns base URL for specified operation based on server settings
|
||||||
def base_url(operation = nil)
|
def base_url(operation = nil)
|
||||||
|
return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
|
||||||
if operation_server_settings.key?(operation) then
|
if operation_server_settings.key?(operation) then
|
||||||
index = server_operation_index.fetch(operation, server_index)
|
index = server_operation_index.fetch(operation, server_index)
|
||||||
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
|
||||||
|
Loading…
x
Reference in New Issue
Block a user