OpenAPITools / OpenAPITools/openapi-generator
[BUG] nodejs-express-server Controller.js response.end() not found
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- What's the version of OpenAPI Generator used? 4.3.1
- Have you search for related issues/PRs?
- What's the actual output vs expected output?
Description
nodejs-express-server generator generates code that doesn't work well.
Specifically it produces Controller.js with calls to response.end() while it doesn't seem to be defined.
E.g.:
static sendError(response, error) {
response.status(error.code || 500);
if (error.error instanceof Object) {
response.json(error.error);
} else {
response.end(error.error || error.message);
}
}
Here the call to response.end() raises Method not allowed error on the front-end instead not the actual error whatever it was.
Here is a part of my package.json:
{
"dependencies": {
"body-parser": "^1.19.0",
"camelcase": "^5.3.1",
"cookie-parser": "^1.4.4",
"cors": "^2.8.5",
"express": "^4.16.4",
"express-openapi-validator": "^3.9.1",
"js-yaml": "^3.13.1",
"lodash": "^4.17.15",
"nodemon": "^2.0.4",
"ono": "^5.0.1",
"openapi-sampler": "^1.0.0-beta.15",
"swagger-ui-express": "^4.0.2",
"winston": "^3.2.1"
},
"devDependencies": {
"axios": "^0.19.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"eslint": "^5.16.0",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.17.2",
"mocha": "^7.1.1"
},
}
openapi-generator version
4.3.1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by examining the generated Controller.js, especially the sendError method and its response.end() call. Reproduce the issue with the nodejs-express-server generator using the reported OpenAPI Generator 4.3.1 setup. Done means the generated error response returns the actual error instead of raising a method-not-allowed error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- express, javascript, node.js
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100