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.



155
156
157
158
159
160
161
162
163
164
# File 'lib/scorpio/openapi/document.rb', line 155

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,
    ).freeze
  end
end

#request_media_typeObject



167
168
169
170
171
172
173
174
# File 'lib/scorpio/openapi/document.rb', line 167

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



134
135
136
137
138
139
140
141
142
# File 'lib/scorpio/openapi/document.rb', line 134

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



144
145
146
# File 'lib/scorpio/openapi/document.rb', line 144

def server
  nil
end

#server_variablesObject



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

def server_variables
  nil
end