aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/api/mod.rs16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/api/mod.rs b/src/api/mod.rs
index c4265fb..82b5010 100644
--- a/src/api/mod.rs
+++ b/src/api/mod.rs
@@ -36,6 +36,7 @@ use axum::{
};
use serde_json::{Value as JsonValue, json};
use tracing::{error, warn};
+#[cfg(feature = "swagger-ui")]
use utoipa_swagger_ui::SwaggerUi;
use crate::api::auth::{AuthState, basic_auth};
@@ -140,17 +141,18 @@ pub(crate) fn router(state: AppState, auth_state: AuthState, debug_api: bool) ->
// Outermost: pages of other origins, and their preflights, which bring no
// credentials.
.layer(middleware::from_fn_with_state(state.clone(), cors::cors))
- // The hand-written spec (`docs/openapi.yaml`), and the Swagger UI showing it.
- .merge(
- // Relative to the UI's page (`/swagger-ui/`), so it is found behind a proxy that
- // serves the API under a path of its own too.
- SwaggerUi::new("/swagger-ui")
- .config(utoipa_swagger_ui::Config::from("../openapi.yaml")),
- )
+ // The hand-written spec (`docs/openapi.yaml`).
.route("/openapi.yaml", get(openapi_spec))
// Logging in by key: a challenge, and the token for it signed, without a password.
.route("/auth/challenge", axum::routing::post(login::challenge))
.route("/auth/login/key", axum::routing::post(login::login_key));
+ // The Swagger UI showing the spec, where it is built in.
+ #[cfg(feature = "swagger-ui")]
+ let router = router.merge(
+ // Relative to the UI's page (`/swagger-ui/`), so it is found behind a proxy that
+ // serves the API under a path of its own too.
+ SwaggerUi::new("/swagger-ui").config(utoipa_swagger_ui::Config::from("../openapi.yaml")),
+ );
// A party's login by its key, on a node holding a federated store.
#[cfg(feature = "federation")]
let router = router.route("/auth/login/party", axum::routing::post(login::login_party));