Skip to content

Issue with Default Handler in resolver #844

Open
@kesha-shah

Description

@kesha-shah

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions