Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions docs/generators/typescript-angular.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>ReturnType</li>
<li>Set</li>
<li>String</li>
<li>Temporal.Instant</li>
<li>Temporal.PlainDate</li>
<li>ThisParameterType</li>
<li>ThisType</li>
<li>Uncapitalize</li>
Expand Down
2 changes: 2 additions & 0 deletions docs/generators/typescript-aurelia.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>ReturnType</li>
<li>Set</li>
<li>String</li>
<li>Temporal.Instant</li>
<li>Temporal.PlainDate</li>
<li>ThisParameterType</li>
<li>ThisType</li>
<li>Uncapitalize</li>
Expand Down
2 changes: 2 additions & 0 deletions docs/generators/typescript-axios.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>ReturnType</li>
<li>Set</li>
<li>String</li>
<li>Temporal.Instant</li>
<li>Temporal.PlainDate</li>
<li>ThisParameterType</li>
<li>ThisType</li>
<li>Uncapitalize</li>
Expand Down
3 changes: 3 additions & 0 deletions docs/generators/typescript-fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|stringEnums|Generate string enums instead of objects for enum values.| |false|
|supportsES6|Generate code that conforms to ES6.| |false|
|temporal|Setting this property to true will use Temporal data types instead of Date.| |false|

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: The temporal option description does not mention that generated code emits bare Temporal.Instant/Temporal.PlainDate references with no import, so consumers enabling temporal: true must provide a Temporal runtime/polyfill plus typings or the generated code will not compile. Add the runtime/import requirement to the option documentation (via the CliOption comment it is generated from) so users know what to install.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/generators/typescript-fetch.md, line 46:

<comment>The temporal option description does not mention that generated code emits bare `Temporal.Instant`/`Temporal.PlainDate` references with no import, so consumers enabling `temporal: true` must provide a Temporal runtime/polyfill plus typings or the generated code will not compile. Add the runtime/import requirement to the option documentation (via the CliOption comment it is generated from) so users know what to install.</comment>

<file context>
@@ -43,6 +43,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
 |sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
 |stringEnums|Generate string enums instead of objects for enum values.| |false|
 |supportsES6|Generate code that conforms to ES6.| |false|
+|temporal|Setting this property to true will use Temporal data types instead of Date.| |false|
 |useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |true|
 |useSquareBracketsInArrayNames|Setting this property to true will add brackets to array attribute names, e.g. my_values[].| |false|
</file context>
Suggested change
|temporal|Setting this property to true will use Temporal data types instead of Date.| |false|
|temporal|Setting this property to true will use Temporal data types instead of Date. Requires a Temporal runtime/polyfill (e.g. Temporal.Instant, Temporal.PlainDate) to be available at compile/runtime.| |false|

