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.



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

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



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

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



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

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



142
143
144
# File 'lib/scorpio/openapi/document.rb', line 142

def server
  nil
end

#server_variablesObject



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

def server_variables
  nil
end