Sha256: 56a54856f77791aaf47f1f5d57679bf228b4f3bb7b558894cdaed4635e969524

Contents?: true

Size: 907 Bytes

Versions: 5

Compression:

Stored size: 907 Bytes

Contents

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

      def tomogram
        raise PrefixNotMatch, message unless @main_documentation.prefix_match?(@raw.path)
        @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

5 entries across 5 versions & 1 rubygems

Version Path
esplanade-1.2.1 lib/esplanade/request/doc.rb
esplanade-1.2.0 lib/esplanade/request/doc.rb
esplanade-1.1.2 lib/esplanade/request/doc.rb
esplanade-1.1.1 lib/esplanade/request/doc.rb
esplanade-1.1.0 lib/esplanade/request/doc.rb