Regarding optional requestParams getting added to Body section during code generation
Created by: Uma19
Version of openapigenerator : v4.3.0 Issue description: In my openapi file if the entry of requestparams is like this /v1/request-type/list: post: tags: - request-type summary: Testing description: Testing operationId: addRequestTypeList requestBody: content: '/': schema: type: array items: $ref: '#/components/schemas/RequestType'
so the corresponding code that is getting gererated is like below
export interface AddRequestTypeListRequest {
requestType?: Array;
}
const response = await this.request({
path: /v1/request-type/list
,
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: requestParameters.requestType.map(RequestTypeToJSON),
});
which gives error during compile time as
(property) AddRequestTypeListRequest.requestType?: RequestType[] | undefined
Object is possibly 'undefined'.
Ideally the body content should be created like this optional to resolve the above error body: requestParameters.requestType.?map(RequestTypeToJSON),
Also checked the github code for the same. Can we add this provision or is there any other way
https://github.com/OpenAPITools/openapi-generator/blob/v4.3.0/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache line no 255 line no 21
Can you help me to resolve this issue