Skip to content
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

Breaking change in signature for resolver function #952

Closed
csuermann opened this issue Aug 28, 2024 · 0 comments · Fixed by #956
Closed

Breaking change in signature for resolver function #952

csuermann opened this issue Aug 28, 2024 · 0 comments · Fixed by #956

Comments

@csuermann
Copy link

Describe the bug
#921 changed the signature of the resolver function from

resolver: Function;

to

resolver: (
    handlersPath: string,
    route: RouteMetadata,
    apiDoc: OpenAPIV3.Document,
  ) => RequestHandler | Promise<RequestHandler>;

This breaks backwards-compatibility as Express request handlers can also be arrays of request handlers.

I believe the signature should instead be

resolver: (
    handlersPath: string,
    route: RouteMetadata,
    apiDoc: OpenAPIV3.Document,
  ) => RequestHandler | Promise<RequestHandler> | Array<RequestHandler> | Promise<Array<RequestHandler>>;

Unfortunately more tweaks seem to be required which I haven't found the time to investigate.

mdmower-csnw added a commit to CSNW/express-openapi-validator that referenced this issue Aug 30, 2024
In cdimascio#921, a stronger type applied to OperationHandlerOptions['resolver']
so that end users would have an idea of what the parameters are for
their custom resolvers. It went too far in stipulating a return type.
Set the return type to unknown and let users decide how much type safety
they need in their resolver.

Fixes cdimascio#952
cdimascio pushed a commit that referenced this issue Aug 31, 2024
In #921, a stronger type applied to OperationHandlerOptions['resolver']
so that end users would have an idea of what the parameters are for
their custom resolvers. It went too far in stipulating a return type.
Set the return type to unknown and let users decide how much type safety
they need in their resolver.

Fixes #952
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant