1
0
Files
breadcrumb-the-shire/modules/api-docs/pages/api-docs/spec().php

30 lines
720 B
PHP
Raw Normal View History

<?php
use MintyPHP\Module\ApiDocs\ApiDocsAuthorizationPolicy;
use MintyPHP\Support\Guard;
define('MINTY_ALLOW_OUTPUT', true);
Guard::requireLogin();
Guard::requireAbilityOrForbidden(ApiDocsAuthorizationPolicy::ABILITY_VIEW);
$specPath = defined('APP_ROOT') ? APP_ROOT . '/docs/openapi.yaml' : dirname(__DIR__, 4) . '/docs/openapi.yaml';
if (!is_file($specPath)) {
http_response_code(404);
return;
}
if (!is_readable($specPath)) {
http_response_code(500);
return;
}
header('Content-Type: application/yaml; charset=utf-8');
header('X-Content-Type-Options: nosniff');
header('Cache-Control: private, max-age=60');
$bytes = @readfile($specPath);
if ($bytes === false) {
http_response_code(500);
}