Class: Minitest::OpenAPI::Api::DocumentEndpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/minitest/openapi/api/document_endpoint.rb

Overview

Rack endpoint that serves the generated OpenAPI document.

Constant Summary collapse

JSON_HEADERS =
{"content-type" => "application/json; charset=utf-8"}.freeze

Instance Method Summary collapse

Instance Method Details

#call(_env) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/minitest/openapi/api/document_endpoint.rb', line 12

def call(_env)
  path = resolved_path

  if File.file?(path)
    [200, JSON_HEADERS.dup, [File.read(path)]]
  else
    [404, JSON_HEADERS.dup, [not_found_body]]
  end
end