Sha256: 3ebb561e782a7df476d163a4b1adb2b76aa0292acb7e1f06751071164fe8232d

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

require 'r2-oas/plugins/schema/v3/object/hookable_base_object'

module R2OAS
  module Schema
    module V3
      module Components
        class SchemaObject < R2OAS::Plugins::Schema::V3::HookableBaseObject
          def initialize(route_data, path)
            super()
            @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]
          end

          def to_doc
            execute_before_create(@schema_name)
            create_doc
            execute_after_create(@schema_name)
            doc
          end

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

          # MEMO:
          # please override in inherited class.
          def components_schema_name(_doc, _path_component, _tag_name, _verb, _http_status, schema_name)
            schema_name
          end

          private

          def _components_schema_name(http_status)
            components_schema_name(doc, @path_comp, @tag_name, @verb, http_status, @schema_name)
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
r2-oas-0.3.4 lib/r2-oas/schema/v3/object/components/schema_object.rb
r2-oas-0.3.3 lib/r2-oas/schema/v3/object/components/schema_object.rb
r2-oas-0.3.2 lib/r2-oas/schema/v3/object/components/schema_object.rb
r2-oas-0.3.1 lib/r2-oas/schema/v3/object/components/schema_object.rb
r2-oas-0.3.0 lib/r2-oas/schema/v3/object/components/schema_object.rb
r2-oas-0.2.0 lib/r2-oas/schema/v3/object/components/schema_object.rb
r2-oas-0.1.3 lib/r2-oas/schema/v3/object/components/schema_object.rb
r2-oas-0.1.2 lib/r2-oas/schema/v3/object/components/schema_object.rb
r2-oas-0.1.0 lib/r2-oas/schema/v3/object/components/schema_object.rb