Sha256: 408c8e7734d8437415b83a603e7c2b2282c88c505e9833ddeb7d3830c4c57aac

Contents?: true

Size: 1.15 KB

Versions: 12

Compression:

Stored size: 1.15 KB

Contents

module RspecApiDocs
  module Renderer
    class JSONRenderer
      class ExampleSerializer
        attr_reader :example

        def initialize(example)
          @example = example
        end

        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

        private

        def parameters
          example.parameters.map do |parameter|
            {
              name: Name.(name: parameter.name, scope: parameter.scope),
              description: parameter.description,
              required: parameter.required,
            }
          end
        end

        def response_fields
          example.response_fields.map do |field|
            {
              name: Name.(name: field.name, scope: field.scope),
              description: field.description,
              type: field.type,
            }
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rspec-api-docs-1.1.0 lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb
rspec-api-docs-1.0.0 lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb
rspec-api-docs-0.14.0 lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb
rspec-api-docs-0.13.0 lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb
rspec-api-docs-0.12.0 lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb
rspec-api-docs-0.11.0 lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb
rspec-api-docs-0.10.0 lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb
rspec-api-docs-0.9.0 lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb
rspec-api-docs-0.8.0 lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb
rspec-api-docs-0.7.0 lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb
rspec-api-docs-0.6.0 lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb
rspec-api-docs-0.5.0 lib/rspec_api_docs/formatter/renderer/json_renderer/example_serializer.rb