From 46698078a0290cec8d9ced330e6a23b16d91d900 Mon Sep 17 00:00:00 2001 From: Vlad Date: Tue, 9 Mar 2021 18:56:53 +0300 Subject: [PATCH] fix generator api parameters --- client2/scripts/generator/src/generateApis.ts | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client2/scripts/generator/src/generateApis.ts b/client2/scripts/generator/src/generateApis.ts index cf2a1ec2..649fd135 100644 --- a/client2/scripts/generator/src/generateApis.ts +++ b/client2/scripts/generator/src/generateApis.ts @@ -52,20 +52,26 @@ class ApiGenerator { apis: morph.SourceFile[] = []; + methods = ['patch', 'delete', 'post', 'get', 'put', 'head', 'options', 'trace']; + constructor(openapi: OpenApi) { this.openapi = openapi; this.paths = openapi.paths; this.serverUrl = openapi.servers[0].url; Object.keys(this.paths).forEach((pathKey) => { - Object.keys(this.paths[pathKey]).forEach((method) => { + Object.keys(this.paths[pathKey]).filter((method) => this.methods.includes(method)).forEach((method) => { const { - tags, operationId, parameters, responses, requestBody, security, "x-skip-web-api": skip + tags, operationId, responses, requestBody, security, "x-skip-web-api": skip } = this.paths[pathKey][method]; + const parameters = this.paths[pathKey][method].parameters || this.paths[pathKey].parameters; const controller = toCamel((tags ? tags[0] : pathKey.split('/')[1])); if (skip) { return; } + if (!operationId) { + console.log(pathKey); + } if (this.controllers[controller]) { this.controllers[controller][uncapitalize(operationId)] = { parameters,