OpenAPITools / OpenAPITools/openapi-generator
Design questions node-express-server
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
This is not a bug report but more of a question about some design decision of the generated code
-
The service class need to now about http result codes. I don't think a service should now anything about how it is used later. So it should only return data and perhaps throw an exception but it don't know if it is called from a rest-api controller, a cli or another service. But in the template the service functions should return data and http return codes
-
Inside a service function do you create a promise
static someFunction({ someParameter }) {
return new Promise(
async (resolve) => {
try {
resolve(Service.successResponse(''));
} catch (e) {
resolve(Service.rejectResponse(
e.message || 'Invalid input',
e.status || 405,
));
}
},
);
}
why not the much simpler declaring the function as async?
static async someFunction({ someParameter }) {
try {
return Service.successResponse('');
} catch (e) {
return Service.rejectResponse(
e.message || 'Invalid input',
e.status || 405,
);
}
}
or am I missing something obvious?
openapi-generator version
4.2 (but 5.0 branch is similar)
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
The issue names the node-express-server generator and its service functions; begin by reviewing the generated templates in the referenced 4.2 and 5.0 branches. Determine whether the service/controller boundary and async error-handling approach should change, then document a maintainer-approved decision before identifying the affected templates and tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- express, javascript, node.js
- Domain
- api, backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100