Class: SpecForge::Documentation::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/spec_forge/documentation/document.rb,
lib/spec_forge/documentation/document/response.rb,
lib/spec_forge/documentation/document/operation.rb,
lib/spec_forge/documentation/document/parameter.rb,
lib/spec_forge/documentation/document/request_body.rb,
lib/spec_forge/documentation/document/response_body.rb

Overview

Represents the structured API documentation

This class is the central data structure for API documentation, containing all endpoints organized by path and HTTP method. It serves as the bridge between extracted test data and generators.

Examples:

Creating a document

document = Document.new(
  endpoints: {
    "/users" => {
      "get" => {id: "list_users", description: "List all users"...},
      "post" => {id: "create_user", description: "Create a user"...}
    }
  }
)

Defined Under Namespace

Classes: Operation, Parameter, RequestBody, Response, ResponseBody

Instance Method Summary collapse

Constructor Details

#initialize(endpoints: {}) ⇒ Document

Creates a new document with normalized endpoints

Parameters:

  • endpoints (Hash) (defaults to: {})

    A hash mapping paths to operations by HTTP method



30
31
32
33
34
35
36
37
38
39
# File 'lib/spec_forge/documentation/document.rb', line 30

def initialize(endpoints: {})
  endpoints = endpoints.transform_values do |operations|
    operations.transform_keys(&:downcase)
      .transform_values! { |op| Operation.new(**op) }
  end

  endpoints.deep_symbolize_keys!

  super
end