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

Use lenient resolver return type #956

Merged
merged 1 commit into from
Aug 31, 2024
Merged

Conversation

mdmower-csnw
Copy link
Contributor

In #921, a stronger type was 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

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
@mdmower-csnw
Copy link
Contributor Author

@csuermann - could you confirm that this would fix the issue you ran into in #952? A quick way to test would be to manually edit node_modules/express-openapi-validator/dist/framework/types.d.ts in your project, changing

export declare type OperationHandlerOptions = {
    basePath: string;
    resolver: (handlersPath: string, route: RouteMetadata, apiDoc: OpenAPIV3.Document) => RequestHandler | Promise<RequestHandler>;
};

to

export declare type OperationHandlerOptions = {
    basePath: string;
    resolver: (handlersPath: string, route: RouteMetadata, apiDoc: OpenAPIV3.Document) => unknown;
};

When you're done testing, that file could be restored.

@csuermann
Copy link

Hi @mdmower-csnw! Thank you! That seems to work!

@mdmower-csnw mdmower-csnw changed the title Use lenient resolver type Use lenient resolver return type Aug 31, 2024
@mdmower-csnw
Copy link
Contributor Author

@cdimascio - this is ready for review. It fixes an issue I introduced.

Copy link
Owner

@cdimascio cdimascio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

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 this pull request may close these issues.

Breaking change in signature for resolver function
3 participants