Skip to content

feat(openapi)!: replace shouldHoistDef with customComponentName option in generator - #1728

Merged
dinwwwh merged 1 commit into
middleapi:mainfrom
dinwwwh:claude/openapi-hoisting-options-3be20a
Jul 26, 2026
Merged

feat(openapi)!: replace shouldHoistDef with customComponentName option in generator#1728
dinwwwh merged 1 commit into
middleapi:mainfrom
dinwwwh:claude/openapi-hoisting-options-3be20a

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Jul 26, 2026

Copy link
Copy Markdown
Member

Root-level $defs are now always hoisted into components.schemas. The shouldHoistDef option is gone, replaced by customComponentName for renaming the resulting components.

const spec = await generator.generate(router, {
  customComponentName: defName => `Api${defName}`,
})
  • Returning undefined keeps the original def name.
  • Conflicting names still fall back to the existing postfix rules (Planet, PlanetInput, Planet2, ...).
  • Error components no longer put the default message in their message schema. Procedures that declare the same error code with different messages now share one component, and the message still shows up in the response description.

Root-level `$defs` are now always hoisted into `components.schemas`, and
`customComponentName` lets users rename the resulting components instead.

Error components no longer carry the default message in their `message`
schema, so procedures sharing an error code reuse a single component.
@vercel

vercel Bot commented Jul 26, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
orpc Ready Ready Preview, Comment Jul 26, 2026 5:34am

@dinwwwh dinwwwh changed the title refactor(openapi)!: replace shouldHoistDef with customComponentName feat(openapi)!: replace shouldHoistDef with customComponentName Jul 26, 2026
@pkg-pr-new

pkg-pr-new Bot commented Jul 26, 2026

Copy link
Copy Markdown
More templates

@orpc/ai-sdk

npm i https://pkg.pr.new/@orpc/ai-sdk@1728

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@1728

@orpc/bun

npm i https://pkg.pr.new/@orpc/bun@1728

@orpc/client

npm i https://pkg.pr.new/@orpc/client@1728

@orpc/cloudflare

npm i https://pkg.pr.new/@orpc/cloudflare@1728

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@1728

@orpc/experimental-effect

npm i https://pkg.pr.new/@orpc/experimental-effect@1728

@orpc/evlog

npm i https://pkg.pr.new/@orpc/evlog@1728

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@1728

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@1728

@orpc/next

npm i https://pkg.pr.new/@orpc/next@1728

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@1728

@orpc/opentelemetry

npm i https://pkg.pr.new/@orpc/opentelemetry@1728

@orpc/pinia-colada

npm i https://pkg.pr.new/@orpc/pinia-colada@1728

@orpc/pino

npm i https://pkg.pr.new/@orpc/pino@1728

@orpc/publisher

npm i https://pkg.pr.new/@orpc/publisher@1728

@orpc/ratelimit

npm i https://pkg.pr.new/@orpc/ratelimit@1728

@orpc/server

npm i https://pkg.pr.new/@orpc/server@1728

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@1728

@orpc/swr

npm i https://pkg.pr.new/@orpc/swr@1728

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@1728

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@1728

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@1728

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@1728

commit: ff4d3db

@codecov

codecov Bot commented Jul 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dinwwwh dinwwwh changed the title feat(openapi)!: replace shouldHoistDef with customComponentName feat(openapi)!: replace shouldHoistDef with customComponentName option in generator Jul 26, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — this PR removes shouldHoistDef and replaces it with customComponentName. All root-level $defs are now always hoisted into components.schemas; customComponentName controls how they're renamed. Error components also shed their baked-in default message for better reuse.

  • customComponentName replaces shouldHoistDef — the OpenAPIComponentRegistry constructor and OpenAPIGeneratorGenerateOptions now accept a (defName, defSchema) => string | undefined callback instead of a Value<boolean> predicate. All defs are always hoisted.
  • ~90 lines of dead code removedvisitLocalDefRefs, hoistReferencedLocalDefs, withReferencedLocalDefs, and collectReferencedLocalDefNames are gone, along with unused imports of visitJsonSchemaRefs and Value.
  • Error message default removed — error components no longer carry the per-procedure defaultMessage in their message schema. Procedures sharing the same error code but with different messages now reuse the same component.
  • Docs updated — the specification docs reflect the new customComponentName API.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@codspeed-hq

codspeed-hq Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing dinwwwh:claude/openapi-hoisting-options-3be20a (ff4d3db) with main (8bbe5f0)

Open in CodSpeed

@dinwwwh
dinwwwh merged commit 6941896 into middleapi:main Jul 26, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant