-
-
Notifications
You must be signed in to change notification settings - Fork 481
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
postTransform would be more useful with schema information #2013
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 |
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: