Sha256: 1852bcb17a8fd4e368cda7391345b28fd51266ae776caead1aaa50278fcaa898

Contents?: true

Size: 795 Bytes

Versions: 3

Compression:

Stored size: 795 Bytes

Contents

# frozen_string_literal: true

require_relative "oapi/version"

require "zeitwerk"

loader = Zeitwerk::Loader.for_gem

loader.inflector.inflect(
  "oapi" => "OAPI",
  "open_api" => "OpenAPI",
  "json" => "JSON"
)

loader.setup

module OAPI
  class Error < StandardError
    # Your code goes here...
  end

  class UnsupportedSpecVersion < Error
  end

  class << self
    def define(&)
      # TODO: check version
      # raise UnsupportedSpecVersion, "unsupported version #{version}" unless version.start_with?("3.0")

      OAPI::OpenAPI::V30::Definition.new(&)
    end

    def parse(json)
      version = json[:openapi]
      raise UnsupportedSpecVersion, "unsupported version #{version}" unless version.start_with?("3.0")

      OAPI::OpenAPI::V30::Definition.parse(json)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
oapi-0.1.2 lib/oapi.rb
oapi-0.1.1 lib/oapi.rb
oapi-0.1.0 lib/oapi.rb