Class: SpecForge::Documentation::Document::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/spec_forge/documentation/document/response.rb

Overview

Represents a possible response from an API operation

Contains the status code, headers, and body content with content type information.

Examples:

Success response

Response.new(
  content_type: "application/json",
  status: 200,
  headers: {"Cache-Control" => {type: "string"}},
  body: {type: "object", content: {id: {type: "integer"}}}
)

Instance Method Summary collapse

Constructor Details

#initialize(content_type:, status:, headers:, body:) ⇒ Response

Creates a new response with a normalized body

Parameters:

  • content_type (String)

    The content type (e.g., "application/json")

  • status (Integer)

    The HTTP status code

  • headers (Hash)

    Response headers with their types

  • body (Hash)

    Response body description



31
32
33
34
35
# File 'lib/spec_forge/documentation/document/response.rb', line 31

def initialize(content_type:, status:, headers:, body:)
  body = ResponseBody.new(**body) if body.present?

  super
end