From 1cdb85ba178aaa7f7c8d09d62e4036d8e43194b9 Mon Sep 17 00:00:00 2001 From: Gerard Downes Date: Tue, 17 Oct 2023 15:35:45 +0100 Subject: [PATCH] Default text body --- src/mapper.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mapper.ts b/src/mapper.ts index 8b738c3..c6779c3 100644 --- a/src/mapper.ts +++ b/src/mapper.ts @@ -60,7 +60,7 @@ export class Method { const responseTypeName = responseType?.substring(responseType?.lastIndexOf('/') + 1); return `json(body: Model.${responseTypeName}, headers?: {${headerParam}}): APIGatewayProxyResult`; } else if (contentType === 'application/text') { - return `text(body: string, headers?: {${headerParam}}): APIGatewayProxyResult`; + return `text(body = '', headers?: {${headerParam}}): APIGatewayProxyResult`; } return `['${contentType}'](body: string, headers?: {${headerParam}}): APIGatewayProxyResult`; }); @@ -78,9 +78,9 @@ export class Method { const responseTypeName = responseType?.substring(responseType?.lastIndexOf('/') + 1); return `json(body: Model.${responseTypeName}, headers?: {${headerParam}}): APIGatewayProxyResult { return { statusCode: ${statusCode}, body: JSON.stringify(body), headers: { ...(headers ?? {}), ['Content-Type']: '${contentType}' } } }`; } else if (contentType === 'application/text') { - return `text(body: string, headers?: {${headerParam}}): APIGatewayProxyResult { return { statusCode: ${statusCode}, body, headers: { ...(headers ?? {}), ['Content-Type']: '${contentType}' } } }`; + return `text(body = '', headers?: {${headerParam}}): APIGatewayProxyResult { return { statusCode: ${statusCode}, body, headers: { ...(headers ?? {}), ['Content-Type']: '${contentType}' } } }`; } - return `['${contentType}'](body: string, headers?: {${headerParam}}): APIGatewayProxyResult { return { statusCode: ${statusCode}, body, headers: { ...(headers ?? {}), ['Content-Type']: '${contentType}' } } }`; + return `['${contentType}'](body = '', headers?: {${headerParam}}): APIGatewayProxyResult { return { statusCode: ${statusCode}, body, headers: { ...(headers ?? {}), ['Content-Type']: '${contentType}' } } }`; }); return `[${statusCode}]: { ${responses.join(', ')} }`; }).join(', ');