Module: SpecForge::Documentation::OpenAPI

Defined in:
lib/spec_forge/documentation/openapi.rb,
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

OpenAPI specification generation and version management

Provides version-aware access to OpenAPI generators and validators. Supports multiple OpenAPI versions through semantic versioning matching.

Defined Under Namespace

Classes: V30

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 version used as default

Points to the latest supported OpenAPI version for new specifications.

V30::CURRENT_VERSION
VERSIONS =

Mapping of semantic versions to their generator classes

Returns:

  • (Hash{SemVersion => Class})
{
  V30.to_sem_version => V30
}.freeze

Class Method Summary collapse

Class Method Details

.[](version) ⇒ Class

Returns the generator class for the specified OpenAPI version

Parameters:

  • version (String, SemVersion)

    The OpenAPI version (e.g., "3.0")

Returns:

  • (Class)

    The generator class for the requested version

Raises:

  • (ArgumentError)

    If the version is not supported



39
40
41
42
43
44
45
46
47
48
# File 'lib/spec_forge/documentation/openapi.rb', line 39

def self.[](version)
  version = SemVersion.from_loose_version(version)
  generator = VERSIONS.value_where { |k, _v| k.satisfies?("~> #{version}") }

  if generator.nil?
    raise ArgumentError, "Invalid OpenAPI version provided: #{version.to_s.in_quotes}"
  end

  generator
end