forked from cdimascio/express-openapi-validator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support ESM import of handler module in default resolver
Make the default request handler resolver work in ESM projects by allowing a URL value for the handlersPath. If a URL is passed, then a dynamic import will be used to load the handler module. If a string is passed, then require() will be used. Because this project uses moduleResolution:node in tsconfig, it's not possible to write async import(...) directly in code. It has to be obscured so that the compiler does not replace it, hence the HACK! function that is essentially eval('import(...)'). ESM users should be aware that a file extension must be specified when defining x-eov-operation-handler in schemas. For example: ``` { "get": { "summary": "Get list", "x-eov-operation-id": "getList", "x-eov-operation-handler": "list.js", "responses": { ... ```
- Loading branch information
1 parent
a59f659
commit ee2841e
Showing
3 changed files
with
25 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters