fix: allow overriding status route response schemas - #300
Merged
Merged
Conversation
Tony133
marked this pull request as ready for review
September 17, 2026 15:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposal:
The status route schema is built with:
so any
responseprovided inrouteSchemaOptsis silently discarded, androuteResponseSchemaOptsonly affects the 200 properties. When the app uses a custom error handler that returns a payload with a different shape, the fields are stripped by the hard-coded 503 schema and/statusreplies with503 {}.There is currently no option to work around this.
Changes:
routeSchemaOpts.responseentries are merged over the defaults and take precedence (so 500/503, or any additional status code, can be customized).200,propertiesare merged instead of replaced, sostatusis always present as documented.routeResponseSchemaOptskeeps working as before.responseis provided.A
responsekey inrouteSchemaOptsthat was previously ignored is now applied. I believe this is what users passing it expected, but flagging it so you can decide whether this should go out as a patch or a minor.Note:
status(androuteResponseSchemaOptsprops)codeandmessageare already part of the default 503 schema. The bug shows up as soon as the error handler uses any other field, e.g.{ ok: false, reason }.The two new tests fail on
mainand pass with this change. Coverage stays at 100%.Fixes #206