feat: allow swagger operation customization via transformOperation#11
Merged
sjorobekov merged 3 commits intomainfrom Mar 18, 2026
Merged
feat: allow swagger operation customization via transformOperation#11sjorobekov merged 3 commits intomainfrom
sjorobekov merged 3 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new transformOperation hook to the OpenAPI registry so callers can programmatically patch the generated OpenAPI operation per-route (based on method/path/route description), and updates docs/tests accordingly.
Changes:
- Extend
createOpenApiRegistryconfig withtransformOperation(operation, context)to customize operations before registration. - Refactor operation-building logic in
openapi-registry.tsand add test coverage for the new hook. - Simplify and update
README.mdwith a new “Customizing the OpenAPI operation” section.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/types.ts | Adds transformOperation to OpenApiRegistryConfig and introduces OpenApiOperation type. |
| src/openapi-registry.ts | Wires transformOperation into route registration and refactors operation construction helpers. |
| src/tests/openapi-registry.test.ts | Adds tests verifying operation patching and transformer context. |
| src/index.ts | Re-exports OpenApiRegistry type from the public entrypoint. |
| README.md | Simplifies docs and documents transformOperation usage. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
imsitnikov
previously approved these changes
Mar 17, 2026
imsitnikov
approved these changes
Mar 18, 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.
Summary
This PR introduces
transformOperation, a new callback increateOpenApiRegistrythat allows for fine-grained customization of generated OpenAPI operations.Additionally, the
README.mdhas been significantly simplified to make the documentation clearer and more focused.Details
🛠
transformOperationCallbackPreviously, customizing the generated OpenAPI specs for specific routes was limited to what the built-in wrappers provided. The new
transformOperationcallback gives developers full control to patch theOpenApiOperationobject right before it is registered.How it works:
The callback receives the current
operationobject and acontextobject containing the HTTPmethod, the OpenAPI-formattedpath, and the fullAppRouteDescription(route).Example Usage: