From f1f4dfdda311003e769bdbd6f0689fdd20ef8a2d Mon Sep 17 00:00:00 2001 From: Luis Fernando Planella Gonzalez Date: Wed, 19 Feb 2020 16:14:17 -0300 Subject: [PATCH] Fixed the operation request body generation --- lib/operation.ts | 7 +++++-- lib/request-body.ts | 2 +- templates/operationParameters.handlebars | 3 +-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/operation.ts b/lib/operation.ts index c89ed88..4affaf1 100644 --- a/lib/operation.ts +++ b/lib/operation.ts @@ -170,9 +170,12 @@ export class Operation { } } } - if (map.size < 2) { - map.clear(); + if (map.size === 0) { map.set('', null); + } else if (map.size === 1) { + const content = [...map.values()][0]; + map.clear(); + map.set('', content); } return map; } diff --git a/lib/request-body.ts b/lib/request-body.ts index e510b4c..e2ee640 100644 --- a/lib/request-body.ts +++ b/lib/request-body.ts @@ -16,7 +16,7 @@ export class RequestBody { public content: Content[], public options: Options) { - this.tsComments = tsComments(spec.description, 1); + this.tsComments = tsComments(spec.description, 2); this.required = spec.required === true; } diff --git a/templates/operationParameters.handlebars b/templates/operationParameters.handlebars index 3c37899..cf6199e 100644 --- a/templates/operationParameters.handlebars +++ b/templates/operationParameters.handlebars @@ -1,6 +1,5 @@ params{{^operation.parametersRequired}}?{{/operation.parametersRequired}}: { {{#operation.parameters}}{{tsComments}}{{var}}{{^required}}?{{/required}}: {{{type}}};{{#tsComments}} -{{/tsComments}}{{/operation.parameters}}{{#requestBody}} - {{{../operation.requestBody.tsComments}}}body{{^../operation.requestBody.required}}?{{/../operation.requestBody.required +{{/tsComments}}{{/operation.parameters}}{{#requestBody}} {{{../operation.requestBody.tsComments}}}body{{^../operation.requestBody.required}}?{{/../operation.requestBody.required }}: {{{type}}}{{/requestBody}} } \ No newline at end of file