class Openapi3Parser::SourceInput
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.
@see SourceInput::Raw
SourceInput::Raw
for an input that is done through
data, such as a Hash.
@see SourceInput::File
SourceInput::File
for an input that is done through
the path to a file within the local file system.
@see SourceInput::Url
SourceInput::Url
for an input that is done through]
a URL to an OpenAPI Document
@attr_reader [Error::InaccessibleInput, nil] access_error
@attr_reader [Error::UnparsableInput, nil] parse_error
Attributes
Public Class Methods
# 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.message) end
Public Instance Methods
Used to determine whether a different instance of SourceInput
is the same file/data
# File lib/openapi3_parser/source_input.rb, line 45 def ==(_other); end
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
# File lib/openapi3_parser/source_input.rb, line 33 def available? access_error.nil? && parse_error.nil? end
The parsed data from the input
@raise [Error::InaccessibleInput] In cases where the file does not exist @raise [Error::UnparsableInput] In cases where the data is not parsable
@return Object
# 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
The relative path, if possible, for this source_input compared to a different one. Defaults to empty string and should be specialised in subclasses
@return [String]
# File lib/openapi3_parser/source_input.rb, line 65 def relative_to(_source_input) "" end
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
# File lib/openapi3_parser/source_input.rb, line 41 def resolve_next(_reference); end