feat(api-docs): extract API docs viewer into standalone module
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>
This commit is contained in:
@@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
use MintyPHP\Buffer;
|
||||
use MintyPHP\Support\Guard;
|
||||
|
||||
Guard::requireLogin();
|
||||
Guard::requireAbility(\MintyPHP\Service\Access\OperationsAuthorizationPolicy::ABILITY_ADMIN_API_DOCS_VIEW);
|
||||
|
||||
Buffer::set('title', t('API docs'));
|
||||
Buffer::set('style_groups', json_encode(['api-docs']));
|
||||
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
$breadcrumbs = [
|
||||
['label' => t('Home'), 'path' => 'admin'],
|
||||
['label' => t('API docs')],
|
||||
];
|
||||
$specUrl = lurl('admin/api-docs/spec');
|
||||
require templatePath('partials/app-breadcrumb.phtml');
|
||||
?>
|
||||
|
||||
<div class="app-swagger-container">
|
||||
<div id="swagger-ui" data-spec-url="<?php e($specUrl); ?>"></div>
|
||||
</div>
|
||||
|
||||
<script src="<?php e(assetVersion('vendor/swagger-ui/swagger-ui-bundle.js')); ?>"></script>
|
||||
<script type="module" src="<?php e(assetVersion('js/pages/admin-api-docs-index.js')); ?>"></script>
|
||||
@@ -1,29 +0,0 @@
|
||||
<?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);
|
||||
}
|
||||
Reference in New Issue
Block a user