Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
private static final String X_KEEP_AS_JS_OBJECT = "x-keepAsJSObject";
private static final String X_TYPESCRIPT_FETCH_API_EXAMPLE = "x-typescriptFetchApiExample";
private static final String BLOB_API_EXAMPLE = "new Blob(['example file content'], { type: 'application/octet-stream' })";
private static final String DATE_TYPE = "date";
private static final String DATE_TIME_TYPE = "DateTime";
private static final String TS_DATE_TYPE = "Date";

protected boolean sagasAndRecords = false;
@Getter @Setter
Expand Down Expand Up @@ -317,8 +320,8 @@ public void processOpts() {

if (!withoutRuntimeChecks) {
this.modelTemplateFiles.put("models.mustache", ".ts");
typeMapping.put("date", "Date");
typeMapping.put("DateTime", "Date");
typeMapping.put(DATE_TYPE, TS_DATE_TYPE);
typeMapping.put(DATE_TIME_TYPE, TS_DATE_TYPE);
}

if (additionalProperties.containsKey(SAGAS_AND_RECORDS)) {
Expand Down Expand Up @@ -1484,11 +1487,11 @@ public String getItemsDataType() {
}

public boolean isDateType() {
return isDate && "Date".equals(dataType);
return isDate && TypeScriptFetchClientCodegen.isDateType(dataType);
}

public boolean isDateTimeType() {
return isDateTime && "Date".equals(dataType);
return isDateTime && TypeScriptFetchClientCodegen.isDateTimeType(dataType);
}

public ExtendedCodegenParameter(CodegenParameter cp) {
Expand Down Expand Up @@ -1635,11 +1638,11 @@ public String getItemsDataType() {
}

public boolean isDateType() {
return isDate && "Date".equals(dataType);
return isDate && TypeScriptFetchClientCodegen.isDateType(dataType);
}

public boolean isDateTimeType() {
return isDateTime && "Date".equals(dataType);
return isDateTime && TypeScriptFetchClientCodegen.isDateTimeType(dataType);
}

public ExtendedCodegenProperty(CodegenProperty cp) {
Expand Down Expand Up @@ -1923,12 +1926,13 @@ public class ExtendedCodegenModel extends CodegenModel {
public boolean hasSelfReferencingDiscriminatorMapping(){
return selfReferencingDiscriminatorMapping != null;
}

public boolean isDateType() {
return isDate && "Date".equals(dataType);
return isDate && TypeScriptFetchClientCodegen.isDateType(dataType);
}

public boolean isDateTimeType() {
return isDateTime && "Date".equals(dataType);
return isDateTime && TypeScriptFetchClientCodegen.isDateTimeType(dataType);
}

public ExtendedCodegenModel(CodegenModel cm) {
Expand Down Expand Up @@ -2069,4 +2073,12 @@ public String toString() {
protected String getLicenseNameDefaultValue() {
return null;
}

private static boolean isDateType(String dataType) {
return TS_DATE_TYPE.equals(dataType);
}

private static boolean isDateTimeType(String dataType) {
Comment thread
Mattias-Sehlstedt marked this conversation as resolved.
return TS_DATE_TYPE.equals(dataType);
}
}
Loading