gateway: nginx-hosts the full Swagger UI dist, core drops the fallback
Extends the theme-only alias into the full shape mara asked for on the
PR thread:
1. nix/packages/swagger-ui-dist.nix — plain vendored Swagger UI 5.17.14
dist, sourced directly from the swagger-ui-dist npm package (same
release the Rust utoipa-swagger-ui-vendored crate ships, verified
via matching gitHead commit) rather than through Cargo.lock/cargo.
2. nix/packages/swagger-ui-theme.nix — overlays our 3 override files
(index.html, hyperhive-theme.css, and now swagger-initializer.js)
onto (1).
3. vhosts.nix's swaggerUiLocations now prefix-matches the whole
/api/docs/ tree (not just 2 exact-match files) straight from (2),
plus a `= /api/docs` redirect shim since hive-c0re's own redirect
is going away too. /api/openapi.json (outside this prefix) keeps
proxying to c0re unchanged — that's the one thing that stays
dynamic.
New file swagger-initializer.js needed hand-verification: the plain
vendored copy hardcodes the swagger.io petstore demo URL.
utoipa-swagger-ui normally rewrites it per-request from a {{config}}
placeholder its own build.rs injects — since hive-c0re won't be
serving this file at all once its SwaggerUi mount is removed, that
rewrite has to be baked in statically here instead. Derived by
actually running build.rs's own two transforms (strip the default
layout: line, splice the Config JSON in place of the url/deepLinking
block) against the real vendored file, not typed from scratch —
verified byte-for-byte against what format_config() would produce for
hive-c0re's actual single-URL config, and checked with node --check.
Coordinated with damocles: he's taking the corresponding hive-c0re
side (drop the utoipa-swagger-ui dependency + SwaggerUi::new(...)
mount, keep only the plain /api/openapi.json route) once this lands.
Verified: nix fmt clean; nix build .#swagger-ui-theme succeeds, output
byte-matches the checked-in override files and node --check passes on
swagger-initializer.js; a full nixosSystem eval of nixosModules.default
resolves both new locations (/api/docs/ aliased to the right store
path, = /api/docs redirecting) with auth threaded through.
This commit is contained in:
parent
de1659d10e
commit
1bc9c18504
8 changed files with 166 additions and 76 deletions
|
|
@ -1,16 +1,13 @@
|
|||
<!-- Served by the gateway's nginx (an exact-match `location = /api/docs/`
|
||||
alias straight to this file's nix store path — see
|
||||
nix/host-modules/hive-gateway/vhosts.nix's swaggerThemeLocations),
|
||||
NOT by hive-c0re: a theme tweak here is a gateway config change,
|
||||
not a hive-c0re rebuild+restart. Byte-identical to the vendored
|
||||
Swagger UI's dist/index.html except two added <link>s: `colors.css`
|
||||
(same origin as the dashboard — so this resolves the operator's
|
||||
live stylix theme, not a frozen copy) and hyperhive-theme.css,
|
||||
which consumes its `--baseNN` vars. Every other path here (script
|
||||
src, other stylesheets, favicons) stays relative and falls through
|
||||
nginx's `/api/` prefix proxy to hive-c0re's own vendored,
|
||||
unmodified Swagger UI assets — only this file and
|
||||
hyperhive-theme.css are intercepted. -->
|
||||
<!-- Served by the gateway's nginx — one of 3 files (see also
|
||||
hyperhive-theme.css, swagger-initializer.js) that
|
||||
nix/packages/swagger-ui-theme.nix overlays onto the plain vendored
|
||||
dist (swagger-ui-dist.nix), and the whole result is what
|
||||
vhosts.nix's `swaggerUiLocations` serves at /api/docs/, wholesale,
|
||||
with NO hive-c0re fallback for any file in the tree. Byte-identical
|
||||
to the vendored Swagger UI's dist/index.html except two added
|
||||
<link>s: `colors.css` (same origin as the dashboard — so this
|
||||
resolves the operator's live stylix theme, not a frozen copy) and
|
||||
hyperhive-theme.css, which consumes its `--baseNN` vars. -->
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
|
|
|
|||
21
hive-c0re/swagger-ui-theme/swagger-initializer.js
Normal file
21
hive-c0re/swagger-ui-theme/swagger-initializer.js
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
window.onload = function() {
|
||||
//<editor-fold desc="Changeable Configuration Block">
|
||||
|
||||
// the following lines will be replaced by docker/configurator, when it runs in a docker-container
|
||||
window.ui = SwaggerUIBundle({
|
||||
"dom_id": "#swagger-ui",
|
||||
"url": "/api/openapi.json",
|
||||
"deepLinking": true,
|
||||
"layout": "StandaloneLayout",
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIStandalonePreset
|
||||
],
|
||||
plugins: [
|
||||
SwaggerUIBundle.plugins.DownloadUrl
|
||||
],
|
||||
|
||||
});
|
||||
|
||||
//</editor-fold>
|
||||
};
|
||||
Loading…
Reference in a new issue