forked from fa/breadcrumb-the-shire
Move the Swagger UI viewer from core (pages/admin/api-docs/) into modules/api-docs/ as a self-contained module. Create module manifest with routes, permission, sidebar.admin_nav_item slot, asset group, and authorization policy. Remove API docs ability from core OperationsAuthorizationPolicy and UiCapabilityMap. Remove hardcoded sidebar nav item — now contributed via module slot. Add admin-automation group meta to sidebar template for module nav items. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
30 lines
720 B
PHP
30 lines
720 B
PHP
<?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);
|
|
}
|