Skip to content

Commit

Permalink
Fixed the operation request body generation
Browse files Browse the repository at this point in the history
  • Loading branch information
luisfpg committed Feb 19, 2020
1 parent 6915684 commit f1f4dfd
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
7 changes: 5 additions & 2 deletions lib/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/request-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
3 changes: 1 addition & 2 deletions templates/operationParameters.handlebars
Original file line number Diff line number Diff line change
@@ -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}}
}

0 comments on commit f1f4dfd

Please sign in to comment.