Sha256: 9d7707eec2a21e0cccda644fa4a690c644d11b9d3c529dd4e3f7971bb3ae8708

Contents?: true

Size: 1.25 KB

Versions: 9

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

require_relative 'base_object'
require_relative 'tag_object'
require_relative 'server_object'

module R2OAS
  module Schema
    module V3
      class OpenapiObject < BaseObject
        def initialize(routes_data, tags_data, schemas_data)
          super()
          @routes_data  = routes_data
          @tags_data    = tags_data
          @schemas_data = schemas_data
        end

        def to_doc
          {
            'openapi' => '3.0.0',
            'info' => info_doc,
            'tags' => tags_doc,
            'paths' => paths_doc,
            'externalDocs' => external_docs_doc,
            'servers' => servers_doc,
            'components' => components_doc
          }
        end

        private

        def info_doc
          info_object_class.new.to_doc
        end

        def tags_doc
          TagObject.new(@tags_data).to_doc
        end

        def paths_doc
          paths_object_class.new(@routes_data).to_doc
        end

        def external_docs_doc
          external_document_object_class.new.to_doc
        end

        def servers_doc
          ServerObject.new.to_doc
        end

        def components_doc
          components_object_class.new(@routes_data).to_doc
        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/openapi_object.rb
r2-oas-0.3.3 lib/r2-oas/schema/v3/object/openapi_object.rb
r2-oas-0.3.2 lib/r2-oas/schema/v3/object/openapi_object.rb
r2-oas-0.3.1 lib/r2-oas/schema/v3/object/openapi_object.rb
r2-oas-0.3.0 lib/r2-oas/schema/v3/object/openapi_object.rb
r2-oas-0.2.0 lib/r2-oas/schema/v3/object/openapi_object.rb
r2-oas-0.1.3 lib/r2-oas/schema/v3/object/openapi_object.rb
r2-oas-0.1.2 lib/r2-oas/schema/v3/object/openapi_object.rb
r2-oas-0.1.0 lib/r2-oas/schema/v3/object/openapi_object.rb