From 5a412fa6ec7d7a4b03bc8c9a3e5773cb6afa0700 Mon Sep 17 00:00:00 2001 From: Stefan Paul Noack Date: Mon, 9 Jun 2025 22:51:56 +0300 Subject: [PATCH 1/2] typescript-fetch: use `type` modifier on imports for `discriminator.mappedModels` This ensures that the generated code works when `--verbatimModuleSyntax` is enabled for the TypeScript compiler. Regular imports already use the `type` modifier, so this should not be a breaking change. --- .../src/main/resources/typescript-fetch/modelGeneric.mustache | 2 +- .../self-import-issue/models/AbstractUserDto.ts | 4 ++-- .../builds/snakecase-discriminator/models/Animal.ts | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache index 25265adf9804..454f2c68b792 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/modelGeneric.mustache @@ -13,7 +13,7 @@ import { {{/hasImports}} {{#discriminator}} {{#discriminator.mappedModels}} -import { {{modelName}}, {{modelName}}FromJSONTyped, {{modelName}}ToJSON, {{modelName}}ToJSONTyped } from './{{modelName}}{{importFileExtension}}'; +import { type {{modelName}}, {{modelName}}FromJSONTyped, {{modelName}}ToJSON, {{modelName}}ToJSONTyped } from './{{modelName}}{{importFileExtension}}'; {{/discriminator.mappedModels}} {{/discriminator}} {{>modelGenericInterfaces}} diff --git a/samples/client/others/typescript-fetch/self-import-issue/models/AbstractUserDto.ts b/samples/client/others/typescript-fetch/self-import-issue/models/AbstractUserDto.ts index ad4ece85fb37..fda9bb25bb6e 100644 --- a/samples/client/others/typescript-fetch/self-import-issue/models/AbstractUserDto.ts +++ b/samples/client/others/typescript-fetch/self-import-issue/models/AbstractUserDto.ts @@ -21,8 +21,8 @@ import { BranchDtoToJSONTyped, } from './BranchDto'; -import { InternalAuthenticatedUserDto, InternalAuthenticatedUserDtoFromJSONTyped, InternalAuthenticatedUserDtoToJSON, InternalAuthenticatedUserDtoToJSONTyped } from './InternalAuthenticatedUserDto'; -import { RemoteAuthenticatedUserDto, RemoteAuthenticatedUserDtoFromJSONTyped, RemoteAuthenticatedUserDtoToJSON, RemoteAuthenticatedUserDtoToJSONTyped } from './RemoteAuthenticatedUserDto'; +import { type InternalAuthenticatedUserDto, InternalAuthenticatedUserDtoFromJSONTyped, InternalAuthenticatedUserDtoToJSON, InternalAuthenticatedUserDtoToJSONTyped } from './InternalAuthenticatedUserDto'; +import { type RemoteAuthenticatedUserDto, RemoteAuthenticatedUserDtoFromJSONTyped, RemoteAuthenticatedUserDtoToJSON, RemoteAuthenticatedUserDtoToJSONTyped } from './RemoteAuthenticatedUserDto'; /** * * @export diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Animal.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Animal.ts index 6edfcf079255..ae195a01bfa5 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Animal.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/Animal.ts @@ -13,8 +13,8 @@ */ import { mapValues } from '../runtime'; -import { Cat, CatFromJSONTyped, CatToJSON, CatToJSONTyped } from './Cat'; -import { Dog, DogFromJSONTyped, DogToJSON, DogToJSONTyped } from './Dog'; +import { type Cat, CatFromJSONTyped, CatToJSON, CatToJSONTyped } from './Cat'; +import { type Dog, DogFromJSONTyped, DogToJSON, DogToJSONTyped } from './Dog'; /** * * @export From 1a3d33cdb5330ed5054e2d018d6a319755307c10 Mon Sep 17 00:00:00 2001 From: Stefan Paul Noack Date: Tue, 17 Jun 2025 19:29:05 +0300 Subject: [PATCH 2/2] update samples --- .../typescript-fetch/builds/default-v3.0/models/Animal.ts | 4 ++-- .../builds/default-v3.0/models/ParentWithNullable.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Animal.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Animal.ts index a6fed19c73b4..d7831b21cab8 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Animal.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/Animal.ts @@ -13,8 +13,8 @@ */ import { mapValues } from '../runtime'; -import { Cat, CatFromJSONTyped, CatToJSON, CatToJSONTyped } from './Cat'; -import { Dog, DogFromJSONTyped, DogToJSON, DogToJSONTyped } from './Dog'; +import { type Cat, CatFromJSONTyped, CatToJSON, CatToJSONTyped } from './Cat'; +import { type Dog, DogFromJSONTyped, DogToJSON, DogToJSONTyped } from './Dog'; /** * * @export diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts index 410f2d732ccb..fdc763ac2e46 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/ParentWithNullable.ts @@ -13,7 +13,7 @@ */ import { mapValues } from '../runtime'; -import { ChildWithNullable, ChildWithNullableFromJSONTyped, ChildWithNullableToJSON, ChildWithNullableToJSONTyped } from './ChildWithNullable'; +import { type ChildWithNullable, ChildWithNullableFromJSONTyped, ChildWithNullableToJSON, ChildWithNullableToJSONTyped } from './ChildWithNullable'; /** * * @export