Sha256: 8af43740cab4122eaa0de362a00ed55ae41db25dea9f9bfa6ca54a86cb6f406c

Contents?: true

Size: 819 Bytes

Versions: 2

Compression:

Stored size: 819 Bytes

Contents

module Esplanade
  class Request
    class Doc
      def initialize(main_documentation, raw)
        @main_documentation = main_documentation
        @raw = raw
      end

      def tomogram
        @tomogram ||= @main_documentation.find_request(method: @raw.method, path: @raw.path)
        raise NotDocumented, message if @tomogram.nil?
        @tomogram
      end

      def json_schema
        @json_schema ||= tomogram.request
      end

      def method
        @method ||= tomogram.method
      end

      def path
        @path ||= tomogram.path.to_s
      end

      def responses
        @responses ||= tomogram.responses
      rescue NotDocumented
        []
      end

      private

      def message
        {
          method: @raw.method,
          path: @raw.path
        }
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
esplanade-1.0.1 lib/esplanade/request/doc.rb
esplanade-1.0.0 lib/esplanade/request/doc.rb