Module: Openapi3Parser

Defined in:
lib/openapi3_parser.rb,
lib/openapi3_parser/node.rb,
lib/openapi3_parser/error.rb,
lib/openapi3_parser/context.rb,
lib/openapi3_parser/version.rb,
lib/openapi3_parser/document.rb,
lib/openapi3_parser/node/map.rb,
lib/openapi3_parser/nodes/map.rb,
lib/openapi3_parser/nodes/tag.rb,
lib/openapi3_parser/nodes/xml.rb,
lib/openapi3_parser/fields/map.rb,
lib/openapi3_parser/nodes/info.rb,
lib/openapi3_parser/nodes/link.rb,
lib/openapi3_parser/node/object.rb,
lib/openapi3_parser/nodes/array.rb,
lib/openapi3_parser/nodes/paths.rb,
lib/openapi3_parser/node_factory.rb,
lib/openapi3_parser/nodes/header.rb,
lib/openapi3_parser/nodes/schema.rb,
lib/openapi3_parser/nodes/server.rb,
lib/openapi3_parser/nodes/contact.rb,
lib/openapi3_parser/nodes/example.rb,
lib/openapi3_parser/nodes/license.rb,
lib/openapi3_parser/nodes/openapi.rb,
lib/openapi3_parser/nodes/callback.rb,
lib/openapi3_parser/nodes/encoding.rb,
lib/openapi3_parser/nodes/response.rb,
lib/openapi3_parser/nodes/operation.rb,
lib/openapi3_parser/nodes/parameter.rb,
lib/openapi3_parser/nodes/path_item.rb,
lib/openapi3_parser/nodes/responses.rb,
lib/openapi3_parser/node_factory/map.rb,
lib/openapi3_parser/nodes/components.rb,
lib/openapi3_parser/nodes/media_type.rb,
lib/openapi3_parser/nodes/oauth_flow.rb,
lib/openapi3_parser/validation/error.rb,
lib/openapi3_parser/nodes/oauth_flows.rb,
lib/openapi3_parser/node_factories/map.rb,
lib/openapi3_parser/node_factories/tag.rb,
lib/openapi3_parser/node_factories/xml.rb,
lib/openapi3_parser/nodes/request_body.rb,
lib/openapi3_parser/node_factories/info.rb,
lib/openapi3_parser/node_factories/link.rb,
lib/openapi3_parser/node_factory/object.rb,
lib/openapi3_parser/nodes/discriminator.rb,
lib/openapi3_parser/node_factories/array.rb,
lib/openapi3_parser/node_factories/paths.rb,
lib/openapi3_parser/node_factories/header.rb,
lib/openapi3_parser/node_factories/schema.rb,
lib/openapi3_parser/node_factories/server.rb,
lib/openapi3_parser/nodes/security_scheme.rb,
lib/openapi3_parser/nodes/server_variable.rb,
lib/openapi3_parser/node_factories/contact.rb,
lib/openapi3_parser/node_factories/example.rb,
lib/openapi3_parser/node_factories/license.rb,
lib/openapi3_parser/node_factories/openapi.rb,
lib/openapi3_parser/node_factories/callback.rb,
lib/openapi3_parser/node_factories/encoding.rb,
lib/openapi3_parser/node_factories/response.rb,
lib/openapi3_parser/node_factories/operation.rb,
lib/openapi3_parser/node_factories/parameter.rb,
lib/openapi3_parser/node_factories/path_item.rb,
lib/openapi3_parser/node_factories/reference.rb,
lib/openapi3_parser/node_factories/responses.rb,
lib/openapi3_parser/node_factories/components.rb,
lib/openapi3_parser/node_factories/media_type.rb,
lib/openapi3_parser/node_factories/oauth_flow.rb,
lib/openapi3_parser/node_factory/field_config.rb,
lib/openapi3_parser/node_factories/oauth_flows.rb,
lib/openapi3_parser/nodes/security_requirement.rb,
lib/openapi3_parser/node_factories/request_body.rb,
lib/openapi3_parser/validation/error_collection.rb,
lib/openapi3_parser/node_factories/discriminator.rb,
lib/openapi3_parser/nodes/external_documentation.rb,
lib/openapi3_parser/node_factory/object/validator.rb,
lib/openapi3_parser/node_factories/security_scheme.rb,
lib/openapi3_parser/node_factories/server_variable.rb,
lib/openapi3_parser/nodes/parameter/parameter_like.rb,
lib/openapi3_parser/node_factory/optional_reference.rb,
lib/openapi3_parser/node_factory/object/node_builder.rb,
lib/openapi3_parser/node_factories/security_requirement.rb,
lib/openapi3_parser/node_factories/external_documentation.rb,
lib/openapi3_parser/node_factories/parameter/parameter_like.rb

Defined Under Namespace

Modules: Fields, Node, NodeFactories, NodeFactory, Nodes, Validation Classes: Context, Document, Error

Constant Summary

VERSION =
"0.2.0"

Class Method Summary collapse

Class Method Details

.load(input) ⇒ Document

For a variety of inputs this will construct an OpenAPI document. For a String/File input it will try to determine if the input is JSON or YAML.

Parameters:

  • input (String, Hash, File)

    Source for the OpenAPI document

Returns:



16
17
18
19
20
21
22
23
24
# File 'lib/openapi3_parser.rb', line 16

def self.load(input)
  # working_directory ||= if input.respond_to?(:read)
  #                         File.dirname(input)
  #                       else
  #                         Dir.pwd
  #                       end

  Document.new(parse_input(input))
end

.load_file(path) ⇒ Document

For a given string filename this will read the file and parse it as an OpenAPI document. It will try detect automatically whether the contents are JSON or YAML.

Parameters:

  • path (String)

    Filename of the OpenAPI document

Returns:



33
34
35
36
# File 'lib/openapi3_parser.rb', line 33

def self.load_file(path)
  file = File.open(path)
  load(file)
end