Add async support and unified type for patch.input and patch() shorthand#3411
Merged
Add async support and unified type for patch.input and patch() shorthand#3411
Conversation
|
|
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: ba9f893 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add patch.spec callback for full-spec transformations
Add patch.input and shorthand patch() for full-spec transformations
Feb 17, 2026
Co-authored-by: mrlubos <12529395+mrlubos@users.noreply.github.com>
Copilot
AI
changed the title
Add patch.input and shorthand patch() for full-spec transformations
Add async support and unified type for patch.input and patch() shorthand
Feb 17, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3411 +/- ##
==========================================
+ Coverage 38.91% 38.93% +0.01%
==========================================
Files 473 473
Lines 17287 17292 +5
Branches 5210 5212 +2
==========================================
+ Hits 6727 6732 +5
Misses 8480 8480
Partials 2080 2080
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@hey-api/codegen-core
@hey-api/json-schema-ref-parser
@hey-api/nuxt
@hey-api/openapi-ts
@hey-api/shared
@hey-api/types
@hey-api/vite-plugin
commit: |
Add `patch.input` and shorthand `patch()` option for full specification transformations
mrlubos
approved these changes
Feb 17, 2026
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.
The
patch.inputcallback and shorthandpatch()function used different types and did not support async operations, preventing users from performing asynchronous transformations during spec patching.Changes
PatchInputFntype accepting both sync and async functions (void | Promise<void>), used by bothpatch.inputand shorthandpatch()patchOpenApiSpecasync: Function now awaits patch callbacks, enabling async operations like fetching external data or reading filesopenapi-tsandopenapi-pythoncreateClientfunctions now awaitpatchOpenApiSpecExample
Original prompt
This section details on the original issue you should resolve
<issue_title>Feature: Add patch.spec callback for full-spec transformations</issue_title>
<issue_description>### Description
Description
The
parser.patchconfiguration provides targeted patching forschemas,operations,parameters,requestBodies,responses,meta, andversion. These are excellent for surgical fixes to individual named resources.However, there is currently no way to perform bulk or structural transformations on the raw spec before parsing -- such as adding new component definitions and injecting parameter references across many operations at once.
Use Case
We maintain a Vue.js frontend for OpenBMC that consumes the DMTF Redfish OpenAPI specification (~240k lines). The Redfish spec omits standard query parameters (
$expand,$select,$filter,$top,$skip, etc.) from individual operations, even though they are part of the Redfish protocol for all GET endpoints.We need to:
components.parameters(the Redfish query parameter definitions don't exist in the upstream spec)$refparameters to every GET operation under/redfish/v1/(thousands of paths)The existing
patchoptions cannot achieve this because:patch.parameterscan only modify existing component parameters (lookup by key inspec.components.parameters), not create new onespatch.operationsrequires enumerating every operation by exact key (e.g.,'GET /redfish/v1/Systems') -- impractical for thousands of paths with no wildcard/regex supportpatch.metaonly receivesspec.info, not the full specWe currently handle this with a separate preprocessing script, but would prefer to consolidate into the
openapi-tsconfig using the parser.Proposed Solution
Add an optional
speccallback to thePatchtype that receives the entire raw OpenAPI spec object, invoked before any other patch callbacks:Example usage
Alternatives Considered
Dynamic
patch.operationsmap: Pre-read the spec file in the config to discover all GET paths and build a map with thousands of entries. Works but is roundabout -- the config reads the same file thatinputpoints to.Regex/glob support in
patch.operationskeys: Would help with the operation...✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.