|useSingleRequestParameter|Setting this property to true will generate functions with a single argument containing all API endpoint parameters instead of one argument per parameter.| |true|
|useSquareBracketsInArrayNames|Setting this property to true will add brackets to array attribute names, e.g. my_values[].| |false|
|validationAttributes|Setting this property to true will generate the validation attributes of model properties.| |false|
Expand Down Expand Up @@ -98,6 +99,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>ReturnType</li>
<li>Set</li>
<li>String</li>
<li>Temporal.Instant</li>
<li>Temporal.PlainDate</li>
<li>ThisParameterType</li>
<li>ThisType</li>
<li>Uncapitalize</li>
Expand Down
2 changes: 2 additions & 0 deletions docs/generators/typescript-inversify.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>ReturnType</li>
<li>Set</li>
<li>String</li>
<li>Temporal.Instant</li>
<li>Temporal.PlainDate</li>
<li>ThisParameterType</li>
<li>ThisType</li>
<li>Uncapitalize</li>
Expand Down
2 changes: 2 additions & 0 deletions docs/generators/typescript-jquery.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>ReturnType</li>
<li>Set</li>
<li>String</li>
<li>Temporal.Instant</li>
<li>Temporal.PlainDate</li>
<li>ThisParameterType</li>
<li>ThisType</li>
<li>Uncapitalize</li>
Expand Down
2 changes: 2 additions & 0 deletions docs/generators/typescript-nestjs-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>ReturnType</li>
<li>Set</li>
<li>String</li>
<li>Temporal.Instant</li>
<li>Temporal.PlainDate</li>
<li>ThisParameterType</li>
<li>ThisType</li>
<li>Uncapitalize</li>
Expand Down
2 changes: 2 additions & 0 deletions docs/generators/typescript-nestjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>ReturnType</li>
<li>Set</li>
<li>String</li>
<li>Temporal.Instant</li>
<li>Temporal.PlainDate</li>
<li>ThisParameterType</li>
<li>ThisType</li>
<li>Uncapitalize</li>
Expand Down
2 changes: 2 additions & 0 deletions docs/generators/typescript-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>ReturnType</li>
<li>Set</li>
<li>String</li>
<li>Temporal.Instant</li>
<li>Temporal.PlainDate</li>
<li>ThisParameterType</li>
<li>ThisType</li>
<li>Uncapitalize</li>
Expand Down
2 changes: 2 additions & 0 deletions docs/generators/typescript-redux-query.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>ReturnType</li>
<li>Set</li>
<li>String</li>
<li>Temporal.Instant</li>
<li>Temporal.PlainDate</li>
<li>ThisParameterType</li>
<li>ThisType</li>
<li>Uncapitalize</li>
Expand Down
2 changes: 2 additions & 0 deletions docs/generators/typescript-rxjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>ReturnType</li>
<li>Set</li>
<li>String</li>
<li>Temporal.Instant</li>
<li>Temporal.PlainDate</li>
<li>ThisParameterType</li>
<li>ThisType</li>
<li>Uncapitalize</li>
Expand Down
2 changes: 2 additions & 0 deletions docs/generators/typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
<li>ReturnType</li>
<li>Set</li>
<li>String</li>
<li>Temporal.Instant</li>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This doc covers the base typescript generator (TypeScriptClientCodegen), which has no temporal config option — the option is only registered on TypeScriptFetchClientCodegen (new CliOption(TEMPORAL, ...)). Because Temporal.Instant/Temporal.PlainDate were added unconditionally to AbstractTypeScriptClientCodegen.languageSpecificPrimitives (the shared base of every TS generator), these entries now appear in typescript.md even though generated code from this generator always maps date/date-time to Date and never emits Temporal types. That is misleading, and it also leaked into all other TS generator docs (angular, axios, node, rxjs). Temporal types should be added to languageSpecificPrimitives only in the typescript-fetch codegen (e.g. conditionally when the temporal option is set), so docs of generators that don't support Temporal don't list them. Note also that Temporal.Instant/Temporal.PlainDate are not TypeScript language primitives at all — they require a Temporal runtime/polyfill, so unconditionally listing them as primitives overstates availability.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/generators/typescript.md, line 100:

<comment>This doc covers the base `typescript` generator (TypeScriptClientCodegen), which has no `temporal` config option — the option is only registered on TypeScriptFetchClientCodegen (`new CliOption(TEMPORAL, ...)`). Because `Temporal.Instant`/`Temporal.PlainDate` were added unconditionally to `AbstractTypeScriptClientCodegen.languageSpecificPrimitives` (the shared base of every TS generator), these entries now appear in `typescript.md` even though generated code from this generator always maps date/date-time to `Date` and never emits Temporal types. That is misleading, and it also leaked into all other TS generator docs (angular, axios, node, rxjs). Temporal types should be added to `languageSpecificPrimitives` only in the typescript-fetch codegen (e.g. conditionally when the temporal option is set), so docs of generators that don't support Temporal don't list them. Note also that `Temporal.Instant`/`Temporal.PlainDate` are not TypeScript language primitives at all — they require a Temporal runtime/polyfill, so unconditionally listing them as primitives overstates availability.</comment>

