Sha256: 9dd47941e63aa91f5ddcc0c046d356fc3973c455810d8e1ca33b16f66c013aff

Contents?: true

Size: 886 Bytes

Versions: 3

Compression:

Stored size: 886 Bytes

Contents

# frozen_string_literal: true

module Yori
  module Schema
    module V3
      # Root
      module Root
        def self.included(klass)
          klass.class_eval do
            class << self
              def api_docs_factory
                @_api_docs_factory
              end

              def api_docs
                return unless api_docs_factory

                openapi = api_docs_factory.call
                openapi.to_json
              end

              def root(id = '', &block)
                @_api_docs_factory = proc do
                  Yori::Schema::V3::OpenAPI.new.tap do |openapi|
                    openapi.id = id
                    openapi.instance_eval(&block)
                  end
                end
              end
            end
          end
        end

        def api_docs
          self.class.api_docs
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yori-0.1.2 lib/yori/schema/v3/root.rb
yori-0.1.1 lib/yori/schema/v3/root.rb
yori-0.1.0 lib/yori/schema/v3/root.rb