Context
GET /openapi.json is served from state.openapi mutex; both sync and async paths call openapi.lock().to_string() per request (src/dispatch.rs).
- OpenAPI document changes only at route registration / title update.
Problem
Repeated serialization and lock contention on a read-mostly document.
Proposed change
Files
src/state.rs, src/lib.rs, src/dispatch.rs
Acceptance criteria
/openapi.json body identical before/after change.
- No per-request full JSON serialization on cache hit.
- Tests cover route add and title change invalidation.
Expected low-level impact
Faster OpenAPI endpoint; less mutex work under load.
Context
GET /openapi.jsonis served fromstate.openapimutex; both sync and async paths callopenapi.lock().to_string()per request (src/dispatch.rs).Problem
Repeated serialization and lock contention on a read-mostly document.
Proposed change
Arc<str>orBytesonAppState.Files
src/state.rs,src/lib.rs,src/dispatch.rsAcceptance criteria
/openapi.jsonbody identical before/after change.Expected low-level impact
Faster OpenAPI endpoint; less mutex work under load.