Skip to main content

ironflow_api/routes/
openapi_spec.rs

1//! `GET /api/v1/openapi.json` -- OpenAPI specification.
2
3use axum::response::{IntoResponse, Response};
4
5/// Serve the OpenAPI specification as JSON.
6///
7/// When the `openapi` feature is disabled, returns 404.
8pub async fn openapi_spec() -> Response {
9    #[cfg(feature = "openapi")]
10    {
11        use axum::Json;
12        use utoipa::OpenApi;
13
14        use crate::openapi::ApiDoc;
15
16        Json(ApiDoc::openapi()).into_response()
17    }
18
19    #[cfg(not(feature = "openapi"))]
20    {
21        axum::http::StatusCode::NOT_FOUND.into_response()
22    }
23}