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

Issue with Default Handler in resolver #844

Open
kesha-shah opened this issue May 18, 2023 · 1 comment
Open

Issue with Default Handler in resolver #844

kesha-shah opened this issue May 18, 2023 · 1 comment

Comments

@kesha-shah
Copy link
Contributor

kesha-shah commented May 18, 2023

Describe the bug
With this commit, there is one issue caused which is blocking us to use default exported functions in APIs

To Reproduce

  1. Use any version > 4.13.2 - This bug got introduced in version 4.13.4
  2. Create one HTTP API function, export it as default function, set it as operationId and set its path in x-eov-operation-handler
  3. Try to invoke that API

Actual behavior
It gives error Route.get() requires a callback function but got a [object Object]
Stacktrace :

Route.get() requires a callback function but got a [object Object]\n at Route. [as get] (/Users/keshashah/work/api-framework/node_modules/express/lib/router/route.js:211:15)\n at Function.proto. [as get] (/Users/keshashah/work/api-framework/node_modules/express/lib/router/index.js:521:19)\n at OpenApiValidator.installOperationHandlers (/Users/keshashah/work/api-framework/node_modules/express-openapi-validator/src/openapi.validator.ts:314:37)\n at /Users/keshashah/work/api-framework/node_modules/express-openapi-validator/src/openapi.validator.ts:215:30\n at processTicksAndRejections (internal/process/task_queues.js:95:5)","timestamp":"2023-05-18T06:02:49.057Z","type":"app-log"}

Expected behavior
It should return JSON or any expected response.

Examples and context
This bug got created because

const handler = tmpModules[modulePath][oId] || tmpModules[modulePath].default;

here if tmpModules[modulePath][oId] does not exist then it should first check handler from tmpModules[modulePath].default[oId] if that does not exist then only return tmpModules[modulePath].default

Is there any specific reason for this? or should I create a PR for this.
Currently all our function with exports.default with operationId are not working with this upgrade.

@kesha-shah
Copy link
Contributor Author

Proposed PR : #846

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

No branches or pull requests

1 participant