Sha256: 8dcc91b415bae8911cdd0c9cd9b10164c809ef8288ecbaf337366a07a574aa82

Contents?: true

Size: 777 Bytes

Versions: 4

Compression:

Stored size: 777 Bytes

Contents

# frozen_string_literal: true

class Zilla::Versions::V20::Endpoint
  include Zilla::Versions::V20

  include Memery

  attr_reader :path, :method, :json, :definitions

  def initialize(path, method, json, definitions: {})
    raise ArgumentError, "json must be a Hash, given: #{json.class.inspect}" unless json.instance_of?(Hash)

    @path = path
    @method = method
    @json = json
    @definitions = definitions
  end

  [:summary, :description, :tags, :operationId].each do |name|
    define_method(name) do
      json[name.to_s]
    end
  end

  memoize def path_template = PathTemplate.new(path)

  memoize def parameters = Parameters.new(json["parameters"], definitions:)
  memoize def responses = json["responses"].transform_values { |v| JSONSchemer.schema(v) }
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
zilla-0.1.5 lib/zilla/versions/v20/endpoint.rb
zilla-0.1.4 lib/zilla/versions/v20/endpoint.rb
zilla-0.1.3 lib/zilla/versions/v20/endpoint.rb
zilla-0.1.2 lib/zilla/versions/v20/endpoint.rb