Repository navigation
Commit 142bb4e
Defer reading the OpenAPI spec until it is first requested
SwaggerServlet read the full OpenAPI spec during server startup. Nothing
used that result: OpenApiResource, which serves /api/openapi.json and
/api/openapi.yaml, builds its own child context from the configuration
SwaggerServlet registers and reads the spec again on the first request.
Register the configuration only. The served spec is unchanged, and the
Swagger servlet's init drops from about 660 ms to about 120 ms on a warm
start, taking about 0.5 s off the time until the web server is up.
The startup read did warm up class loading and Jackson introspection,
so the first spec request now takes longer (about 460 ms to 700 ms on
a warm start). That request normally comes from someone opening the
Swagger UI, which is a better place for the cost than server startup.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Jon Bartels <jonathan.bartels@gmail.com>1 parent fdff780 commit 142bb4e
1 file changed
Lines changed: 4 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
73 | 76 | | |
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
77 | | - | |
78 | | - | |
| 80 | + | |
79 | 81 | | |
80 | 82 | | |
81 | 83 | | |
| |||
0 commit comments