[oapi] swagger path #292
-
Hi, how are you? I have an API with Openopi documentation using utoipa in this way [1] I am now trying to use the integration of Salvo-Openopi, but I am failing on the route to Swagger. In http://127.0.0.1:7887/api-doc/openapi.json I get correctly:
but in http://127.0.0.1:7887/swagger-ui/ I get 404 error My router tree is:
What do I have bad? [1] https://github.com/salvo-rs/salvo/tree/main/examples/todos-utoipa |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
It seems you attached your Swagger UI to http://127.0.0.1:7887/ |
Beta Was this translation helpful? Give feedback.
-
I simplified and cleaned the router function, but I still get the 404
|
Beta Was this translation helpful? Give feedback.
-
Try this and access http://127.0.0.1:7887/swagger-ui/: fn router(config: &Config) -> Router {
let router = Router::new()
.hoop(Logger::default())
.get(health::get_health)
.push(Router::with_path("health").get(health::get_health))
.push(Router::with_path("version").get(version::get_version));
let doc = OpenApi::new("TEST API", "0.0.1").merge_router(&router);
let router = router
.push(doc.into_router("/api-doc/openapi.json"))
.push(SwaggerUi::new("/api-doc/openapi.json").into_router("/swagger-ui"));
router
} |
Beta Was this translation helpful? Give feedback.
-
Some things are interesting:
Can extractors also use with #[handler]? Any doubts: How is "status_codes" used? When I used Utoipa "by hand" I could put the path explicitly:
Now I put it as docstrings |
Beta Was this translation helpful? Give feedback.
-
Can extractors also use with #[handler]? How is "status_codes" used? Is it possible to define the path so that it appears next to the "GET" button for example? |
Beta Was this translation helpful? Give feedback.
Try this and access http://127.0.0.1:7887/swagger-ui/: