use axum::http::{HeaderValue, StatusCode, header};
use axum::response::{IntoResponse, Response};
const OPENAPI_3_1: &str = include_str!("../../openapi/openapi.json");
const OPENAPI_3_0: &str = include_str!("../../openapi/openapi-3.0.json");
pub async fn serve_openapi_3_1() -> Response {
json_response(OPENAPI_3_1)
}
pub async fn serve_openapi_3_0() -> Response {
json_response(OPENAPI_3_0)
}
fn json_response(body: &'static str) -> Response {
let mut resp = (StatusCode::OK, body).into_response();
let headers = resp.headers_mut();
headers.insert(
header::CONTENT_TYPE,
HeaderValue::from_static("application/json; charset=utf-8"),
);
headers.insert(
header::ACCESS_CONTROL_ALLOW_ORIGIN,
HeaderValue::from_static("*"),
);
resp
}