Skip to content

Commit

Permalink
Don't make a serialization roundtrip in openapi.json route (#1269)
Browse files Browse the repository at this point in the history
  • Loading branch information
svix-jplatte authored Mar 13, 2024
1 parent 2061286 commit 80e7265
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions server/svix-server/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,6 @@ mod docs {
use axum::{
response::{Html, IntoResponse, Redirect},
routing::get,
Json,
};

// TODO: switch to generated docs instead of hardcoded JSON once generated
Expand All @@ -345,8 +344,7 @@ mod docs {
}

async fn get_openapi_json() -> impl IntoResponse {
let json: serde_json::Value = serde_json::from_str(include_str!("static/openapi.json"))
.expect("Error: openapi.json does not exist");
Json(json)
static BODY: &str = include_str!("static/openapi.json");
([(http::header::CONTENT_TYPE, "application/json")], BODY)
}
}

0 comments on commit 80e7265

Please sign in to comment.