<file context>
@@ -97,6 +97,8 @@ These options may be applied as additional-properties (cli) or configOptions (pl
 <li>ReturnType</li>
 <li>Set</li>
 <li>String</li>
+<li>Temporal.Instant</li>
+<li>Temporal.PlainDate</li>
 <li>ThisParameterType</li>
</file context>

<li>Temporal.PlainDate</li>
<li>ThisParameterType</li>
<li>ThisType</li>
<li>Uncapitalize</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
public static final String USE_SQUARE_BRACKETS_IN_ARRAY_NAMES = "useSquareBracketsInArrayNames";
public static final String VALIDATION_ATTRIBUTES = "validationAttributes";
public static final String WITH_REQUEST_OPTS_IN_INTERFACE = "withRequestOptsInInterface";
public static final String TEMPORAL = "temporal";

@Getter @Setter
protected String npmRepository = null;
Expand Down Expand Up @@ -134,6 +135,11 @@ public TypeScriptFetchClientCodegen() {

this.addExtraReservedWords();

languageSpecificPrimitives.addAll(Arrays.asList(
"Temporal.Instant",
"Temporal.PlainDate"
));

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()));
Expand All @@ -147,6 +153,7 @@ public TypeScriptFetchClientCodegen() {
this.cliOptions.add(new CliOption(USE_SQUARE_BRACKETS_IN_ARRAY_NAMES, "Setting this property to true will add brackets to array attribute names, e.g. my_values[].", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
this.cliOptions.add(new CliOption(VALIDATION_ATTRIBUTES, "Setting this property to true will generate the validation attributes of model properties.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
this.cliOptions.add(new CliOption(WITH_REQUEST_OPTS_IN_INTERFACE, "Setting this property to true will include *RequestOpts methods in the API interface declarations. Set to false to keep them only on the class.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.TRUE.toString()));
this.cliOptions.add(new CliOption(TEMPORAL, "Setting this property to true will use Temporal data types instead of Date.", SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
}

@Override
Expand Down Expand Up @@ -315,10 +322,19 @@ public void processOpts() {
this.setFileNaming(additionalProperties.get(FILE_NAMING).toString());
}

if (additionalProperties.containsKey(TEMPORAL)) {
convertPropertyToBooleanAndWriteBack(TEMPORAL);
}

if (!withoutRuntimeChecks) {
this.modelTemplateFiles.put("models.mustache", ".ts");
typeMapping.put("date", "Date");
typeMapping.put("DateTime", "Date");
if (additionalProperties.containsKey(TEMPORAL) && Boolean.TRUE.equals(additionalProperties.get(TEMPORAL))) {
typeMapping.put("date", "Temporal.PlainDate");
typeMapping.put("DateTime", "Temporal.Instant");
} else {
typeMapping.put("date", "Date");
typeMapping.put("DateTime", "Date");
}
}

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

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

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

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

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

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

public ExtendedCodegenProperty(CodegenProperty cp) {
Expand Down Expand Up @@ -1924,11 +1940,11 @@ public boolean hasSelfReferencingDiscriminatorMapping(){
return selfReferencingDiscriminatorMapping != null;
}
public boolean isDateType() {
return isDate && "Date".equals(dataType);
return isDate && ("Date".equals(dataType) || "Temporal.PlainDate".equals(dataType));
}

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

public ExtendedCodegenModel(CodegenModel cm) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,28 @@ export class {{classname}} extends runtime.BaseAPI {
let urlPath = `{{{path}}}`;
{{#pathParams}}
{{#isDateTimeType}}
{{#temporal}}
if (requestParameters['{{paramName}}'] instanceof Temporal.Instant) {
urlPath = urlPath.replace({{=<< >>=}}'{<<baseName>>}'<<={{ }}=>>, encodeURIComponent(requestParameters['{{paramName}}'].toString()));
{{/temporal}}
{{^temporal}}
if (requestParameters['{{paramName}}'] instanceof Date) {
urlPath = urlPath.replace({{=<< >>=}}'{<<baseName>>}'<<={{ }}=>>, encodeURIComponent(requestParameters['{{paramName}}'].toISOString()));
{{/temporal}}
} else {
urlPath = urlPath.replace({{=<< >>=}}'{<<baseName>>}'<<={{ }}=>>, encodeURIComponent(String(requestParameters['{{paramName}}'])));
}
{{/isDateTimeType}}
{{^isDateTimeType}}
{{#isDateType}}
{{#temporal}}
if (requestParameters['{{paramName}}'] instanceof Temporal.PlainDate) {
urlPath = urlPath.replace({{=<< >>=}}'{<<baseName>>}'<<={{ }}=>>, encodeURIComponent(requestParameters['{{paramName}}'].toString()));
{{/temporal}}
{{^temporal}}
if (requestParameters['{{paramName}}'] instanceof Date) {
urlPath = urlPath.replace({{=<< >>=}}'{<<baseName>>}'<<={{ }}=>>, encodeURIComponent(requestParameters['{{paramName}}'].toISOString().substring(0,10)));
{{/temporal}}
} else {
urlPath = urlPath.replace({{=<< >>=}}'{<<baseName>>}'<<={{ }}=>>, encodeURIComponent(String(requestParameters['{{paramName}}'])));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{{! Assign query parameters based on their type }}
{{#isDateTimeType}}
queryParameters['{{baseName}}'] = (requestParameters['{{paramName}}'] as any).toISOString();
queryParameters['{{baseName}}'] = {{#temporal}}(requestParameters['{{paramName}}'] as any).toString(){{/temporal}}{{^temporal}}(requestParameters['{{paramName}}'] as any).toISOString(){{/temporal}};

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth noting that Temporal.Instant's toString() method gives something like this (based on my experiments):

  • Node: "2026-08-15T14:25:49.161593018Z"
  • Firefox: "2026-08-15T14:25:46.876Z"
  • Chromium: "2026-08-15T14:26:24.1674Z"

So in Node, the precision is up to nanoseconds. Also, the specification says that the number of places after the decimal point may differ because trailing zeroes are removed. We could also fix the number of fractional seconds (the method has a parameter for that).

{{/isDateTimeType}}
{{^isDateTimeType}}
{{#isDateType}}
queryParameters['{{baseName}}'] = (requestParameters['{{paramName}}'] as any).toISOString().substring(0,10);
queryParameters['{{baseName}}'] = {{#temporal}}(requestParameters['{{paramName}}'] as any).toString(){{/temporal}}{{^temporal}}(requestParameters['{{paramName}}'] as any).toISOString().substring(0,10){{/temporal}};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: When a caller supplies a non-ISO-calendar Temporal.PlainDate, .toString() produces a value outside OpenAPI format: date. Serialize with .toString({ calendarName: 'never' }) for the query wire format.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/typescript-fetch/apisAssignQueryParam.mustache, line 7:

<comment>When a caller supplies a non-ISO-calendar `Temporal.PlainDate`, `.toString()` produces a value outside OpenAPI `format: date`. Serialize with `.toString({ calendarName: 'never' })` for the query wire format.</comment>

<file context>
@@ -1,10 +1,10 @@
 {{^isDateTimeType}}
 {{#isDateType}}
-            queryParameters['{{baseName}}'] = (requestParameters['{{paramName}}'] as any).toISOString().substring(0,10);
+            queryParameters['{{baseName}}'] = {{#temporal}}(requestParameters['{{paramName}}'] as any).toString(){{/temporal}}{{^temporal}}(requestParameters['{{paramName}}'] as any).toISOString().substring(0,10){{/temporal}};
 {{/isDateType}}
 {{^isDateType}}
</file context>
Suggested change
queryParameters['{{baseName}}'] = {{#temporal}}(requestParameters['{{paramName}}'] as any).toString(){{/temporal}}{{^temporal}}(requestParameters['{{paramName}}'] as any).toISOString().substring(0,10){{/temporal}};
queryParameters['{{baseName}}'] = {{#temporal}}(requestParameters['{{paramName}}'] as any).toString({ calendarName: 'never' }){{/temporal}}{{^temporal}}(requestParameters['{{paramName}}'] as any).toISOString().substring(0,10){{/temporal}};

{{/isDateType}}
{{^isDateType}}
queryParameters['{{baseName}}'] = requestParameters['{{paramName}}'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,12 @@
{{^isArray}}
if (requestParameters['{{paramName}}'] != null) {
{{#isDateTimeType}}
{{#temporal}}
formParams.append('{{baseName}}', (requestParameters['{{paramName}}'] as any).toString());
{{/temporal}}
{{^temporal}}
formParams.append('{{baseName}}', (requestParameters['{{paramName}}'] as any).toISOString());
{{/temporal}}
{{/isDateTimeType}}
{{^isDateTimeType}}
{{#isPrimitiveType}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole
{{/isArray}}
{{^isArray}}
{{#isDateType}}
'{{name}}': {{^required}}{{#isNullable}}json['{{baseName}}'] === undefined ? undefined : json['{{baseName}}'] === null ? null : {{/isNullable}}{{^isNullable}}json['{{baseName}}'] == null ? undefined : {{/isNullable}}{{/required}}({{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{^isNullable}}json['{{baseName}}'] == null ? json['{{baseName}}'] : {{/isNullable}}{{/required}}new Date(json['{{baseName}}'])),
'{{name}}': {{^required}}{{#isNullable}}json['{{baseName}}'] === undefined ? undefined : json['{{baseName}}'] === null ? null : {{/isNullable}}{{^isNullable}}json['{{baseName}}'] == null ? undefined : {{/isNullable}}{{/required}}({{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{^isNullable}}json['{{baseName}}'] == null ? json['{{baseName}}'] : {{/isNullable}}{{/required}}{{#temporal}}Temporal.PlainDate.from(json['{{baseName}}']){{/temporal}}{{^temporal}}new Date(json['{{baseName}}']){{/temporal}}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: For array properties with date or date-time items, this scalar-only branch is skipped and FromJSON returns strings despite the generated Temporal.*[] type. Map each array item through Temporal.PlainDate.from or Temporal.Instant.from, and serialize each item with toString().

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache, line 101:

<comment>For array properties with date or date-time items, this scalar-only branch is skipped and `FromJSON` returns strings despite the generated `Temporal.*[]` type. Map each array item through `Temporal.PlainDate.from` or `Temporal.Instant.from`, and serialize each item with `toString()`.</comment>

<file context>
@@ -98,10 +98,10 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole
         {{^isArray}}
         {{#isDateType}}
-        '{{name}}': {{^required}}{{#isNullable}}json['{{baseName}}'] === undefined ? undefined : json['{{baseName}}'] === null ? null : {{/isNullable}}{{^isNullable}}json['{{baseName}}'] == null ? undefined : {{/isNullable}}{{/required}}({{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{^isNullable}}json['{{baseName}}'] == null ? json['{{baseName}}'] : {{/isNullable}}{{/required}}new Date(json['{{baseName}}'])),
+        '{{name}}': {{^required}}{{#isNullable}}json['{{baseName}}'] === undefined ? undefined : json['{{baseName}}'] === null ? null : {{/isNullable}}{{^isNullable}}json['{{baseName}}'] == null ? undefined : {{/isNullable}}{{/required}}({{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{^isNullable}}json['{{baseName}}'] == null ? json['{{baseName}}'] : {{/isNullable}}{{/required}}{{#temporal}}Temporal.PlainDate.from(json['{{baseName}}']){{/temporal}}{{^temporal}}new Date(json['{{baseName}}']){{/temporal}}),
         {{/isDateType}}
         {{#isDateTimeType}}
</file context>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: When consumers provide Temporal through the usual polyfill module import without assigning globalThis.Temporal, deserializing a date field throws ReferenceError: Temporal is not defined. Generate an explicit Temporal import or a documented, generated global binding.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache, line 101:

<comment>When consumers provide Temporal through the usual polyfill module import without assigning `globalThis.Temporal`, deserializing a date field throws `ReferenceError: Temporal is not defined`. Generate an explicit Temporal import or a documented, generated global binding.</comment>

<file context>
@@ -98,10 +98,10 @@ export function {{classname}}FromJSONTyped(json: any, ignoreDiscriminator: boole
         {{^isArray}}
         {{#isDateType}}
-        '{{name}}': {{^required}}{{#isNullable}}json['{{baseName}}'] === undefined ? undefined : json['{{baseName}}'] === null ? null : {{/isNullable}}{{^isNullable}}json['{{baseName}}'] == null ? undefined : {{/isNullable}}{{/required}}({{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{^isNullable}}json['{{baseName}}'] == null ? json['{{baseName}}'] : {{/isNullable}}{{/required}}new Date(json['{{baseName}}'])),
+        '{{name}}': {{^required}}{{#isNullable}}json['{{baseName}}'] === undefined ? undefined : json['{{baseName}}'] === null ? null : {{/isNullable}}{{^isNullable}}json['{{baseName}}'] == null ? undefined : {{/isNullable}}{{/required}}({{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{^isNullable}}json['{{baseName}}'] == null ? json['{{baseName}}'] : {{/isNullable}}{{/required}}{{#temporal}}Temporal.PlainDate.from(json['{{baseName}}']){{/temporal}}{{^temporal}}new Date(json['{{baseName}}']){{/temporal}}),
         {{/isDateType}}
         {{#isDateTimeType}}
</file context>

{{/isDateType}}
{{#isDateTimeType}}
'{{name}}': {{^required}}{{#isNullable}}json['{{baseName}}'] === undefined ? undefined : json['{{baseName}}'] === null ? null : {{/isNullable}}{{^isNullable}}json['{{baseName}}'] == null ? undefined : {{/isNullable}}{{/required}}({{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{^isNullable}}json['{{baseName}}'] == null ? json['{{baseName}}'] : {{/isNullable}}{{/required}}new Date(json['{{baseName}}'])),
'{{name}}': {{^required}}{{#isNullable}}json['{{baseName}}'] === undefined ? undefined : json['{{baseName}}'] === null ? null : {{/isNullable}}{{^isNullable}}json['{{baseName}}'] == null ? undefined : {{/isNullable}}{{/required}}({{#required}}{{#isNullable}}json['{{baseName}}'] == null ? null : {{/isNullable}}{{^isNullable}}json['{{baseName}}'] == null ? json['{{baseName}}'] : {{/isNullable}}{{/required}}{{#temporal}}Temporal.Instant.from(json['{{baseName}}']){{/temporal}}{{^temporal}}new Date(json['{{baseName}}']){{/temporal}}),
{{/isDateTimeType}}
{{^isDateType}}
{{^isDateTimeType}}
Expand Down Expand Up @@ -173,10 +173,10 @@ export function {{classname}}ToJSONTyped(value?: {{#hasReadOnly}}Omit<{{classnam
{{^isReadOnly}}
{{#isPrimitiveType}}
{{#isDateType}}
'{{baseName}}': value['{{name}}'] == null ? value['{{name}}'] : value['{{name}}'].toISOString().substring(0,10),
'{{baseName}}': value['{{name}}'] == null ? value['{{name}}'] : {{#temporal}}value['{{name}}'].toString(){{/temporal}}{{^temporal}}value['{{name}}'].toISOString().substring(0,10){{/temporal}},
{{/isDateType}}
{{#isDateTimeType}}
'{{baseName}}': value['{{name}}'] == null ? value['{{name}}'] : value['{{name}}'].toISOString(),
'{{baseName}}': value['{{name}}'] == null ? value['{{name}}'] : {{#temporal}}value['{{name}}'].toString(){{/temporal}}{{^temporal}}value['{{name}}'].toISOString(){{/temporal}},
{{/isDateTimeType}}
{{#isArray}}
'{{baseName}}': {{#uniqueItems}}{{^required}}value['{{name}}'] == null ? undefined : {{/required}}{{#required}}{{#isNullable}}value['{{name}}'] == null ? null : {{/isNullable}}{{/required}}Array.from(value['{{name}}'] as Set<any>){{/uniqueItems}}{{^uniqueItems}}value['{{name}}']{{/uniqueItems}},
Expand Down
Loading