class OpenApi::Response
Attributes
content[RW]
description[RW]
headers[RW]
links[RW]
Public Class Methods
load(hash)
click to toggle source
# File lib/open_api/response.rb, line 23 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
new(description:, headers: nil, content: nil, links: nil)
click to toggle source
# File lib/open_api/response.rb, line 7 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
Public Instance Methods
serializable_hash()
click to toggle source
# File lib/open_api/response.rb, line 14 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