diff --git a/bin/configs/typescript-fetch-date-anchor-utc.yaml b/bin/configs/typescript-fetch-date-anchor-utc.yaml
new file mode 100644
index 000000000000..ef28acc814f5
--- /dev/null
+++ b/bin/configs/typescript-fetch-date-anchor-utc.yaml
@@ -0,0 +1,10 @@
+generatorName: typescript-fetch
+outputDir: samples/client/petstore/typescript-fetch/builds/date-anchor-utc
+inputSpec: modules/openapi-generator/src/test/resources/3_0/typescript-fetch/date-handling.yaml
+templateDir: modules/openapi-generator/src/main/resources/typescript-fetch
+additionalProperties:
+ dateLibrary: date
+ dateAnchor: utc
+ npmVersion: 1.0.0
+ npmName: '@openapitools/typescript-fetch-petstore'
+ npmRepository: https://skimdb.npmjs.com/registry
diff --git a/docs/generators/typescript-fetch.md b/docs/generators/typescript-fetch.md
index 543e13061808..57e4e47613bd 100644
--- a/docs/generators/typescript-fetch.md
+++ b/docs/generators/typescript-fetch.md
@@ -19,6 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
| Option | Description | Values | Default |
| ------ | ----------- | ------ | ------- |
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
+|dateAnchor|Option. How a `format: date` value is anchored to an instant. Only applies when dateLibrary=date.|
- **local**
- Local calendar. A `format: date` value is parsed to local midnight and serialized from the local calendar (default since 7.25.0).
- **utc**
- UTC. A `format: date` value is parsed with `new Date(value)` and serialized as the UTC calendar day (`toISOString().substring(0, 10)`), the behaviour up to 7.24.
|local|
|dateLibrary|Option. Date library to use.|- **date**
- Native Date. `format: date` and `format: date-time` are both mapped to Date and (de)serialized by the runtime.
- **string**
- Plain string. Values are passed through untouched, leaving date handling to the consumer.
- **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. (Experimental support)
|date|
|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.|- **false**
- The 'additionalProperties' implementation is compliant with the OAS and JSON schema specifications.
- **true**
- Keep the old (incorrect) behaviour that 'additionalProperties' is set to false by default.
|true|
|ensureUniqueParams|Whether to ensure parameter names are unique in an operation (rename parameters that are not).| |true|
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java
index c5a3990c5184..aae1143c22ca 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptFetchClientCodegen.java
@@ -73,6 +73,10 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
public static final String DATE_LIBRARY_DATE = "date";
public static final String DATE_LIBRARY_STRING = "string";
public static final String DATE_LIBRARY_TEMPORAL = "temporal";
+ public static final String DATE_ANCHOR = "dateAnchor";
+ public static final String DATE_ANCHOR_DESC = "Option. How a `format: date` value is anchored to an instant. Only applies when dateLibrary=date.";
+ public static final String DATE_ANCHOR_LOCAL = "local";
+ public static final String DATE_ANCHOR_UTC = "utc";
public static final String STRING_ENUMS = "stringEnums";
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";
public static final String IMPORT_FILE_EXTENSION_SWITCH = "importFileExtension";
@@ -96,6 +100,7 @@ public class TypeScriptFetchClientCodegen extends AbstractTypeScriptClientCodege
protected boolean addedModelIndex = false;
protected boolean withoutRuntimeChecks = false;
protected String dateLibrary = DATE_LIBRARY_DATE;
+ protected String dateAnchor = DATE_ANCHOR_LOCAL;
protected boolean stringEnums = false;
protected String fileNaming = PASCAL_CASE;
protected String apiDocPath = "docs";
@@ -172,6 +177,13 @@ public TypeScriptFetchClientCodegen() {
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. (Experimental support) ");
dateLibraryOption.setEnum(dateOptions);
this.cliOptions.add(dateLibraryOption);
+
+ CliOption dateAnchorOption = new CliOption(DATE_ANCHOR, DATE_ANCHOR_DESC).defaultValue(this.getDateAnchor());
+ Map dateAnchorOptions = new LinkedHashMap<>();
+ dateAnchorOptions.put(DATE_ANCHOR_LOCAL, "Local calendar. A `format: date` value is parsed to local midnight and serialized from the local calendar (default since 7.25.0).");
+ dateAnchorOptions.put(DATE_ANCHOR_UTC, "UTC. A `format: date` value is parsed with `new Date(value)` and serialized as the UTC calendar day (`toISOString().substring(0, 10)`), the behaviour up to 7.24.");
+ dateAnchorOption.setEnum(dateAnchorOptions);
+ this.cliOptions.add(dateAnchorOption);
this.cliOptions.add(new CliOption(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()));
this.cliOptions.add(new CliOption(STRING_ENUMS, STRING_ENUMS_DESC, SchemaTypeUtil.BOOLEAN_TYPE).defaultValue(Boolean.FALSE.toString()));
this.cliOptions.add(new CliOption(IMPORT_FILE_EXTENSION_SWITCH, IMPORT_FILE_EXTENSION_SWITCH_DESC).defaultValue(""));
@@ -238,6 +250,19 @@ public void setDateLibrary(String dateLibrary) {
this.dateLibrary = dateLibrary;
}
+ public String getDateAnchor() {
+ return this.dateAnchor;
+ }
+
+ public void setDateAnchor(String dateAnchor) {
+ if (DATE_ANCHOR_LOCAL.equals(dateAnchor) || DATE_ANCHOR_UTC.equals(dateAnchor)) {
+ this.dateAnchor = dateAnchor;
+ } else {
+ throw new IllegalArgumentException("Invalid dateAnchor '" +
+ dateAnchor + "'. Must be 'local' or 'utc'");
+ }
+ }
+
public Boolean getStringEnums() {
return this.stringEnums;
}
@@ -359,6 +384,10 @@ public void processOpts() {
this.setDateLibrary(additionalProperties.get(DATE_LIBRARY).toString());
}
+ if (additionalProperties.containsKey(DATE_ANCHOR)) {
+ this.setDateAnchor(additionalProperties.get(DATE_ANCHOR).toString());
+ }
+
if (!withoutRuntimeChecks) {
this.modelTemplateFiles.put("models.mustache", ".ts");
}
@@ -390,6 +419,13 @@ public void processOpts() {
additionalProperties.put("isDateLibraryString", DATE_LIBRARY_STRING.equals(this.dateLibrary));
additionalProperties.put("isDateLibraryTemporal", DATE_LIBRARY_TEMPORAL.equals(this.dateLibrary));
+ if (DATE_ANCHOR_UTC.equals(this.dateAnchor) && !DATE_LIBRARY_DATE.equals(this.dateLibrary)) {
+ LOGGER.warn("{}={} only applies when {}={}; ignoring {}={}.",
+ DATE_ANCHOR, this.dateAnchor, DATE_LIBRARY, DATE_LIBRARY_DATE, DATE_ANCHOR, this.dateAnchor);
+ }
+ additionalProperties.put(DATE_ANCHOR, this.dateAnchor);
+ additionalProperties.put("isDateAnchorUtc", DATE_ANCHOR_UTC.equals(this.dateAnchor) && DATE_LIBRARY_DATE.equals(this.dateLibrary));
+
if (additionalProperties.containsKey(SAGAS_AND_RECORDS)) {
this.setSagasAndRecords(convertPropertyToBoolean(SAGAS_AND_RECORDS));
if (this.getSagasAndRecords()) {
diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache
index 76921c1e2896..9aaecc252db8 100644
--- a/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache
+++ b/modules/openapi-generator/src/main/resources/typescript-fetch/runtime.mustache
@@ -411,8 +411,14 @@ export function parseDate(value: Temporal.PlainDate | string): Temporal.PlainDat
* Every generated date call site routes through these.
*
* `format: date` is a calendar date, with no time and no offset, so it is converted
+{{#isDateAnchorUtc}}
+ * against UTC on both ends: the UTC calendar day is preserved everywhere.
+ * `format: date-time` is an instant and uses UTC.
+{{/isDateAnchorUtc}}
+{{^isDateAnchorUtc}}
* against the local calendar on both ends: they have to agree or the date shifts by
* a day. `format: date-time` is an instant and uses UTC.
+{{/isDateAnchorUtc}}
*/
export function serializeDateTime(value: Date): string {
return value.toISOString();
@@ -423,10 +429,15 @@ export function serializeDate(value: Date): string {
if (isNaN(value.getTime())) {
throw new RangeError('Invalid time value');
}
+{{#isDateAnchorUtc}}
+ return value.toISOString().substring(0, 10);
+{{/isDateAnchorUtc}}
+{{^isDateAnchorUtc}}
const year = ('000' + value.getFullYear()).slice(-4);
const month = ('0' + (value.getMonth() + 1)).slice(-2);
const day = ('0' + value.getDate()).slice(-2);
return `${year}-${month}-${day}`;
+{{/isDateAnchorUtc}}
}
@@ -434,6 +445,10 @@ export function parseDate(value: Date | string): Date {
if (value instanceof Date) {
return value;
}
+{{#isDateAnchorUtc}}
+ return new Date(value);
+{{/isDateAnchorUtc}}
+{{^isDateAnchorUtc}}
// `new Date("2026-08-05")` would parse as UTC midnight: a different day west of UTC.
// Local midnight is the stated day everywhere. setFullYear avoids the 1900 offset the
// multi-argument constructor applies to years 0-99.
@@ -453,6 +468,7 @@ export function parseDate(value: Date | string): Date {
return date;
}
return new Date(value);
+{{/isDateAnchorUtc}}
}
export function parseDateTime(value: any): Date {
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java
index 9b35b5074d35..4b4a472aff99 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/options/TypeScriptFetchClientOptionsProvider.java
@@ -32,6 +32,7 @@ public class TypeScriptFetchClientOptionsProvider implements TypeScriptSharedCli
public static final String STRING_ENUMS = "false";
public static final String FILE_NAMING_VALUE = PASCAL_CASE;
public static final String DATE_LIBRARY_VALUE = TypeScriptFetchClientCodegen.DATE_LIBRARY_STRING;
+ public static final String DATE_ANCHOR_VALUE = TypeScriptFetchClientCodegen.DATE_ANCHOR_UTC;
@Override
@@ -52,6 +53,7 @@ public Map createOptions() {
.put(TypeScriptFetchClientCodegen.IMPORT_FILE_EXTENSION_SWITCH, IMPORT_FILE_EXTENSION_VALUE)
.put(TypeScriptFetchClientCodegen.FILE_NAMING, FILE_NAMING_VALUE)
.put(TypeScriptFetchClientCodegen.DATE_LIBRARY, DATE_LIBRARY_VALUE)
+ .put(TypeScriptFetchClientCodegen.DATE_ANCHOR, DATE_ANCHOR_VALUE)
.put(TypeScriptFetchClientCodegen.STRING_ENUMS, STRING_ENUMS)
.put(TypeScriptFetchClientCodegen.USE_SQUARE_BRACKETS_IN_ARRAY_NAMES, Boolean.FALSE.toString())
.put(TypeScriptFetchClientCodegen.VALIDATION_ATTRIBUTES, Boolean.FALSE.toString())
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientCodegenTest.java
index 836202953a1c..7c69df52865d 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientCodegenTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientCodegenTest.java
@@ -1493,6 +1493,54 @@ public void testDateLibraryDateFallsBackToStringWithoutRuntimeChecks() throws IO
TestUtils.assertFileNotContains(modelsIndex, "startsOn: Date;");
}
+ @Test(description = "Verify dateAnchor=local is the default: format: date is anchored to the local calendar")
+ public void testDateAnchorLocalIsTheDefault() throws IOException {
+ File output = generate(new HashMap<>(), DATE_HANDLING_SPEC);
+
+ Path runtime = Paths.get(output + "/runtime.ts");
+ TestUtils.assertFileContains(runtime, "const year = ('000' + value.getFullYear()).slice(-4);");
+ TestUtils.assertFileContains(runtime, "date.setHours(0, 0, 0, 0);");
+ TestUtils.assertFileNotContains(runtime, "return value.toISOString().substring(0, 10);");
+ }
+
+ @Test(description = "Verify dateAnchor=utc restores the pre-7.25 UTC anchoring of format: date")
+ public void testDateAnchorUtc() throws IOException {
+ Map properties = new HashMap<>();
+ properties.put(TypeScriptFetchClientCodegen.DATE_ANCHOR, TypeScriptFetchClientCodegen.DATE_ANCHOR_UTC);
+
+ File output = generate(properties, DATE_HANDLING_SPEC);
+
+ Path runtime = Paths.get(output + "/runtime.ts");
+ TestUtils.assertFileContains(runtime, "return value.toISOString().substring(0, 10);");
+ TestUtils.assertFileContains(runtime, "export function parseDate(value: Date | string): Date {\n if (value instanceof Date) {\n return value;\n }\n return new Date(value);\n}");
+ TestUtils.assertFileNotContains(runtime, "setFullYear(year, month, day)");
+ TestUtils.assertFileNotContains(runtime, "date.setHours(0, 0, 0, 0);");
+
+ Path event = Paths.get(output + "/models/Event.ts");
+ TestUtils.assertFileContains(event, "startsOn: Date;");
+ TestUtils.assertFileContains(event, "'startsOn': (json['startsOn'] == null ? json['startsOn'] : parseDate(json['startsOn']))");
+ TestUtils.assertFileContains(event, "'startsOn': value['startsOn'] == null ? value['startsOn'] : serializeDate(value['startsOn'])");
+ }
+
+ @Test(description = "Verify dateAnchor=utc is ignored when dateLibrary is not date")
+ public void testDateAnchorUtcIsIgnoredWithoutDateLibraryDate() throws IOException {
+ Map properties = new HashMap<>();
+ properties.put(TypeScriptFetchClientCodegen.DATE_ANCHOR, TypeScriptFetchClientCodegen.DATE_ANCHOR_UTC);
+ properties.put(TypeScriptFetchClientCodegen.DATE_LIBRARY, TypeScriptFetchClientCodegen.DATE_LIBRARY_STRING);
+
+ File output = generate(properties, DATE_HANDLING_SPEC);
+
+ Path runtime = Paths.get(output + "/runtime.ts");
+ TestUtils.assertFileNotContains(runtime, "export function parseDate(");
+ TestUtils.assertFileNotContains(runtime, "export function serializeDate(");
+ TestUtils.assertFileNotContains(runtime, "return value.toISOString().substring(0, 10);");
+
+ TypeScriptFetchClientCodegen codegen = new TypeScriptFetchClientCodegen();
+ codegen.additionalProperties().putAll(properties);
+ codegen.processOpts();
+ Assert.assertEquals(codegen.additionalProperties().get("isDateAnchorUtc"), Boolean.FALSE);
+ }
+
@Test(description = "Verify format: date is serialized as a calendar date in every parameter location, not as a date-time")
public void testDateFormatIsSerializedAsACalendarDate() throws IOException {
File output = generate(new HashMap<>(), DATE_HANDLING_SPEC);
diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java
index 711e09fcf993..0f18ea27a4df 100644
--- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java
+++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/typescript/fetch/TypeScriptFetchClientOptionsTest.java
@@ -56,6 +56,7 @@ protected void verifyOptions() {
verify(clientCodegen).setStringEnums(Boolean.parseBoolean(TypeScriptFetchClientOptionsProvider.STRING_ENUMS));
verify(clientCodegen).setFileNaming(TypeScriptFetchClientOptionsProvider.FILE_NAMING_VALUE);
verify(clientCodegen).setDateLibrary(TypeScriptFetchClientOptionsProvider.DATE_LIBRARY_VALUE);
+ verify(clientCodegen).setDateAnchor(TypeScriptFetchClientOptionsProvider.DATE_ANCHOR_VALUE);
}
@Test(description = "Verify if an exception is thrown when invalid values are used with fileNaming option")
@@ -72,4 +73,18 @@ public void testFileNamingInvalidValues() {
);
}
+ @Test(description = "Verify if an exception is thrown when invalid values are used with dateAnchor option")
+ public void testDateAnchorInvalidValues() {
+ final TypeScriptFetchClientCodegen codegen = new TypeScriptFetchClientCodegen();
+ Assert.assertThrows(IllegalArgumentException.class, () ->
+ codegen.setDateAnchor(null)
+ );
+ Assert.assertThrows(IllegalArgumentException.class, () ->
+ codegen.setDateAnchor("")
+ );
+ Assert.assertThrows(IllegalArgumentException.class, () ->
+ codegen.setDateAnchor("UTC")
+ );
+ }
+
}
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/.gitignore b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/.gitignore
new file mode 100644
index 000000000000..149b57654723
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/.gitignore
@@ -0,0 +1,4 @@
+wwwroot/*.js
+node_modules
+typings
+dist
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/.npmignore b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/.npmignore
new file mode 100644
index 000000000000..42061c01a1c7
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/.npmignore
@@ -0,0 +1 @@
+README.md
\ No newline at end of file
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/.openapi-generator-ignore b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/.openapi-generator-ignore
new file mode 100644
index 000000000000..7484ee590a38
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/.openapi-generator-ignore
@@ -0,0 +1,23 @@
+# OpenAPI Generator Ignore
+# Generated by openapi-generator https://github.com/openapitools/openapi-generator
+
+# Use this file to prevent files from being overwritten by the generator.
+# The patterns follow closely to .gitignore or .dockerignore.
+
+# As an example, the C# client generator defines ApiClient.cs.
+# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
+#ApiClient.cs
+
+# You can match any string of characters against a directory, file or extension with a single asterisk (*):
+#foo/*/qux
+# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
+
+# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
+#foo/**/qux
+# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
+
+# You can also negate patterns with an exclamation (!).
+# For example, you can ignore all files in a docs folder with the file extension .md:
+#docs/*.md
+# Then explicitly reverse the ignore rule for a single file:
+#!docs/README.md
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/.openapi-generator/FILES b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/.openapi-generator/FILES
new file mode 100644
index 000000000000..3e08cfacc235
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/.openapi-generator/FILES
@@ -0,0 +1,18 @@
+.gitignore
+.npmignore
+README.md
+docs/DefaultApi.md
+docs/Event.md
+docs/Holidays.md
+docs/Venue.md
+package.json
+src/apis/DefaultApi.ts
+src/apis/index.ts
+src/index.ts
+src/models/Event.ts
+src/models/Holidays.ts
+src/models/Venue.ts
+src/models/index.ts
+src/runtime.ts
+tsconfig.esm.json
+tsconfig.json
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/.openapi-generator/VERSION b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/.openapi-generator/VERSION
new file mode 100644
index 000000000000..84bf2ceeaede
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/.openapi-generator/VERSION
@@ -0,0 +1 @@
+7.28.0-SNAPSHOT
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/README.md b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/README.md
new file mode 100644
index 000000000000..b31d9b5b3edc
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/README.md
@@ -0,0 +1,117 @@
+# @openapitools/typescript-fetch-petstore@1.0.0
+
+A TypeScript SDK client for the localhost API.
+
+## Usage
+
+First, install the SDK from npm.
+
+```bash
+npm install @openapitools/typescript-fetch-petstore --save
+```
+
+Next, try it out.
+
+
+```ts
+import {
+ Configuration,
+ DefaultApi,
+} from '@openapitools/typescript-fetch-petstore';
+import type { CreateEventRequest } from '@openapitools/typescript-fetch-petstore';
+
+async function example() {
+ console.log("🚀 Testing @openapitools/typescript-fetch-petstore SDK...");
+ const api = new DefaultApi();
+
+ const body = {
+ // Date
+ startsOn: 2013-10-20,
+ // Date (optional)
+ createdAt: 2013-10-20T19:20:30+01:00,
+ } satisfies CreateEventRequest;
+
+ try {
+ const data = await api.createEvent(body);
+ console.log(data);
+ } catch (error) {
+ console.error(error);
+ }
+}
+
+// Run the test
+example().catch(console.error);
+```
+
+
+## Documentation
+
+### API Endpoints
+
+All URIs are relative to *http://localhost*
+
+| Class | Method | HTTP request | Description
+| ----- | ------ | ------------ | -------------
+*DefaultApi* | [**createEvent**](docs/DefaultApi.md#createevent) | **POST** /events |
+*DefaultApi* | [**listEvents**](docs/DefaultApi.md#listevents) | **GET** /events/{onDate} |
+
+
+### Models
+
+- [Event](docs/Event.md)
+- [Holidays](docs/Holidays.md)
+- [Venue](docs/Venue.md)
+
+### Authorization
+
+Endpoints do not require authorization.
+
+
+## About
+
+This TypeScript SDK client supports the [Fetch API](https://fetch.spec.whatwg.org/)
+and is automatically generated by the
+[OpenAPI Generator](https://openapi-generator.tech) project:
+
+- API version: `1.0.0`
+- Package version: `1.0.0`
+- Generator version: `7.28.0-SNAPSHOT`
+- Build package: `org.openapitools.codegen.languages.TypeScriptFetchClientCodegen`
+
+The generated npm module supports the following:
+
+- Environments
+ * Node.js
+ * Webpack
+ * Browserify
+- Language levels
+ * ES5 - you must have a Promises/A+ library installed
+ * ES6
+- Module systems
+ * CommonJS
+ * ES6 module system
+
+
+## Development
+
+### Building
+
+To build the TypeScript source code, you need to have Node.js and npm installed.
+After cloning the repository, navigate to the project directory and run:
+
+```bash
+npm install
+npm run build
+```
+
+### Publishing
+
+Once you've built the package, you can publish it to npm:
+
+```bash
+npm publish
+```
+
+## License
+
+[]()
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/docs/DefaultApi.md b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/docs/DefaultApi.md
new file mode 100644
index 000000000000..ba094d1fefb5
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/docs/DefaultApi.md
@@ -0,0 +1,149 @@
+# DefaultApi
+
+All URIs are relative to *http://localhost*
+
+| Method | HTTP request | Description |
+|------------- | ------------- | -------------|
+| [**createEvent**](DefaultApi.md#createevent) | **POST** /events | |
+| [**listEvents**](DefaultApi.md#listevents) | **GET** /events/{onDate} | |
+
+
+
+## createEvent
+
+> Event createEvent(startsOn, createdAt)
+
+
+
+### Example
+
+```ts
+import {
+ Configuration,
+ DefaultApi,
+} from '@openapitools/typescript-fetch-petstore';
+import type { CreateEventRequest } from '@openapitools/typescript-fetch-petstore';
+
+async function example() {
+ console.log("🚀 Testing @openapitools/typescript-fetch-petstore SDK...");
+ const api = new DefaultApi();
+
+ const body = {
+ // Date
+ startsOn: 2013-10-20,
+ // Date (optional)
+ createdAt: 2013-10-20T19:20:30+01:00,
+ } satisfies CreateEventRequest;
+
+ try {
+ const data = await api.createEvent(body);
+ console.log(data);
+ } catch (error) {
+ console.error(error);
+ }
+}
+
+// Run the test
+example().catch(console.error);
+```
+
+### Parameters
+
+
+| Name | Type | Description | Notes |
+|------------- | ------------- | ------------- | -------------|
+| **startsOn** | `Date` | | [Defaults to `undefined`] |
+| **createdAt** | `Date` | | [Optional] [Defaults to `undefined`] |
+
+### Return type
+
+[**Event**](Event.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+- **Content-Type**: `application/x-www-form-urlencoded`
+- **Accept**: `application/json`
+
+
+### HTTP response details
+| Status code | Description | Response headers |
+|-------------|-------------|------------------|
+| **200** | the created event | - |
+
+[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
+
+
+## listEvents
+
+> Array<Event> listEvents(onDate, from, updatedSince)
+
+
+
+### Example
+
+```ts
+import {
+ Configuration,
+ DefaultApi,
+} from '@openapitools/typescript-fetch-petstore';
+import type { ListEventsRequest } from '@openapitools/typescript-fetch-petstore';
+
+async function example() {
+ console.log("🚀 Testing @openapitools/typescript-fetch-petstore SDK...");
+ const api = new DefaultApi();
+
+ const body = {
+ // Date
+ onDate: 2013-10-20,
+ // Date (optional)
+ from: 2013-10-20,
+ // Date (optional)
+ updatedSince: 2013-10-20T19:20:30+01:00,
+ } satisfies ListEventsRequest;
+
+ try {
+ const data = await api.listEvents(body);
+ console.log(data);
+ } catch (error) {
+ console.error(error);
+ }
+}
+
+// Run the test
+example().catch(console.error);
+```
+
+### Parameters
+
+
+| Name | Type | Description | Notes |
+|------------- | ------------- | ------------- | -------------|
+| **onDate** | `Date` | | [Defaults to `undefined`] |
+| **from** | `Date` | | [Optional] [Defaults to `undefined`] |
+| **updatedSince** | `Date` | | [Optional] [Defaults to `undefined`] |
+
+### Return type
+
+[**Array<Event>**](Event.md)
+
+### Authorization
+
+No authorization required
+
+### HTTP request headers
+
+- **Content-Type**: Not defined
+- **Accept**: `application/json`
+
+
+### HTTP response details
+| Status code | Description | Response headers |
+|-------------|-------------|------------------|
+| **200** | matching events | - |
+
+[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
+
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/docs/Event.md b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/docs/Event.md
new file mode 100644
index 000000000000..fad20771f599
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/docs/Event.md
@@ -0,0 +1,38 @@
+
+# Event
+
+
+## Properties
+
+Name | Type
+------------ | -------------
+`startsOn` | Date
+`endsOn` | Date
+`createdAt` | Date
+
+## Example
+
+```typescript
+import type { Event } from '@openapitools/typescript-fetch-petstore'
+
+// TODO: Update the object below with actual values
+const example = {
+ "startsOn": null,
+ "endsOn": null,
+ "createdAt": null,
+} satisfies Event
+
+console.log(example)
+
+// Convert the instance to a JSON string
+const exampleJSON: string = JSON.stringify(example)
+console.log(exampleJSON)
+
+// Parse the JSON string back to an object
+const exampleParsed = JSON.parse(exampleJSON) as Event
+console.log(exampleParsed)
+```
+
+[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/docs/Holidays.md b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/docs/Holidays.md
new file mode 100644
index 000000000000..8fce59f17544
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/docs/Holidays.md
@@ -0,0 +1,33 @@
+
+# Holidays
+
+A oneOf whose branch is picked by testing the value against the date helper.
+
+## Properties
+
+Name | Type
+------------ | -------------
+
+## Example
+
+```typescript
+import type { Holidays } from '@openapitools/typescript-fetch-petstore'
+
+// TODO: Update the object below with actual values
+const example = {
+} satisfies Holidays
+
+console.log(example)
+
+// Convert the instance to a JSON string
+const exampleJSON: string = JSON.stringify(example)
+console.log(exampleJSON)
+
+// Parse the JSON string back to an object
+const exampleParsed = JSON.parse(exampleJSON) as Holidays
+console.log(exampleParsed)
+```
+
+[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/docs/Venue.md b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/docs/Venue.md
new file mode 100644
index 000000000000..44dd22b3f4d5
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/docs/Venue.md
@@ -0,0 +1,35 @@
+
+# Venue
+
+Has no date of any kind, so it must not import the date helpers.
+
+## Properties
+
+Name | Type
+------------ | -------------
+`name` | string
+
+## Example
+
+```typescript
+import type { Venue } from '@openapitools/typescript-fetch-petstore'
+
+// TODO: Update the object below with actual values
+const example = {
+ "name": null,
+} satisfies Venue
+
+console.log(example)
+
+// Convert the instance to a JSON string
+const exampleJSON: string = JSON.stringify(example)
+console.log(exampleJSON)
+
+// Parse the JSON string back to an object
+const exampleParsed = JSON.parse(exampleJSON) as Venue
+console.log(exampleParsed)
+```
+
+[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
+
+
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/package.json b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/package.json
new file mode 100644
index 000000000000..6d44ed32b0c2
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/package.json
@@ -0,0 +1,24 @@
+{
+ "name": "@openapitools/typescript-fetch-petstore",
+ "version": "1.0.0",
+ "description": "OpenAPI client for @openapitools/typescript-fetch-petstore",
+ "author": "OpenAPI-Generator",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/GIT_USER_ID/GIT_REPO_ID.git"
+ },
+ "main": "./dist/index.js",
+ "types": "./dist/index.d.ts",
+ "module": "./dist/esm/index.js",
+ "sideEffects": false,
+ "scripts": {
+ "build": "tsc && tsc -p tsconfig.esm.json",
+ "prepare": "npm run build"
+ },
+ "devDependencies": {
+ "typescript": "^4.0 || ^5.0"
+ },
+ "publishConfig": {
+ "registry": "https://skimdb.npmjs.com/registry"
+ }
+}
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/apis/DefaultApi.ts b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/apis/DefaultApi.ts
new file mode 100644
index 000000000000..879209121093
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/apis/DefaultApi.ts
@@ -0,0 +1,173 @@
+/* tslint:disable */
+/* eslint-disable */
+/**
+ * Date handling
+ * Covers every location a `format: date` or `format: date-time` value can appear in, so the generated (de)serialization can be checked in one place.
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+import * as runtime from '../runtime';
+import {
+ type Event,
+ EventFromJSON,
+ EventToJSON,
+} from '../models/Event';
+
+export interface CreateEventRequest {
+ /**
+ *
+ */
+ startsOn: Date;
+ /**
+ *
+ */
+ createdAt?: Date;
+}
+
+export interface ListEventsRequest {
+ /**
+ *
+ */
+ onDate: Date;
+ /**
+ *
+ */
+ from?: Date;
+ /**
+ *
+ */
+ updatedSince?: Date;
+}
+
+/**
+ *
+ */
+export class DefaultApi extends runtime.BaseAPI {
+
+ /**
+ * Creates request options for createEvent without sending the request
+ */
+ async createEventRequestOpts(requestParameters: CreateEventRequest): Promise {
+ if (requestParameters['startsOn'] == null) {
+ throw new runtime.RequiredError(
+ 'startsOn',
+ 'Required parameter "startsOn" was null or undefined when calling createEvent().'
+ );
+ }
+
+ const queryParameters: any = {};
+
+ const headerParameters: runtime.HTTPHeaders = {};
+
+ const consumes: runtime.Consume[] = [
+ { contentType: 'application/x-www-form-urlencoded' },
+ ];
+ // @ts-ignore: canConsumeForm may be unused
+ const canConsumeForm = runtime.canConsumeForm(consumes);
+
+ let formParams: { append(param: string, value: any): any };
+ let useForm = false;
+ if (useForm) {
+ formParams = new FormData();
+ } else {
+ formParams = new URLSearchParams();
+ }
+
+ if (requestParameters['startsOn'] != null) {
+ formParams.append('startsOn', runtime.serializeDate(requestParameters['startsOn'] as any));
+ }
+
+ if (requestParameters['createdAt'] != null) {
+ formParams.append('createdAt', runtime.serializeDateTime(requestParameters['createdAt'] as any));
+ }
+
+
+ let urlPath = `/events`;
+
+ return {
+ path: urlPath,
+ method: 'POST',
+ headers: headerParameters,
+ query: queryParameters,
+ body: formParams,
+ };
+ }
+
+ /**
+ */
+ async createEventRaw(requestParameters: CreateEventRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> {
+ const requestOptions = await this.createEventRequestOpts(requestParameters);
+ const response = await this.request(requestOptions, initOverrides);
+
+ return new runtime.JSONApiResponse(response, (jsonValue) => EventFromJSON(jsonValue));
+ }
+
+ /**
+ */
+ async createEvent(requestParameters: CreateEventRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise {
+ const response = await this.createEventRaw(requestParameters, initOverrides);
+ return await response.value();
+ }
+
+ /**
+ * Creates request options for listEvents without sending the request
+ */
+ async listEventsRequestOpts(requestParameters: ListEventsRequest): Promise {
+ if (requestParameters['onDate'] == null) {
+ throw new runtime.RequiredError(
+ 'onDate',
+ 'Required parameter "onDate" was null or undefined when calling listEvents().'
+ );
+ }
+
+ const queryParameters: any = {};
+
+ if (requestParameters['from'] != null) {
+ queryParameters['from'] = runtime.serializeDate(requestParameters['from'] as any);
+ }
+
+ if (requestParameters['updatedSince'] != null) {
+ queryParameters['updatedSince'] = runtime.serializeDateTime(requestParameters['updatedSince'] as any);
+ }
+
+ const headerParameters: runtime.HTTPHeaders = {};
+
+
+ let urlPath = `/events/{onDate}`;
+ if (requestParameters['onDate'] instanceof Date) {
+ urlPath = urlPath.replace('{onDate}', encodeURIComponent(runtime.serializeDate(requestParameters['onDate'])));
+ } else {
+ urlPath = urlPath.replace('{onDate}', encodeURIComponent(String(requestParameters['onDate'])));
+ }
+
+ return {
+ path: urlPath,
+ method: 'GET',
+ headers: headerParameters,
+ query: queryParameters,
+ };
+ }
+
+ /**
+ */
+ async listEventsRaw(requestParameters: ListEventsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise>> {
+ const requestOptions = await this.listEventsRequestOpts(requestParameters);
+ const response = await this.request(requestOptions, initOverrides);
+
+ return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(EventFromJSON));
+ }
+
+ /**
+ */
+ async listEvents(requestParameters: ListEventsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise> {
+ const response = await this.listEventsRaw(requestParameters, initOverrides);
+ return await response.value();
+ }
+
+}
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/apis/index.ts b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/apis/index.ts
new file mode 100644
index 000000000000..69c44c00fa0d
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/apis/index.ts
@@ -0,0 +1,3 @@
+/* tslint:disable */
+/* eslint-disable */
+export * from './DefaultApi';
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/index.ts b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/index.ts
new file mode 100644
index 000000000000..bebe8bbbe206
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/index.ts
@@ -0,0 +1,5 @@
+/* tslint:disable */
+/* eslint-disable */
+export * from './runtime';
+export * from './apis/index';
+export * from './models/index';
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/models/Event.ts b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/models/Event.ts
new file mode 100644
index 000000000000..4d64ddb87131
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/models/Event.ts
@@ -0,0 +1,76 @@
+/* tslint:disable */
+/* eslint-disable */
+/**
+ * Date handling
+ * Covers every location a `format: date` or `format: date-time` value can appear in, so the generated (de)serialization can be checked in one place.
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+import { mapValues, parseDate, parseDateTime, serializeDate, serializeDateTime } from '../runtime';
+/**
+ *
+ * @export
+ * @interface Event
+ */
+export interface Event {
+ /**
+ *
+ */
+ startsOn: Date;
+ /**
+ *
+ */
+ endsOn?: Date | null;
+ /**
+ *
+ */
+ createdAt?: Date;
+}
+
+/**
+ * Check if a given object implements the Event interface.
+ */
+export function instanceOfEvent(value: object): value is Event {
+ if (!('startsOn' in value) || value['startsOn'] === undefined) return false;
+ return true;
+}
+
+export function EventFromJSON(json: any): Event {
+ return EventFromJSONTyped(json, false);
+}
+
+export function EventFromJSONTyped(json: any, ignoreDiscriminator: boolean): Event {
+ if (json == null) {
+ return json;
+ }
+ return {
+
+ 'startsOn': (json['startsOn'] == null ? json['startsOn'] : parseDate(json['startsOn'])),
+ 'endsOn': json['endsOn'] === undefined ? undefined : json['endsOn'] === null ? null : (parseDate(json['endsOn'])),
+ 'createdAt': json['createdAt'] == null ? undefined : (parseDateTime(json['createdAt'])),
+ };
+}
+
+export function EventToJSON(json: any): Event {
+ return EventToJSONTyped(json, false);
+}
+
+export function EventToJSONTyped(value?: Event | null, ignoreDiscriminator: boolean = false): any {
+ if (value == null) {
+ return value;
+ }
+
+ return {
+
+ 'startsOn': value['startsOn'] == null ? value['startsOn'] : serializeDate(value['startsOn']),
+ 'endsOn': value['endsOn'] == null ? value['endsOn'] : serializeDate(value['endsOn']),
+ 'createdAt': value['createdAt'] == null ? value['createdAt'] : serializeDateTime(value['createdAt']),
+ };
+}
+
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/models/Holidays.ts b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/models/Holidays.ts
new file mode 100644
index 000000000000..cbd3b5cd29ab
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/models/Holidays.ts
@@ -0,0 +1,64 @@
+/* tslint:disable */
+/* eslint-disable */
+/**
+ * Date handling
+ * Covers every location a `format: date` or `format: date-time` value can appear in, so the generated (de)serialization can be checked in one place.
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+import { parseDate, parseDateTime, serializeDate, serializeDateTime } from '../runtime';
+/**
+ * @type Holidays
+ * A oneOf whose branch is picked by testing the value against the date helper.
+ * @export
+ */
+export type Holidays = Array | Array;
+
+export function HolidaysFromJSON(json: any): Holidays {
+ return HolidaysFromJSONTyped(json, false);
+}
+
+export function HolidaysFromJSONTyped(json: any, ignoreDiscriminator: boolean): Holidays {
+ if (json == null) {
+ return json;
+ }
+ if (Array.isArray(json)) {
+ if (json.every(item => !(isNaN(parseDate(item).getTime())))) {
+ return json.map(value => parseDate(value));
+ }
+ }
+ if (Array.isArray(json)) {
+ if (json.every(item => typeof item === 'number')) {
+ return json;
+ }
+ }
+ return {} as any;
+}
+
+export function HolidaysToJSON(json: any): any {
+ return HolidaysToJSONTyped(json, false);
+}
+
+export function HolidaysToJSONTyped(value?: Holidays | null, ignoreDiscriminator: boolean = false): any {
+ if (value == null) {
+ return value;
+ }
+ if (Array.isArray(value)) {
+ if (value.every(item => item instanceof Date)) {
+ return value.map(value => serializeDate(value));
+ }
+ }
+ if (Array.isArray(value)) {
+ if (value.every(item => typeof item === 'number')) {
+ return value;
+ }
+ }
+ return {};
+}
+
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/models/Venue.ts b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/models/Venue.ts
new file mode 100644
index 000000000000..1a97a56452f1
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/models/Venue.ts
@@ -0,0 +1,63 @@
+/* tslint:disable */
+/* eslint-disable */
+/**
+ * Date handling
+ * Covers every location a `format: date` or `format: date-time` value can appear in, so the generated (de)serialization can be checked in one place.
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+import { mapValues } from '../runtime';
+/**
+ * Has no date of any kind, so it must not import the date helpers.
+ * @export
+ * @interface Venue
+ */
+export interface Venue {
+ /**
+ *
+ */
+ name?: string;
+}
+
+/**
+ * Check if a given object implements the Venue interface.
+ */
+export function instanceOfVenue(value: object): value is Venue {
+ return true;
+}
+
+export function VenueFromJSON(json: any): Venue {
+ return VenueFromJSONTyped(json, false);
+}
+
+export function VenueFromJSONTyped(json: any, ignoreDiscriminator: boolean): Venue {
+ if (json == null) {
+ return json;
+ }
+ return {
+
+ 'name': json['name'] == null ? undefined : json['name'],
+ };
+}
+
+export function VenueToJSON(json: any): Venue {
+ return VenueToJSONTyped(json, false);
+}
+
+export function VenueToJSONTyped(value?: Venue | null, ignoreDiscriminator: boolean = false): any {
+ if (value == null) {
+ return value;
+ }
+
+ return {
+
+ 'name': value['name'],
+ };
+}
+
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/models/index.ts b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/models/index.ts
new file mode 100644
index 000000000000..78f198c92352
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/models/index.ts
@@ -0,0 +1,5 @@
+/* tslint:disable */
+/* eslint-disable */
+export * from './Event';
+export * from './Holidays';
+export * from './Venue';
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/runtime.ts
new file mode 100644
index 000000000000..625dc3ca235d
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/src/runtime.ts
@@ -0,0 +1,551 @@
+/* tslint:disable */
+/* eslint-disable */
+/**
+ * Date handling
+ * Covers every location a `format: date` or `format: date-time` value can appear in, so the generated (de)serialization can be checked in one place.
+ *
+ * The version of the OpenAPI document: 1.0.0
+ *
+ *
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
+ * https://openapi-generator.tech
+ * Do not edit the class manually.
+ */
+
+export const BASE_PATH: string = "http://localhost".replace(/\/+$/, "");
+
+export interface ConfigurationParameters {
+ basePath?: string; // override base path
+ fetchApi?: FetchAPI; // override for fetch implementation
+ middleware?: Middleware[]; // middleware to apply before/after fetch requests
+ queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
+ username?: string; // parameter for basic security
+ password?: string; // parameter for basic security
+ apiKey?: string | Promise | ((name: string) => string | Promise); // parameter for apiKey security
+ accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string | Promise); // parameter for oauth2 security
+ headers?: HTTPHeaders; //header params we want to use on every request
+ credentials?: RequestCredentials; //value for the credentials param we want to use on each request
+}
+
+export class Configuration {
+ constructor(private configuration: ConfigurationParameters = {}) {}
+
+ set config(configuration: Configuration) {
+ this.configuration = configuration;
+ }
+
+ get basePath(): string {
+ return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
+ }
+
+ get fetchApi(): FetchAPI | undefined {
+ return this.configuration.fetchApi;
+ }
+
+ get middleware(): Middleware[] {
+ return this.configuration.middleware || [];
+ }
+
+ get queryParamsStringify(): (params: HTTPQuery) => string {
+ return this.configuration.queryParamsStringify || querystring;
+ }
+
+ get username(): string | undefined {
+ return this.configuration.username;
+ }
+
+ get password(): string | undefined {
+ return this.configuration.password;
+ }
+
+ get apiKey(): ((name: string) => string | Promise) | undefined {
+ const apiKey = this.configuration.apiKey;
+ if (apiKey) {
+ return typeof apiKey === 'function' ? apiKey : () => apiKey;
+ }
+ return undefined;
+ }
+
+ get accessToken(): ((name?: string, scopes?: string[]) => string | Promise) | undefined {
+ const accessToken = this.configuration.accessToken;
+ if (accessToken) {
+ return typeof accessToken === 'function' ? accessToken : async () => accessToken;
+ }
+ return undefined;
+ }
+
+ get headers(): HTTPHeaders | undefined {
+ return this.configuration.headers;
+ }
+
+ get credentials(): RequestCredentials | undefined {
+ return this.configuration.credentials;
+ }
+}
+
+export const DefaultConfig: Configuration = new Configuration();
+
+/**
+ * This is the base class for all generated API classes.
+ */
+export class BaseAPI {
+
+ private static readonly jsonRegex = /^(:?application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(:?;.*)?$/i;
+ private middleware: Middleware[];
+
+ constructor(protected configuration: Configuration = DefaultConfig) {
+ this.middleware = configuration.middleware;
+ }
+
+ withMiddleware(this: T, ...middlewares: Middleware[]): T {
+ const next = this.clone();
+ next.middleware = next.middleware.concat(...middlewares);
+ return next;
+ }
+
+ withPreMiddleware(this: T, ...preMiddlewares: Array): T {
+ const middlewares = preMiddlewares.map((pre) => ({ pre }));
+ return this.withMiddleware(...middlewares);
+ }
+
+ withPostMiddleware(this: T, ...postMiddlewares: Array): T {
+ const middlewares = postMiddlewares.map((post) => ({ post }));
+ return this.withMiddleware(...middlewares);
+ }
+
+ /**
+ * Check if the given MIME is a JSON MIME.
+ * JSON MIME examples:
+ * application/json
+ * application/json; charset=UTF8
+ * APPLICATION/JSON
+ * application/vnd.company+json
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
+ * @return True if the given MIME is JSON, false otherwise.
+ */
+ protected isJsonMime(mime: string | null | undefined): boolean {
+ if (!mime) {
+ return false;
+ }
+ return BaseAPI.jsonRegex.test(mime);
+ }
+
+ protected async request(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction): Promise {
+ const { url, init } = await this.createFetchParams(context, initOverrides);
+ const response = await this.fetchApi(url, init);
+ if (response && (response.status >= 200 && response.status < 300)) {
+ return response;
+ }
+ throw new ResponseError(response, 'Response returned an error code');
+ }
+
+ private async createFetchParams(context: RequestOpts, initOverrides?: RequestInit | InitOverrideFunction) {
+ let url = this.configuration.basePath + context.path;
+ if (context.query !== undefined && Object.keys(context.query).length !== 0) {
+ // only add the querystring to the URL if there are query parameters.
+ // this is done to avoid urls ending with a "?" character which buggy webservers
+ // do not handle correctly sometimes.
+ url += '?' + this.configuration.queryParamsStringify(context.query);
+ }
+
+ const headers = Object.assign({}, this.configuration.headers, context.headers);
+ Object.keys(headers).forEach(key => headers[key] === undefined ? delete headers[key] : {});
+
+ const initOverrideFn =
+ typeof initOverrides === "function"
+ ? initOverrides
+ : async () => initOverrides;
+
+ const initParams = {
+ method: context.method,
+ headers,
+ body: context.body,
+ credentials: this.configuration.credentials,
+ };
+
+ const overriddenInit: RequestInit = {
+ ...initParams,
+ ...(await initOverrideFn({
+ init: initParams,
+ context,
+ }))
+ };
+
+ let body: any;
+ if (isFormData(overriddenInit.body)
+ || (overriddenInit.body instanceof URLSearchParams)
+ || isBlob(overriddenInit.body)) {
+ body = overriddenInit.body;
+ } else if (this.isJsonMime(headers['Content-Type'])) {
+ body = JSON.stringify(overriddenInit.body);
+ } else {
+ body = overriddenInit.body;
+ }
+
+ const init: RequestInit = {
+ ...overriddenInit,
+ body
+ };
+
+ return { url, init };
+ }
+
+ private fetchApi = async (url: string, init: RequestInit) => {
+ let fetchParams = { url, init };
+ for (const middleware of this.middleware) {
+ if (middleware.pre) {
+ fetchParams = await middleware.pre({
+ fetch: this.fetchApi,
+ ...fetchParams,
+ }) || fetchParams;
+ }
+ }
+ let response: Response | undefined = undefined;
+ try {
+ response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
+ } catch (e) {
+ for (const middleware of this.middleware) {
+ if (middleware.onError) {
+ response = await middleware.onError({
+ fetch: this.fetchApi,
+ url: fetchParams.url,
+ init: fetchParams.init,
+ error: e,
+ response: response ? response.clone() : undefined,
+ }) || response;
+ }
+ }
+ if (response === undefined) {
+ if (e instanceof Error) {
+ throw new FetchError(e, 'The request failed and the interceptors did not return an alternative response');
+ } else {
+ throw e;
+ }
+ }
+ }
+ for (const middleware of this.middleware) {
+ if (middleware.post) {
+ response = await middleware.post({
+ fetch: this.fetchApi,
+ url: fetchParams.url,
+ init: fetchParams.init,
+ response: response.clone(),
+ }) || response;
+ }
+ }
+ return response;
+ }
+
+ /**
+ * Create a shallow clone of `this` by constructing a new instance
+ * and then shallow cloning data members.
+ */
+ private clone(this: T): T {
+ const constructor = this.constructor as any;
+ const next = new constructor(this.configuration);
+ next.middleware = this.middleware.slice();
+ return next;
+ }
+};
+
+function isBlob(value: any): value is Blob {
+ return typeof Blob !== 'undefined' && value instanceof Blob;
+}
+
+function isFormData(value: any): value is FormData {
+ return typeof FormData !== "undefined" && value instanceof FormData;
+}
+
+export class ResponseError extends Error {
+ override name: "ResponseError" = "ResponseError";
+ constructor(public response: Response, msg?: string) {
+ super(msg);
+
+ // restore prototype chain
+ const actualProto = new.target.prototype;
+ if (Object.setPrototypeOf) {
+ Object.setPrototypeOf(this, actualProto);
+ }
+ }
+}
+
+export class FetchError extends Error {
+ override name: "FetchError" = "FetchError";
+ constructor(public cause: Error, msg?: string) {
+ super(msg);
+
+ // restore prototype chain
+ const actualProto = new.target.prototype;
+ if (Object.setPrototypeOf) {
+ Object.setPrototypeOf(this, actualProto);
+ }
+ }
+}
+
+export class RequiredError extends Error {
+ override name: "RequiredError" = "RequiredError";
+ constructor(public field: string, msg?: string) {
+ super(msg);
+
+ // restore prototype chain
+ const actualProto = new.target.prototype;
+ if (Object.setPrototypeOf) {
+ Object.setPrototypeOf(this, actualProto);
+ }
+ }
+}
+
+export const COLLECTION_FORMATS = {
+ csv: ",",
+ ssv: " ",
+ tsv: "\t",
+ pipes: "|",
+};
+
+export type FetchAPI = WindowOrWorkerGlobalScope['fetch'];
+
+export type Json = any;
+export type HTTPMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
+export type HTTPHeaders = { [key: string]: string };
+export type HTTPQuery = { [key: string]: string | number | null | boolean | Array | Set | HTTPQuery };
+export type HTTPBody = Json | FormData | URLSearchParams;
+export type HTTPRequestInit = { headers?: HTTPHeaders; method: HTTPMethod; credentials?: RequestCredentials; body?: HTTPBody };
+export type ModelPropertyNaming = 'camelCase' | 'snake_case' | 'PascalCase' | 'original';
+
+export type InitOverrideFunction = (requestContext: { init: HTTPRequestInit, context: RequestOpts }) => Promise
+
+export interface FetchParams {
+ url: string;
+ init: RequestInit;
+}
+
+export interface RequestOpts {
+ path: string;
+ method: HTTPMethod;
+ headers: HTTPHeaders;
+ query?: HTTPQuery;
+ body?: HTTPBody;
+}
+
+export function querystring(params: HTTPQuery, prefix: string = ''): string {
+ return Object.keys(params)
+ .map(key => querystringSingleKey(key, params[key], prefix))
+ .filter(part => part.length > 0)
+ .join('&');
+}
+
+function querystringSingleKey(key: string, value: string | number | null | undefined | boolean | Array | Set | HTTPQuery, keyPrefix: string = ''): string {
+ const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
+ if (value instanceof Array) {
+ const multiValue = value.map(singleValue => encodeURIComponent(String(singleValue)))
+ .join(`&${encodeURIComponent(fullKey)}=`);
+ return `${encodeURIComponent(fullKey)}=${multiValue}`;
+ }
+ if (value instanceof Set) {
+ const valueAsArray = Array.from(value);
+ return querystringSingleKey(key, valueAsArray, keyPrefix);
+ }
+ if (value instanceof Date) {
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(serializeDateTime(value))}`;
+ }
+ if (value instanceof Object) {
+ return querystring(value as HTTPQuery, fullKey);
+ }
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
+}
+
+export function exists(json: any, key: string): boolean {
+ const value = json[key];
+ return value !== null && value !== undefined;
+}
+
+/**
+ * Every generated date call site routes through these.
+ *
+ * `format: date` is a calendar date, with no time and no offset, so it is converted
+ * against UTC on both ends: the UTC calendar day is preserved everywhere.
+ * `format: date-time` is an instant and uses UTC.
+ */
+export function serializeDateTime(value: Date): string {
+ return value.toISOString();
+}
+
+export function serializeDate(value: Date): string {
+ if (isNaN(value.getTime())) {
+ throw new RangeError('Invalid time value');
+ }
+ return value.toISOString().substring(0, 10);
+}
+
+
+export function parseDate(value: Date | string): Date {
+ if (value instanceof Date) {
+ return value;
+ }
+ return new Date(value);
+}
+
+export function parseDateTime(value: any): Date {
+ return new Date(value);
+}
+
+export function mapValues(data: any, fn: (item: any) => any): { [key: string]: any } {
+ const result: { [key: string]: any } = {};
+ for (const key of Object.keys(data)) {
+ result[key] = fn(data[key]);
+ }
+ return result;
+}
+
+// Pass-through serializer for `any`-typed properties in form data. See #1877.
+export function anyToJSON(value: any): any {
+ return value;
+}
+
+export function canConsumeForm(consumes: Consume[]): boolean {
+ for (const consume of consumes) {
+ if (consume.contentType?.startsWith('multipart/form-data') == true) {
+ return true;
+ }
+ }
+ return false;
+}
+
+export interface Consume {
+ contentType: string;
+}
+
+export interface RequestContext {
+ fetch: FetchAPI;
+ url: string;
+ init: RequestInit;
+}
+
+export interface ResponseContext {
+ fetch: FetchAPI;
+ url: string;
+ init: RequestInit;
+ response: Response;
+}
+
+export interface ErrorContext {
+ fetch: FetchAPI;
+ url: string;
+ init: RequestInit;
+ error: unknown;
+ response?: Response;
+}
+
+export interface Middleware {
+ pre?(context: RequestContext): Promise;
+ post?(context: ResponseContext): Promise;
+ onError?(context: ErrorContext): Promise;
+}
+
+export interface ApiResponse {
+ raw: Response;
+ value(): Promise;
+}
+
+export interface ResponseTransformer {
+ (json: any): T;
+}
+
+export class JSONApiResponse {
+ constructor(public raw: Response, private transformer: ResponseTransformer = (jsonValue: any) => jsonValue) {}
+
+ async value(): Promise {
+ return this.transformer(await this.raw.json());
+ }
+}
+
+export class VoidApiResponse {
+ constructor(public raw: Response) {}
+
+ async value(): Promise {
+ return undefined;
+ }
+}
+
+/**
+ * A Blob carrying the file name the server advertised, empty when it did not send one. It is a File
+ * wherever one can be built, and the bare Blob given a name otherwise. Same name and shape as the
+ * `typescript` generator's browser HttpFile.
+ */
+export type HttpFile = Blob & { readonly name: string };
+
+export class BlobApiResponse {
+ constructor(public raw: Response) {}
+
+ /**
+ * The body named after the Content-Disposition header, so that a download keeps the name the
+ * server gave it. A File is built from a native Blob; the Blob itself is named where there is no
+ * global File (Node.js before 20), where File cannot be constructed, or where the Blob is not the
+ * native one, as returned by an injected fetch implementation such as node-fetch, which a File
+ * would stringify instead of wrapping.
+ */
+ async value(): Promise {
+ const blob = await this.raw.blob();
+ const name = parseContentDispositionFilename(this.raw.headers) ?? '';
+ if (typeof File !== 'undefined' && blob instanceof Blob) {
+ try {
+ return new File([blob], name, { type: blob.type });
+ } catch {
+ // File cannot be constructed: name the Blob itself
+ }
+ }
+ return Object.assign(blob, { name });
+ };
+}
+
+/**
+ * The file name advertised by a Content-Disposition header (RFC 6266): the RFC 5987 encoded
+ * `filename*` parameter first, falling back to the plain `filename` when it is malformed, not UTF-8
+ * or has no usable name. Any directory part is dropped; undefined when no usable name is advertised.
+ */
+export function parseContentDispositionFilename(headers: Headers): string | undefined {
+ const params = parseHeaderParameters(headers.get('Content-Disposition') ?? '');
+ return basename(decodeExtValue(params.get('filename*'))) ?? basename(params.get('filename'));
+}
+
+/** The decoded RFC 5987 ext-value, or undefined when it is not UTF-8 or its percent-encoding is malformed. */
+function decodeExtValue(value: string | undefined): string | undefined {
+ const match = value === undefined ? null : /^utf-8'[^']*'(.*)$/i.exec(value);
+ try {
+ return match?.[1] !== undefined ? decodeURIComponent(match[1]) : undefined;
+ } catch {
+ return undefined;
+ }
+}
+
+/**
+ * The `name=value` parameters of a header value, consumed one at a time so that a quoted-string is
+ * taken whole, `;` included. Names are lower-cased, quoted-string values are unquoted with their
+ * backslash escapes resolved, and the first occurrence of a name wins.
+ */
+function parseHeaderParameters(value: string): Map {
+ const params = new Map();
+ const parameter = /(?:^|;)\s*([^=;]+?)\s*=\s*(?:"((?:[^"\\]|\\.)*)"?|([^;]*))/g;
+ let match: RegExpExecArray | null;
+ while ((match = parameter.exec(value)) !== null) {
+ const name = (match[1] ?? '').toLowerCase();
+ if (!params.has(name)) {
+ params.set(name, match[2] !== undefined ? match[2].replace(/\\(.)/g, '$1') : (match[3] ?? '').trim());
+ }
+ }
+ return params;
+}
+
+/** The last `/` or `\` separated segment of a file name, or undefined when it is not a file name. */
+function basename(name: string | undefined): string | undefined {
+ const base = name?.split(/[\\/]/).pop();
+ return !base || base === '.' || base === '..' ? undefined : base;
+}
+
+export class TextApiResponse {
+ constructor(public raw: Response) {}
+
+ async value(): Promise {
+ return await this.raw.text();
+ };
+}
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/tsconfig.esm.json b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/tsconfig.esm.json
new file mode 100644
index 000000000000..2c0331cce040
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/tsconfig.esm.json
@@ -0,0 +1,7 @@
+{
+ "extends": "./tsconfig.json",
+ "compilerOptions": {
+ "module": "esnext",
+ "outDir": "dist/esm"
+ }
+}
diff --git a/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/tsconfig.json b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/tsconfig.json
new file mode 100644
index 000000000000..f1d5adffdbf7
--- /dev/null
+++ b/samples/client/petstore/typescript-fetch/builds/date-anchor-utc/tsconfig.json
@@ -0,0 +1,16 @@
+{
+ "compilerOptions": {
+ "declaration": true,
+ "target": "es6",
+ "module": "commonjs",
+ "outDir": "dist",
+ "rootDir": "src",
+ "typeRoots": [
+ "node_modules/@types"
+ ]
+ },
+ "exclude": [
+ "dist",
+ "node_modules"
+ ]
+}