Sha256: f0f5801e97a901e34c23eae86c78c10f304591f38003e7d4be7007d6e49a4224

Contents?: true

Size: 817 Bytes

Versions: 1

Compression:

Stored size: 817 Bytes

Contents

# frozen_string_literal: true

require "modern/struct"
require "modern/descriptor/content"
require "modern/descriptor/parameters"

module Modern
  module Descriptor
    class Response < Modern::Struct
      # TODO: figure out a good way to handle header responses
      #       This is in part an API response type of thing; how do we ensure that
      #       an action defines the header that it says it's defining?
      attribute :http_code, Types::Strict::Integer | Types.Value(:default)
      attribute :description, Types::Strict::String.default("No description provided.")
      attribute :content, Types.array_of(Content)

      attr_reader :content_by_type

      def initialize(fields)
        super

        @content_by_type = content.map { |c| [c.media_type, c] }.to_h.freeze
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
modern-0.5.0 lib/modern/descriptor/response.rb