Typescript-fetch: date is only converted to javascript date with runtime checks enabled (#11481)

* date is only converted to javascript date with runtime checks enabled

* fix test

* fix test
This commit is contained in:
Kasper Peulen
2022-02-02 07:50:45 +01:00
committed by GitHub
parent 8a2131f25f
commit 80082c73c4
3 changed files with 5 additions and 5 deletions

View File

@@ -85,9 +85,6 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
this.addExtraReservedWords();
typeMapping.put("date", "Date");
typeMapping.put("DateTime", "Date");
supportModelPropertyNaming(CodegenConstants.MODEL_PROPERTY_NAMING_TYPE.camelCase);
this.cliOptions.add(new CliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
this.cliOptions.add(new CliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
@@ -231,6 +228,8 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
if (!withoutRuntimeChecks) {
this.modelTemplateFiles.put("models.mustache", ".ts");
typeMapping.put("date", "Date");
typeMapping.put("DateTime", "Date");
}
if (additionalProperties.containsKey(SAGAS_AND_RECORDS)) {

View File

@@ -61,6 +61,7 @@ public class TypeScriptFetchModelTest {
.addRequiredItem("name");
final DefaultCodegen codegen = new TypeScriptFetchClientCodegen();
codegen.processOpts();
OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model);
codegen.setOpenAPI(openAPI);
final CodegenModel cm = codegen.fromModel("sample", model);

View File

@@ -70,10 +70,10 @@ export interface Order {
quantity?: number;
/**
*
* @type {Date}
* @type {string}
* @memberof Order
*/
shipDate?: Date;
shipDate?: string;
/**
* Order Status
* @type {string}