diff --git a/package-lock.json b/package-lock.json index 35c82c2..72be118 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@luxbss/gengen", - "version": "1.2.3", + "version": "1.2.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@luxbss/gengen", - "version": "1.2.3", + "version": "1.2.5", "license": "MIT", "dependencies": { "commander": "11.1.0", diff --git a/package.json b/package.json index ae0518e..73fc293 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/src/services/ServiceMappingService.ts b/src/services/ServiceMappingService.ts index 86871db..a8f1d60 100644 --- a/src/services/ServiceMappingService.ts +++ b/src/services/ServiceMappingService.ts @@ -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 = @@ -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;