Skip to content

Commit

Permalink
fix: duplicate service generation (#135)
Browse files Browse the repository at this point in the history
Co-authored-by: Zaostrovskii Dmitrii <dmitrii.zaostrovskii@dxc.com>
  • Loading branch information
zaostrovskii and Zaostrovskii Dmitrii authored Feb 9, 2024
1 parent 8e43185 commit 3461043
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@luxbss/gengen",
"version": "1.2.4",
"version": "1.2.5",
"description": "Tool for generating models and Angular services based on OpenAPIs and Swagger's JSON",
"bin": {
"gengen": "./bin/index.js"
Expand Down
17 changes: 6 additions & 11 deletions src/services/ServiceMappingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,11 @@ export class ServiceMappingService {
return store;
}

const service = store.find((z) => z.name === info.name);
let service = store.find((z) => z.name === info.name);
if (!service && model.length) {
service = { name: info.name, relativePath: info.relativePath, methods: [] };
store.push(service);
}

model.forEach((z) => {
const action =
Expand All @@ -74,16 +78,7 @@ export class ServiceMappingService {
throw new Error(`Cannot find action in service ${info.name} by method ${z}`);
}

if (service) {
service.methods.push(this.getMethod(action.name, z.method, z.operation, models, action.origin));
return store;
}

store.push({
name: info.name,
relativePath: info.relativePath,
methods: [this.getMethod(action.name, z.method, z.operation, models, action.origin)]
});
service!.methods.push(this.getMethod(action.name, z.method, z.operation, models, action.origin));
});

return store;
Expand Down

0 comments on commit 3461043

Please sign in to comment.