Files
breadcrumb-the-shire/pages/admin/api-docs/spec().php
2026-03-04 15:56:58 +01:00

30 lines
669 B
PHP

<?php
use MintyPHP\Support\Guard;
define('MINTY_ALLOW_OUTPUT', true);
Guard::requireLogin();
Guard::requireAbility(\MintyPHP\Service\Access\OperationsAuthorizationPolicy::ABILITY_ADMIN_API_DOCS_VIEW);
$projectRoot = dirname(__DIR__, 3);
$specPath = $projectRoot . '/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);
}