Replace api.v1.yaml with json variant
This commit is contained in:
parent
ea09061b29
commit
455ca50695
5 changed files with 1344 additions and 899 deletions
src
11
src/main.rs
11
src/main.rs
|
@ -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))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue