fix(crud): support distinct getResponseSchema for detail endpoints#12
Merged
fix(crud): support distinct getResponseSchema for detail endpoints#12
Conversation
GET /api/v1/incidents/{id} returns IncidentDetailDto (with updates +
status-page incidents), not the flat IncidentDto. The single
responseSchema was rejecting valid responses with a strict envelope
validation error.
Mirror the createResponseSchema pattern: add an optional
getResponseSchema that defaults to responseSchema, and wire it into
INCIDENTS so list still validates against IncidentDto while get
validates against the wider detail DTO.
Made-with: Cursor
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.
Summary
GET /api/v1/incidents/{id}returns the fullIncidentDetailDtoenvelope (
{incident, updates, statusPageIncidents}), not the flatIncidentDtoreturned byGET /api/v1/incidents. The strict responsevalidator was rejecting valid detail responses with:
This was caught by the monorepo's surface-integration suite
(
tests/surfaces/cli/test_incidents.py::TestIncidentsCRUD::test_create_resolve_delete)on PR devhelmhq/mono#246.
Fix
Mirror the existing
createResponseSchemapattern: add an optionalgetResponseSchematoResourceConfigthat defaults toresponseSchema, and wire it into theINCIDENTSresource so:liststill validates againstIncidentDtogetandcreatevalidate againstIncidentDetailDtoNo behaviour change for any other resource (default fall-through
preserves the strict envelope used everywhere else).
Test plan
npm run typechecknpm test(856 unit tests pass)incidents create → get → resolve → deleteflow now passes end-to-end againstmonotest stackmake test-surface SURFACE=cli(303 passed, 1 skipped) — green when paired with this branchMade with Cursor