add scalar at openapi2.html

This commit is contained in:
Ruben Fiszel
2024-04-08 01:42:43 +02:00
parent 9c09e948a6
commit b2362c8263
3 changed files with 33 additions and 1 deletions

View File

@@ -5,5 +5,7 @@ npx @redocly/openapi-cli@latest bundle openapi.yaml > openapi-bundled.yaml
npx @redocly/openapi-cli@latest bundle openapi-bundled.yaml --ext yaml -d > openapi-deref.yaml
npx @redocly/openapi-cli@latest bundle openapi-bundled.yaml --ext json > openapi-deref.json
rm openapi-bundled.yaml

View File

@@ -279,7 +279,8 @@ pub async fn run_server(
.route("/version", get(git_v))
.route("/uptodate", get(is_up_to_date))
.route("/ee_license", get(ee_license))
.route("/openapi.yaml", get(openapi)),
.route("/openapi.yaml", get(openapi))
.route("/openapi.json", get(openapi_json)),
)
.fallback(static_assets::static_handler)
.layer(middleware_stack);
@@ -367,6 +368,10 @@ async fn openapi() -> &'static str {
include_str!("../openapi-deref.yaml")
}
async fn openapi_json() -> &'static str {
include_str!("../openapi-deref.json")
}
pub async fn migrate_db(db: &DB) -> anyhow::Result<()> {
db::migrate(db).await?;
Ok(())

View File

@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<title>API Reference</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
</head>
<body>
<!-- Add your own OpenAPI/Swagger spec file URL here: -->
<!-- Note: this includes our proxy, you can remove the following line if you do not need it -->
<!-- data-proxy-url="https://api.scalar.com/request-proxy" -->
<script id="api-reference" data-url="/api/openapi.json"></script>
<!-- You can also set a full configuration object like this -->
<!-- easier for nested objects -->
<script>
var configuration = {
theme: 'purple'
}
var apiReference = document.getElementById('api-reference')
apiReference.dataset.configuration = JSON.stringify(configuration)
</script>
<script src="https://cdn.jsdelivr.net/npm/@scalar/api-reference"></script>
</body>
</html>