Class: RspecApiDocs::Renderer::JSONRenderer::ExampleSerializer

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(example) ⇒ ExampleSerializer

Returns a new instance of ExampleSerializer.



7
8
9
# File 'lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb', line 7

def initialize(example)
  @example = example
end

Instance Attribute Details

#exampleObject (readonly)

Returns the value of attribute example.



5
6
7
# File 'lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb', line 5

def example
  @example
end

Instance Method Details

#to_hObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb', line 11

def to_h
  {
    description: example.description,
    name: example.name,
    http_method: example.http_method,
    parameters: parameters,
    path: example.path,
    requests: example.requests,
    response_fields: response_fields,
    notes: example.notes,
  }
end