Sha256: 0af53f70cd54aceee973454355c77a3429df374334b1da708dbd15d5c293c6bd
Contents?: true
Size: 1.1 KB
Versions: 12
Compression:
Stored size: 1.1 KB
Contents
module OpenApi class Response prepend EquatableAsContent attr_accessor :description, :headers, :content, :links def initialize(description:, headers: nil, content: nil, links: nil) self.description = description self.headers = headers&.with_indifferent_access self.content = content&.with_indifferent_access self.links = links&.with_indifferent_access end def serializable_hash { "description" => description.to_s, "headers" => headers&.map { |k, v| [k.to_s, v.serializable_hash] }&.to_h, "content" => content&.map { |k, v| [k.to_s, v.serializable_hash] }&.to_h, "links" => links&.map { |k, v| [k.to_s, v.serializable_hash] }&.to_h, }.compact end def self.load(hash) return unless hash new( description: hash["description"].to_s, headers: hash["headers"]&.map { |k, v| [k, Header.load(v)] }&.to_h, content: hash["content"]&.map { |k, v| [k, MediaType.load(v)] }&.to_h, links: hash["links"]&.map { |k, v| [k, Reference.load(v) || Link.load(v)] }&.to_h, ) end end end
Version data entries
12 entries across 12 versions & 1 rubygems