Module: Scorpio::OpenAPI::V2::Document::Configurables

Included in:
Scorpio::OpenAPI::V2::Document
Defined in:
lib/scorpio/openapi/document.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#base_url(scheme: self.scheme, server: nil, server_variables: nil) ⇒ Object

the base url to which paths are appended. by default this looks at the openapi document's schemes, picking https or http first. it looks at the openapi_document's host and basePath.



159
160
161
162
163
164
165
166
167
168
# File 'lib/scorpio/openapi/document.rb', line 159

def base_url(scheme: self.scheme, server: nil, server_variables: nil)
  return @base_url if instance_variable_defined?(:@base_url)
  if host && scheme
    Addressable::URI.new(
      scheme: scheme,
      host: host,
      path: basePath,
    ).to_s
  end
end

#request_media_typeObject



171
172
173
174
175
176
177
178
# File 'lib/scorpio/openapi/document.rb', line 171

def request_media_type
  return @request_media_type if instance_variable_defined?(:@request_media_type)
  if consumes.respond_to?(:to_ary)
    Request.best_media_type(consumes)
  else
    nil
  end
end

#schemeObject



138
139
140
141
142
143
144
145
146
# File 'lib/scorpio/openapi/document.rb', line 138

def scheme
  return @scheme if instance_variable_defined?(:@scheme)
  if schemes.nil?
    'https'
  elsif schemes.respond_to?(:to_ary)
    # prefer https, then http, then anything else since we probably don't support.
    schemes.sort_by { |s| ['https', 'http'].index(s) || (1.0 / 0) }.first
  end
end

Instance Method Details

#serverObject



148
149
150
# File 'lib/scorpio/openapi/document.rb', line 148

def server
  nil
end

#server_variablesObject



151
152
153
# File 'lib/scorpio/openapi/document.rb', line 151

def server_variables
  nil
end