Sha256: 9513025b70c0c2767fcb5c6b4c3f2951b74bcc3e93acb63114f5ad483ef7d256

Contents?: true

Size: 800 Bytes

Versions: 6

Compression:

Stored size: 800 Bytes

Contents

# frozen_string_literal: true

class Zilla::Versions::V20::API
  include Zilla::Versions::V20

  include Memery

  attr_reader :json

  def initialize(json)
    @json = json
  end

  [:host, :schemes].each do |name|
    define_method(name) do
      json[name.to_s]
    end
  end

  memoize def info = OpenStruct.new(json["info"]) # rubocop:disable Style/OpenStructUse

  memoize def definitions
    json.fetch("definitions", {}).each_with_object({}) do |(k, v), acc|
      acc[k] = Definition.new(k, v, definitions: acc)
    end
  end

  memoize def paths
    json.fetch("paths", {}).each_with_object({}) do |(k, v), acc|
      acc[k] = Path.new(k, v, definitions:)
    end
  end

  memoize def endpoints = paths.values.flat_map { _1.endpoints.values }

  # TODO: :security, :securityDefinitions
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
zilla-0.1.5 lib/zilla/versions/v20/api.rb
zilla-0.1.4 lib/zilla/versions/v20/api.rb
zilla-0.1.3 lib/zilla/versions/v20/api.rb
zilla-0.1.2 lib/zilla/versions/v20/api.rb
zilla-0.1.1 lib/zilla/versions/v20/api.rb
zilla-0.1.0 lib/zilla/versions/v20/api.rb