nhance/app/Views/swagger/index.php

76 lines
2.3 KiB
PHP
Executable File

<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title><?= esc($pageTitle ?? 'Swagger UI') ?></title>
<link rel="stylesheet" type="text/css" href="<?= base_url('assets/swagger/swagger-ui.css') ?>">
<link rel="icon" type="image/png" href="<?= base_url('assets/swagger/favicon-32x32.png') ?> sizes=" 32x32" />
<link rel="icon" type="image/png" href="<?= base_url('assets/swagger/favicon-16x16.png') ?> sizes=" 16x16" />
<style>
html {
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
}
*,
*:before,
*:after {
box-sizing: inherit;
}
body {
margin: 0;
background: #fafafa;
}
</style>
</head>
<body>
<div id="swagger-ui"></div>
<script src="<?= base_url('assets/swagger/swagger-ui-bundle.js') ?>"></script>
<script src="<?= base_url('assets/swagger/swagger-ui-standalone-preset.js') ?>"></script>
<script>
window.onload = function() {
const ui = SwaggerUIBundle({
url: "<?= esc($specUrl ?? base_url('assets/api.yaml'), 'js') ?>",
dom_id: '#swagger-ui',
deepLinking: true,
persistAuthorization: true,
presets: [
SwaggerUIBundle.presets.apis,
SwaggerUIStandalonePreset
],
plugins: [
SwaggerUIBundle.plugins.DownloadUrl
],
layout: "StandaloneLayout"
});
window.ui = ui;
<?php if (! empty($swaggerPreauthorize)): ?>
try {
<?php foreach ($swaggerPreauthorize as $row): ?>
<?php if (($row['kind'] ?? '') === 'apiKey'): ?>
if (typeof ui.preauthorizeApiKey === 'function') {
ui.preauthorizeApiKey(<?= json_encode($row['scheme'] ?? '') ?>, <?= json_encode($row['value'] ?? '') ?>);
}
<?php elseif (($row['kind'] ?? '') === 'basic'): ?>
if (typeof ui.preauthorizeBasic === 'function') {
ui.preauthorizeBasic(<?= json_encode($row['scheme'] ?? '') ?>, <?= json_encode($row['username'] ?? '') ?>, <?= json_encode($row['password'] ?? '') ?>);
}
<?php endif; ?>
<?php endforeach; ?>
} catch (e) {
console.warn('Swagger preauthorize', e);
}
<?php endif; ?>
};
</script>
</body>
</html>