-
-
Notifications
You must be signed in to change notification settings - Fork 528
postTransform would be more useful with schema information #2013
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
Comments
I was able to reach the schema node a bit indirectly. Rather than change the postTransform(type: ts.TypeNode, options: openapiTS.TransformNodeOptions): ts.TypeNode {
const schema = options.path ?
options.ctx.resolve<openapiTS.ReferenceObject | openapiTS.SchemaObject>(options.path) :
undefined;
if (
schema &&
!("$ref" in schema) &&
Object.hasOwn(schema, "x-my-custom-property")
) {
return ts.factory.createUnionTypeNode(…);
}
return type;
} It was still a bit of a chore to discover this path, but since all the necessary pieces seem to be present, perhaps this issue should be closed. |
Ha that’s clever! But agreed we could make this easier. We’d accept adding anything onto |
* Add schema to postTransform options Closes openapi-ts#2013 * fixup! Add schema to postTransform options Closes openapi-ts#2013 * fixup! Add schema to postTransform options Closes openapi-ts#2013 * fixup! Add schema to postTransform options
* Add schema to postTransform options (#2049) * Add schema to postTransform options Closes #2013 * fixup! Add schema to postTransform options Closes #2013 * fixup! Add schema to postTransform options Closes #2013 * fixup! Add schema to postTransform options * Add Netlify badge (#2065) * Only check GitHub token for docs build when update needed * Add Netlify badge * Use link * [ci] release (#2084) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> * Fix issue templates (#2088) * Add feat issues to projects (#2090) * Use const arrays for OpenAPI enum types Preserve capitalization of named, exported enum values. Type exported const values as const, instead of their location within the operations or components schemas. Derive and export types for enum values from concrete values in const arrays. Use derived enum value types in operations and components schemas. Use non-conflicting variable names for composed OpenAPI enums (anyOf: [enum1, enum2]) * Export type-predicates along when enumValues is true --------- Co-authored-by: Drew Powers <[email protected]> Co-authored-by: openapi-ts-bot <[email protected]> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Description
The
postTransform
option is handed the ts types as they're generated from each OpenAPI schema member intransformSchemaObject
.However, although there is a 1:1 mapping between calls to the
postTransform
, and OpenAPI schema members,postTransform
has no access to the OpenAPI schema object associated with the generated ts node.I think
postTransform
would be more useful if it gave access to the schema node, and it should be added to theoptions
argument, passed topostTransform
, along withpath
andctx
.Checklist
The text was updated successfully, but these errors were encountered: