Replace api.v1.yaml with json variant

This commit is contained in:
Tobias Reisinger 2024-05-02 00:21:21 +02:00
parent ea09061b29
commit 455ca50695
Signed by: serguzim
GPG key ID: 13AD60C237A28DFE
5 changed files with 1344 additions and 899 deletions

View file

@ -70,9 +70,13 @@ async fn main() -> Result<(), std::io::Error> {
"title": "Failed to load API documentation",
}
});
let api_v1_json =
serde_json::from_str(include_str!(concat!(env!("OUT_DIR"), "/api.v1.json")))
.unwrap_or(api_default.clone());
let mut api_v1_json =
serde_json::from_str(include_str!("../api.v1.json")).unwrap_or(api_default.clone());
api_v1_json["servers"] = json!([{
"url": "/",
}]);
App::new()
.wrap(cors)
@ -84,6 +88,7 @@ async fn main() -> Result<(), std::io::Error> {
SwaggerUi::new("/api/docs/{_:.*}")
.external_urls_from_iter_unchecked([("/api/v1.json", api_v1_json)]),
)
.service(web::redirect("/api/docs", "/api/docs/"))
.service(
web::scope("/api/v1")
.wrap(middleware::NormalizePath::new(TrailingSlash::Trim))