Sha256: 38b13dd4776140133476f88485a0f372984883a979a18264132b04be469ea38c

Contents?: true

Size: 603 Bytes

Versions: 1

Compression:

Stored size: 603 Bytes

Contents

# frozen_string_literal: true

class Rage::OpenAPI::Parsers::SharedReference
  def initialize(**)
  end

  def known_definition?(str)
    str.start_with?("#/components")
  end

  def parse(component_path)
    { "$ref" => component_path } if valid_components_ref?(component_path)
  end

  private

  def valid_components_ref?(component_path)
    shared_components = Rage::OpenAPI.__shared_components
    return false if shared_components.empty?

    !!component_path[2..].split("/").reduce(shared_components) do |components, component_key|
      components[component_key] if components
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rage-rb-1.11.0 lib/rage/openapi/parsers/shared_reference.rb