Class: SpecForge::Documentation::OpenAPI::V30::Example

Inherits:
Object
  • Object
show all
Defined in:
lib/spec_forge/documentation/openapi/v3_0/example.rb

Overview

Represents an OpenAPI 3.0 Example object

Creates example objects for request/response documentation with optional summary, description, and external reference support.

Instance Method Summary collapse

Constructor Details

#initialize(summary: nil, description: nil, value: nil, external_value: nil) ⇒ Example

Creates a new OpenAPI example object

Parameters:

  • summary (String, nil) (defaults to: nil)

    Brief summary of the example's purpose

  • description (String, nil) (defaults to: nil)

    Detailed description of the example

  • value (Object, nil) (defaults to: nil)

    The actual example value

  • external_value (String, nil) (defaults to: nil)

    URL pointing to the example value



26
27
28
# File 'lib/spec_forge/documentation/openapi/v3_0/example.rb', line 26

def initialize(summary: nil, description: nil, value: nil, external_value: nil)
  super
end

Instance Method Details

#to_hHash

Converts the example to an OpenAPI-compliant hash

Returns:

  • (Hash)

    OpenAPI-formatted example object



35
36
37
38
39
# File 'lib/spec_forge/documentation/openapi/v3_0/example.rb', line 35

def to_h
  super
    .rename_key_unordered!(:external_value, :externalValue)
    .compact_blank!
end