Module: Scorpio::OpenAPI::Document
- Includes:
- Configurables
- Included in:
- V2::Document, V3::Document
- Defined in:
- lib/scorpio/openapi/document.rb
Overview
A document that defines or describes an API. An OpenAPI description document uses and conforms to the OpenAPI Specification.
Scorpio::OpenAPI::Document is a module common to V2 and V3 documents.
Defined Under Namespace
Modules: Configurables
Instance Attribute Summary
Attributes included from Configurables
#faraday_adapter, #faraday_builder, #logger, #request_headers, #user_agent
Class Method Summary collapse
-
.from_instance(instance) ⇒ Scorpio::OpenAPI::V2::Document, Scorpio::OpenAPI::V3::Document
takes a document, generally a Hash, and returns a Scorpio OpenAPI Document instantiating it.
Instance Method Summary collapse
Class Method Details
.from_instance(instance) ⇒ Scorpio::OpenAPI::V2::Document, Scorpio::OpenAPI::V3::Document
takes a document, generally a Hash, and returns a Scorpio OpenAPI Document instantiating it.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/scorpio/openapi/document.rb', line 16 def from_instance(instance) if instance.is_a?(Scorpio::OpenAPI::Document) instance elsif instance.is_a?(JSI::Base) raise(TypeError, "instance is unexpected JSI type: #{instance.class.inspect}") elsif instance.respond_to?(:to_hash) if instance['swagger'] =~ /\A2(\.|\z)/ instance = Scorpio::OpenAPI::V2::Document.new_jsi(instance) elsif instance['openapi'] =~ /\A3(\.|\z)/ instance = Scorpio::OpenAPI::V3::Document.new_jsi(instance) else raise(ArgumentError, "instance does not look like a recognized openapi document") end else raise(TypeError, "instance does not look like a hash (json object)") end end |
Instance Method Details
#operations ⇒ Object
76 77 78 79 |
# File 'lib/scorpio/openapi/document.rb', line 76 def operations return @operations if instance_variable_defined?(:@operations) @operations = OperationsScope.new(self) end |