cdimascio / express-openapi-validator

🦋 Auto-validates api requests, responses, and securities using ExpressJS and an OpenAPI 3.x specification
MIT License
920 stars 211 forks source link

Breaking change in signature for resolver function #952

Closed csuermann closed 2 months ago

csuermann commented 3 months ago

Describe the bug https://github.com/cdimascio/express-openapi-validator/pull/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.