You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 88aeaad
Browse filesBrowse the repository at this point in the historyBrowse files
* [typescript-fetch] Add Temporal support
This adds a new date library option to the typescript-fetch generator:
"temporal". With it, the generator uses Temporal.Instant for "type:
string, format: date-time" and Temporal.PlainDate for "type: string,
format: date".
* Improve solution
Based on comments from cubic-dev-ai.
Copy file name to clipboardExpand all lines: docs/generators/typescript-fetch.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,7 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
19
19
| Option | Description | Values | Default |
20
20
| ------ | ----------- | ------ | ------- |
21
21
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false||false|
22
-
|dateLibrary|Option. Date library to use.|<dl><dt>**date**</dt><dd>Native Date. `format: date` and `format: date-time` are both mapped to Date and (de)serialized by the runtime.</dd><dt>**string**</dt><dd>Plain string. Values are passed through untouched, leaving date handling to the consumer.</dd></dl>|date|
22
+
|dateLibrary|Option. Date library to use.|<dl><dt>**date**</dt><dd>Native Date. `format: date` and `format: date-time` are both mapped to Date and (de)serialized by the runtime.</dd><dt>**string**</dt><dd>Plain string. Values are passed through untouched, leaving date handling to the consumer.</dd><dt>**temporal**</dt><dd>Native Temporal. `format: date` is mapped to Temporal.PlainDate and `format: date-time` is mapped to Temporal.Instant and (de)serialized by the runtime.</dd></dl>|date|
23
23
|disallowAdditionalPropertiesIfNotPresent|If false, the 'additionalProperties' implementation (set to true by default) is compliant with the OAS and JSON schema specifications. If true (default), keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.|<dl><dt>**false**</dt><dd>The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.</dd><dt>**true**</dt><dd>Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.</dd></dl>|true|
24
24
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).||true|
25
25
|enumNameSuffix|Suffix that will be appended to all enum names.||Enum|
@@ -99,6 +99,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
Copy file name to clipboardExpand all lines: modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java
+18-4Lines changed: 18 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -67,6 +67,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
67
67
publicstaticfinalStringDATE_LIBRARY_DESC = "Option. Date library to use.";
this.cliOptions.add(newCliOption(NPM_REPOSITORY, "Use this property to set an url your private npmRepo in the package.json"));
148
156
this.cliOptions.add(newCliOption(WITH_INTERFACES, "Setting this property to true will generate interfaces next to the default class implementations.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
@@ -154,6 +162,7 @@ public TypeScriptFetchClientCodegen() {
154
162
Map<String, String> dateOptions = newHashMap<>();
155
163
dateOptions.put(DATE_LIBRARY_DATE, "Native Date. `format: date` and `format: date-time` are both mapped to Date and (de)serialized by the runtime.");
156
164
dateOptions.put(DATE_LIBRARY_STRING, "Plain string. Values are passed through untouched, leaving date handling to the consumer.");
165
+
dateOptions.put(DATE_LIBRARY_TEMPORAL, "Native Temporal. `format: date` is mapped to Temporal.PlainDate and `format: date-time` is mapped to Temporal.Instant and (de)serialized by the runtime.");
157
166
dateLibraryOption.setEnum(dateOptions);
158
167
this.cliOptions.add(dateLibraryOption);
159
168
this.cliOptions.add(newCliOption(SAGAS_AND_RECORDS, "Setting this property to true will generate additional files for use with redux-saga and immutablejs.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
@@ -349,24 +358,29 @@ public void processOpts() {
349
358
350
359
// `date` needs the model (de)serialization to convert with, which
351
360
// withoutRuntimeChecks removes: the raw string would just be cast to Date.
352
-
if (withoutRuntimeChecks && DATE_LIBRARY_DATE.equals(this.dateLibrary)) {
361
+
if (withoutRuntimeChecks && (DATE_LIBRARY_DATE.equals(this.dateLibrary) || DATE_LIBRARY_TEMPORAL.equals(this.dateLibrary))) {
353
362
if (additionalProperties.containsKey(DATE_LIBRARY)) {
354
363
LOGGER.warn("{}={} is not compatible with {}=true; falling back to {}={}.",
0 commit comments