Class: SpecForge::Documentation::OpenAPI::V30
- Defined in:
- lib/spec_forge/documentation/openapi/v3_0.rb,
lib/spec_forge/documentation/openapi/v3_0/tag.rb,
lib/spec_forge/documentation/openapi/v3_0/schema.rb,
lib/spec_forge/documentation/openapi/v3_0/example.rb,
lib/spec_forge/documentation/openapi/v3_0/response.rb,
lib/spec_forge/documentation/openapi/v3_0/operation.rb,
lib/spec_forge/documentation/openapi/v3_0/media_type.rb,
lib/spec_forge/documentation/openapi/v3_0/error_formatter.rb
Overview
Defined Under Namespace
Classes: ErrorFormatter, Example, MediaType, Operation, Response, Schema, Tag
Constant Summary collapse
- CURRENT_VERSION =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Current OpenAPI 3.0 version supported by this generator
"3.0.4"
Instance Attribute Summary
Attributes inherited from Generator
Class Method Summary collapse
-
.validate!(output) ⇒ void
Validates an OpenAPI specification against the standard.
Instance Method Summary collapse
-
#generate ⇒ Hash
Generates an OpenAPI 3.0 specification from the input document.
-
#paths ⇒ Hash
Transforms document endpoints into OpenAPI paths structure.
Methods inherited from Generator
generate, #initialize, to_sem_version
Constructor Details
This class inherits a constructor from SpecForge::Documentation::Generator
Class Method Details
.validate!(output) ⇒ void
This method returns an undefined value.
Validates an OpenAPI specification against the standard
Uses the openapi3_parser gem to validate the generated specification and provides detailed error reporting if validation fails.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/spec_forge/documentation/openapi/v3_0.rb', line 27 def self.validate!(output) document = Openapi3Parser.load(output) if document.valid? puts "✅ No validation errors found!" return end puts ErrorFormatter.format(document.errors.errors) raise Error::InvalidOASDocument end |
Instance Method Details
#generate ⇒ Hash
Generates an OpenAPI 3.0 specification from the input document
Creates a complete OpenAPI specification by combining the document's endpoint data with configuration files and ensuring compliance with OpenAPI 3.0.4 standards.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/spec_forge/documentation/openapi/v3_0.rb', line 47 def generate output = { openapi: CURRENT_VERSION, paths: } output.deep_stringify_keys! output.deep_merge!(config) output end |
#paths ⇒ Hash
Transforms document endpoints into OpenAPI paths structure
Converts the internal endpoint representation into the OpenAPI paths format, with each path containing operations organized by HTTP method.
67 68 69 70 71 72 73 74 75 |
# File 'lib/spec_forge/documentation/openapi/v3_0.rb', line 67 def paths paths = input.endpoints.deep_dup paths.each do |path, operations| operations.transform_values! do |document| Operation.new(document).to_h end end end |