Class: Openapi3Parser::SourceInput
- Inherits:
-
Object
- Object
- Openapi3Parser::SourceInput
- Defined in:
- lib/openapi3_parser/source_input.rb,
lib/openapi3_parser/source_input/raw.rb,
lib/openapi3_parser/source_input/url.rb,
lib/openapi3_parser/source_input/file.rb,
lib/openapi3_parser/source_input/resolve_next.rb,
lib/openapi3_parser/source_input/string_parser.rb
Overview
An abstract class which is used to provide a foundation for classes that represent the different means of input an OpenAPI document can have. It is used to represent the underlying source of the data which is used as a source within an OpenAPI document.
Defined Under Namespace
Classes: File, Raw, ResolveNext, StringParser, Url
Instance Attribute Summary collapse
-
#access_error ⇒ Error::InaccessibleInput?
readonly
The current value of access_error.
-
#parse_error ⇒ Error::UnparsableInput?
readonly
The current value of parse_error.
Instance Method Summary collapse
-
#==(_other) ⇒ Object
Used to determine whether a different instance of SourceInput is the same file/data.
-
#available? ⇒ Boolean
Indicates that the data within this input is suitable (i.e. can parse underlying JSON or YAML) for trying to use as part of a Document.
-
#contents ⇒ Object
The parsed data from the input.
-
#initialize ⇒ SourceInput
constructor
A new instance of SourceInput.
-
#relative_to(_source_input) ⇒ String
The relative path, if possible, for this source_input compared to a different one.
-
#resolve_next(_reference) ⇒ Object
For a given reference use the context of the current SourceInput to determine which file is required for the reference.
Constructor Details
#initialize ⇒ SourceInput
Returns a new instance of SourceInput.
23 24 25 26 27 28 29 |
# File 'lib/openapi3_parser/source_input.rb', line 23 def initialize return if access_error @contents = parse_contents rescue ::StandardError => e @parse_error = Error::UnparsableInput.new(e.) end |
Instance Attribute Details
#access_error ⇒ Error::InaccessibleInput? (readonly)
Returns the current value of access_error.
20 21 22 |
# File 'lib/openapi3_parser/source_input.rb', line 20 def access_error @access_error end |
#parse_error ⇒ Error::UnparsableInput? (readonly)
Returns the current value of parse_error.
20 21 22 |
# File 'lib/openapi3_parser/source_input.rb', line 20 def parse_error @parse_error end |
Instance Method Details
#==(_other) ⇒ Object
Used to determine whether a different instance of SourceInput is the same file/data
45 |
# File 'lib/openapi3_parser/source_input.rb', line 45 def ==(_other); end |
#available? ⇒ Boolean
Indicates that the data within this input is suitable (i.e. can parse underlying JSON or YAML) for trying to use as part of a Document
33 34 35 |
# File 'lib/openapi3_parser/source_input.rb', line 33 def available? access_error.nil? && parse_error.nil? end |
#contents ⇒ Object
The parsed data from the input
53 54 55 56 57 58 |
# File 'lib/openapi3_parser/source_input.rb', line 53 def contents raise access_error if access_error raise parse_error if parse_error @contents end |
#relative_to(_source_input) ⇒ String
The relative path, if possible, for this source_input compared to a different one. Defaults to empty string and should be specialised in subclasses
65 66 67 |
# File 'lib/openapi3_parser/source_input.rb', line 65 def relative_to(_source_input) "" end |
#resolve_next(_reference) ⇒ Object
For a given reference use the context of the current SourceInput to determine which file is required for the reference. This allows references to use relative file paths because we can combine them witt the current SourceInput location to determine the next one
41 |
# File 'lib/openapi3_parser/source_input.rb', line 41 def resolve_next(_reference); end |