Repository navigation
feat(openapi): support enum and union status in detailed responses - #2187
Conversation
EffectSchemaToJsonSchemaConverter emits `Schema.Literal(201)` as
`{ type: 'number', enum: [201] }` rather than `{ const: 201 }`, so
`outputStructure: 'detailed'` with an Effect literal status made
OpenAPIGenerator.generate() throw 'invalid "status" field'. Treat a
single-value `enum` the same as `const` when reading the status.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K42euCFhMfYXSaxkobuBdz
…ed output status A detailed output `status` may now be any union of literal statuses: a multi-value `enum` (zod `z.literal([200, 201])`, valibot `picklist`, arktype `'200 | 201'`, Effect `Schema.Literals`) or an `anyOf` of `const`/`enum` schemas (zod/valibot unions of literals). The member's headers and body are documented under each status, and a description on an individual union member applies only to its own statuses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K42euCFhMfYXSaxkobuBdz
Fold the single-value enum, multi-value enum, and literal union cases into one `it.each` table, rename the stale "not a const integer" case, and cover an empty status union. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K42euCFhMfYXSaxkobuBdz
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
orpc | 1449575 | Commit Preview URL Branch Preview URL |
Oct 06 2026, 03:47 AM |
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/bun
@orpc/client
@orpc/cloudflare
@orpc/contract
@orpc/experimental-effect
@orpc/evlog
@orpc/hibernation
@orpc/json-schema
@orpc/experimental-lock
@orpc/experimental-msw
@orpc/nest
@orpc/next
@orpc/node
@orpc/openapi
@orpc/opentelemetry
@orpc/pinia-colada
@orpc/pino
@orpc/publisher
@orpc/ratelimit
@orpc/server
@orpc/shared
@orpc/swr
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/zod
commit: |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — reviewed the full 3-file diff at 129d8eb, covering multi-status detailed output support end-to-end.
- Multi-status extraction (
packages/openapi/src/openapi-generator-operation.ts): newextractDetailedStatusesnormalizesconst,enum, andanyOf/oneOfunions throughflattenJsonUnionSchemaand rejects non-integer values, values>= 400, and empty unions/enums;extractDetailedResponsePartsnow emits one response per extracted status, sharing the member'sheaders/bodyand applying the flattened member description per status. - Tests (
packages/openapi/src/openapi-generator-operation.test.ts): table-driven success cases (single-value enum, multi-value enum, mixedconst/enumunion with parent-description merging) assert fulloperation.responsesdeep-equality, plus rejection rows for out-of-range enums, empty enum/union, and non-literal/non-integer members. - Docs (
apps/content/docs/openapi/input-and-output-mapping.mdx): documents literal/union status and thez.literal([200, 201])shorthand.
I independently verified the load-bearing claims: zod, Effect, arktype, and valibot emit the enum/const/anyOf shapes the new parser accepts; z.literal([200, 201]) validates at runtime so the docs example is correct; the full @orpc/openapi suite (489 tests) passes; and type:check / eslint are clean.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K42euCFhMfYXSaxkobuBdz

Summary
Extends the OpenAPI generator to support multiple status codes in detailed output responses. Previously, only a single literal status (
const) was allowed. Now supportsenum(how Effect, arktype, and valibot emit picklists) and unions of literals (anyOf), enabling a single response definition to document multiple success status codes with shared headers and body schemas.Changes
extractDetailedStatuses()function to extract all valid status codes fromconst,enum, oranyOfunion schemasextractDetailedResponseParts()to iterate over all extracted statuses and create separate OpenAPI response entries for each, inheriting the same headers and body schemaImplementation Details
flattenJsonUnionSchema()helper is reused to normalize both directenum/constschemas andanyOfunionsconstandenummembershttps://claude.ai/code/session_01K42euCFhMfYXSaxkobuBdz