Sha256: 5c98b90498b49445c1574ada3ae0f8d7f728525799e9ff3082825da0884dab70

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

require 'r2-oas/schema/v3/object/from_routes/base_object'

module R2OAS
  module Schema
    module V3
      module Components
        class SchemaObject < R2OAS::Schema::V3::BaseObject
          def initialize(route_data, path, opts = {})
            super(opts)
            @path_comp    = Routing::PathComponent.new(path)
            @path         = @path_comp.symbol_to_brace
            @route_data   = route_data
            @verb         = route_data[:verb]
            @tag_name     = route_data[:tag_name]
            @schema_name  = route_data[:schema_name]
            # MEMO:
            # Allow primitive types that cannot be passed by reference to be passed by reference
            # This is Compromise
            @ref          = { schema_name: @schema_name, tag_name: @tag_name, verb: @verb }
          end

          def to_doc
            create_doc
            doc
          end

          private

          def create_doc
            result = {
              'type' => 'object',
              'properties' => {
                'id' => {
                  'type' => 'integer',
                  'format' => 'int64'
                }
              }
            }
            doc.merge!(result)
          end

          def _components_schema_name(_http_status)
            @schema_name
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
r2-oas-0.5.0 lib/r2-oas/schema/v3/object/from_routes/components/schema_object.rb