generated code failed to compile with the following error
Object is possibly 'null'. TS2531
'documentTypeName': value.documentTypeName,
'documentNo': value.documentNo,
'issueDate': value.issueDate === undefined ? undefined : value.issueDate.toISOString(),
^
};
}
the generated interface for the value variable is as follows
export interface BillingDocumentReferenceMetadata {
/**
* Document type, e.g. invoice, credit note, order, etc.
* @type {string}
* @memberof BillingDocumentReferenceMetadata
*/
documentType?: BillingDocumentReferenceMetadataDocumentTypeEnum;
/**
* Document type name, e.g. invoice, credit note, order, etc.
* @type {string}
* @memberof BillingDocumentReferenceMetadata
*/
documentTypeName?: string;
/**
* Document number.
* @type {string}
* @memberof BillingDocumentReferenceMetadata
*/
documentNo?: string;
/**
* Document issue date (optional).
* @type {Date}
* @memberof BillingDocumentReferenceMetadata
*/
issueDate?: Date | null;
}
export function BillingDocumentReferenceMetadataToJSON(value?: BillingDocumentReferenceMetadata): any {
if (value === undefined) {
return undefined;
}
return {
'documentType': value.documentType,
'documentTypeName': value.documentTypeName,
'documentNo': value.documentNo,
'issueDate': value.issueDate === undefined ? undefined : value.issueDate.toISOString(),
};
}
version 4.1.1
Part of the swagger.json file that describes the BillingDocumentReferenceMetadata
"BillingDocumentReferenceMetadata": {
"type": "object",
"properties": {
"documentType": {
"enum": [
"Invoice",
"CreditNote",
"Order",
"Unspecified"
],
"type": "string",
"description": "Document type, e.g. invoice, credit note, order, etc."
},
"documentTypeName": {
"type": "string",
"description": "Document type name, e.g. invoice, credit note, order, etc."
},
"documentNo": {
"type": "string",
"description": "Document number."
},
"issueDate": {
"type": "string",
"description": "Document issue date (optional).",
"format": "date-time",
"nullable": true
}
},
"additionalProperties": false,
"description": "Metadata of the reference to another business document."
},
npx openapi-generator generate -i http://localhost:5003/swagger/v1/swagger.json -g typescript-fetch -o ./src/ApiClient
Generate a typescript fetch client from a json file that contains a nullable date
馃憤 Thanks for opening this issue!
馃彿 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
Most helpful comment
would you like to fix this here?
https://github.com/OpenAPITools/openapi-generator/blob/d21b3390feeb0cf0eab44e412fd50eb0b66cc1e6/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache#L119