0
0
mirror of https://github.com/go-gitea/gitea.git synced 2026-05-27 16:12:30 +02:00
gitea/web_src/js/swagger.ts
wxiaoguang 1412009d0a
Frontend iframe renderer framework: 3D models, OpenAPI (#37233) (#37273)
Backport

* #37233
* #37272

---------

Co-authored-by: silverwind <me@silverwind.io>
2026-04-18 16:02:18 +08:00

15 lines
766 B
TypeScript

// FIXME: INCORRECT-VITE-MANIFEST-PARSER: it just happens to work for current dependencies
// If this module depends on another one and that one imports "swagger.css", then {{AssetURI "css/swagger.css"}} won't work
import '../css/swagger-standalone.css';
import {initSwaggerUI} from './render/swagger.ts';
async function initGiteaAPIViewer() {
const elSwaggerUi = document.querySelector<HTMLElement>('#swagger-ui')!;
const url = elSwaggerUi.getAttribute('data-source')!;
const res = await fetch(url); // eslint-disable-line no-restricted-globals
// HINT: SWAGGER-CSS-IMPORT: this is used in the standalone page which already has the related CSS imported by `<link>`
await initSwaggerUI(elSwaggerUi, {specText: await res.text()});
}
initGiteaAPIViewer();