swagger-api / swagger-api/swagger-codegen

Generated node server fails with: "Cannot resolve the configured swagger-router handler:"

Open
#7,039 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

Node server stub generated from Swagger 2.0 specification starts up fine, but throws an error on sending the request.

Here is the error log:

Error: Cannot resolve the configured swagger-router handler: Transactions_GET-transaction
    at swaggerRouter (C:\nodejs-server-server\node_modules\swagger-tools\middleware\swagger-router.js:414:18)
    at call (C:\nodejs-server-server\node_modules\connect\index.js:239:7)
    at next (C:\nodejs-server-server\node_modules\connect\index.js:183:5)
    at C:\nodejs-server-server\node_modules\swagger-tools\middleware\swagger-validator.js:352:30
    at C:\nodejs-server-server\node_modules\async\lib\async.js:52:16
    at C:\nodejs-server-server\node_modules\async\lib\async.js:361:13
    at C:\nodejs-server-server\node_modules\async\lib\async.js:52:16
    at async.forEachOf.async.eachOf (C:\nodejs-server-server\node_modules\async\lib\async.js:236:30)
    at _asyncMap (C:\nodejs-server-server\node_modules\async\lib\async.js:355:9)
    at Object.map (C:\nodejs-server-server\node_modules\async\lib\async.js:337:20)
Swagger-codegen version
Swagger declaration file content or url

https://app.swaggerhub.com/apis/RitwikChatterjee/transactions/1.0.1

Command line used for generation

Used editor.swagger.io and www.swaggerhub.com to download the generated server stub

Steps to reproduce
  1. Copy Swagger file into editor.swagger.io or www.swaggerhub.com
  2. Generate server -> Nodejs-server
  3. Save, extract and go to folder.
  4. Start server with npm start
  5. Hit http://localhost:8080/transactions/123
Related issues/PRs

None

Suggest a fix/enhancement

Looks like a dependency is broken. Not sure what though.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure by generating a Nodejs-server stub from the linked Swagger declaration, starting it with npm start, and requesting /transactions/123. Inspect the generated route and handler name alongside swagger-router's handler resolution; done means the request no longer reports that the configured handler cannot be resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.