[typescript-fetch] (4.0.X) Model parameter uses string type when format: date
Created by: someone1
Description
The typescript-fetch generator defines models with type: string/format: date as type string, but serializes/deserializes the value as a Date
openapi-generator version
openapi-generator-cli-4.0.0-20181126.024631-44
OpenAPI declaration file content or url
swagger: "2.0"
paths:
"/config":
get:
operationId: "config.get"
responses:
200:
description: Success
schema:
$ref: "#/definitions/SiteConfiguration"
definitions:
SiteConfiguration:
description: "Site configuration"
type: object
properties:
maxReportingDate:
type: string
format: date
minReportingDate:
type: string
format: date
Generated Code (excerpt):
export interface SiteConfiguration {
/**
*
* @type {string}
* @memberof SiteConfiguration
*/
maxReportingDate?: string;
/**
*
* @type {string}
* @memberof SiteConfiguration
*/
minReportingDate?: string;
}
export function SiteConfigurationFromJSON(json: any): SiteConfiguration {
return {
'maxReportingDate': !exists(json, 'maxReportingDate') ? undefined : new Date(json['maxReportingDate']),
'minReportingDate': !exists(json, 'minReportingDate') ? undefined : new Date(json['minReportingDate']),
};
}
Command line used for generation
openapi-generator generate -i openapi.yaml -l typescript-fetch -c es6.json -o ./typescript-api/
Steps to reproduce
- Use the provided yaml excerpt above to generate a client with the provided command line
- Buggy code generated
Related issues/PRs
PR #569
Suggest a fix/enhancement
Add additional resolution for Date or DateTime formatted strings in getTypeDeclaration
here