Improve primitive route return guidance#151
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b4c56efce7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| : rawResponse.status | ||
| : rawResponse instanceof Response | ||
| ? rawResponse.status | ||
| : 200 |
There was a problem hiding this comment.
Preserve SerializableToResponse handling for non-WinterSpec types
Setting the fallback status to 200 here makes every non-Response/non-WinterSpecResponse return look successful, which sends custom SerializableToResponse objects into the validating path; serializeToResponse(...) then throws Unknown Response type for those objects because it only accepts WinterSpecResponse subclasses when validation is on. This is a regression for middleware/route handlers that return their own SerializableToResponse implementations (a supported type in Middleware/WinterSpecRouteFn) that previously serialized successfully.
Useful? React with 👍 / 👎.
a1e1d09 to
1573fbc
Compare
|
Closing this out as part of wrapping up my bounty/OSS cleanup. Thanks for the time and review. |
Summary
ctx.json(...)guidance for raw object and primitive return mistakesResponse/ctx.json(...)flows unchanged/claim #30
Validation
npx ava tests/errors/do-not-allow-raw-json.test.ts --verbosenpx prettier --check src/create-with-winter-spec.ts src/middleware/with-response-object-check.ts tests/errors/do-not-allow-raw-json.test.tsgit diff --checkNote
npm test -- tests/errors/do-not-allow-raw-json.test.tscurrently stops in the package pretest build on pre-existing OpenAPI codegen TypeScript errors (operation.responsespossibly undefined) before this test file runs.