(
rocket: rocket::Rocket<rocket::Build>,
doc: OpenApiDoc,
mount_path: impl Into<Cow<'static, str>>,
)
| 624 | |
| 625 | #[cfg(all(feature = "rocket", feature = "openapi"))] |
| 626 | pub fn mount_openapi_docs( |
| 627 | rocket: rocket::Rocket<rocket::Build>, |
| 628 | doc: OpenApiDoc, |
| 629 | mount_path: impl Into<Cow<'static, str>>, |
| 630 | ) -> rocket::Rocket<rocket::Build> { |
| 631 | let base = normalize_openapi_mount(mount_path.into()); |
| 632 | let spec_url = join_mount_path(base.as_ref(), "openapi.json"); |
| 633 | let rendered = doc.render(&spec_url); |
| 634 | let state = OpenApiState::from(rendered); |
| 635 | let mount_point = base.clone().into_owned(); |
| 636 | rocket |
| 637 | .manage(state) |
| 638 | .mount(mount_point, rocket::routes![openapi_spec, openapi_docs]) |
| 639 | } |
| 640 | |
| 641 | #[cfg(all(feature = "rocket", feature = "openapi"))] |
| 642 | fn normalize_openapi_mount(path: Cow<'static, str>) -> Cow<'static, str> { |
no test coverage detected