-
-
Notifications
You must be signed in to change notification settings - Fork 591
feat(openapi-typescript): add transformProperty hook for property signature modification #2449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(openapi-typescript): add transformProperty hook for property signature modification #2449
Conversation
…nature modification Adds a new transformProperty hook that allows users to modify individual property signatures within Schema Objects. This enables adding JSDoc validation annotations and other property-level modifications that can't be achieved with existing transform/postTransform hooks. Features: - New transformProperty option in OpenAPITSOptions - Hook integration in schema-object transformer - Comprehensive documentation with JSDoc validation examples - Test coverage for JSDoc annotations and edge cases Resolves openapi-ts#2448
❌ Deploy Preview for openapi-ts failed.
|
🦋 Changeset detectedLatest commit: fcd7122 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 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 |
- Format transformProperty type definition for better readability - Apply biome formatting to feature-related test code - Keep changes focused only on transformProperty feature files
|
any idea when this might merge? |
|
Hey @htunnicliff @gzm0 @kerwanp — would you have a moment to review PR #2449? It adds a small transformProperty hook for property-level customization (non-breaking). Drew was supportive of the direction in the discussion but has been busy. Happy to rebase/split/edit to make this easy to merge. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Thank you for proposing, investigating, and implementing everything (and for your patience)! Will ship this out later today
|
|
||
| // Apply transformProperty hook if available | ||
| if (typeof options.ctx.transformProperty === "function") { | ||
| const result = options.ctx.transformProperty(property, v as SchemaObject, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. This is what we do in a lot of other places, too—don’t just test the presence of the hook, but also test if it returns something. A consumer may pass this, but still return undefined or null when they want to skip the transformation.
| export type $defs = Record<string, never>; | ||
| export type operations = Record<string, never>;`, | ||
| options: { | ||
| transformProperty(property, schemaObject, _options) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great not only as a test, but many users rely on tests to see examples of usage. Especially working with TypeScript’s comment API which can be unwieldy, users will get a lot of mileage out of this ❤️
|
Note: failed Netlify deploy is unrelated; we had a problem with Netlify on the HEAD commit for this that’s since been fixed. |
Changes
Adds a new
transformPropertyhook that allows users to modify individual property signatures within Schema Objects. This enables adding JSDoc validation annotations and other property-level modifications that can't be achieved with existingtransform/postTransformhooks.Related Issue: Resolves #2448
Features Added:
transformPropertyoption inOpenAPITSOptionsHow to Review
src/transform/schema-object.tsfor hook integrationsrc/types.tsfor the new interfacedocs/node.mdfor examples and explanationspnpm testto verify new test cases passKey files to focus on:
src/transform/schema-object.ts- Main implementationdocs/node.md- Documentation with examplestest/node-api.test.ts- Test coverageChecklist
docs/updated (if necessary)pnpm run update:examplesrun (only applicable for openapi-typescript)