diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java index 4b74d10686d..10cfdd80cc1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractTypeScriptClientCodegen.java @@ -629,6 +629,9 @@ public abstract class AbstractTypeScriptClientCodegen extends DefaultCodegen imp } else if (ModelUtils.isMapSchema(p)) { Schema inner = getSchemaAdditionalProperties(p); String nullSafeSuffix = getNullSafeAdditionalProps() ? " | undefined" : ""; + if (Boolean.TRUE.equals(inner.getNullable())) { + nullSafeSuffix += " | null"; + } return "{ [key: string]: " + getTypeDeclaration(unaliasSchema(inner)) + nullSafeSuffix + "; }"; } else if (ModelUtils.isFileSchema(p)) { return "File"; diff --git a/samples/client/petstore/typescript-axios/builds/test-petstore/api.ts b/samples/client/petstore/typescript-axios/builds/test-petstore/api.ts index a2119d89b14..795071edc3c 100644 --- a/samples/client/petstore/typescript-axios/builds/test-petstore/api.ts +++ b/samples/client/petstore/typescript-axios/builds/test-petstore/api.ts @@ -1107,16 +1107,16 @@ export interface NullableClass { 'object_nullable_prop'?: { [key: string]: object; } | null; /** * - * @type {{ [key: string]: object; }} + * @type {{ [key: string]: object | null; }} * @memberof NullableClass */ - 'object_and_items_nullable_prop'?: { [key: string]: object; } | null; + 'object_and_items_nullable_prop'?: { [key: string]: object | null; } | null; /** * - * @type {{ [key: string]: object; }} + * @type {{ [key: string]: object | null; }} * @memberof NullableClass */ - 'object_items_nullable'?: { [key: string]: object; }; + 'object_items_nullable'?: { [key: string]: object | null; }; } /** * @type NullableShape diff --git a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/api.ts b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/api.ts index 2c8551e9254..cbfc7da19ad 100644 --- a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/api.ts +++ b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/api.ts @@ -875,16 +875,16 @@ export interface NullableClass { 'object_nullable_prop'?: { [key: string]: object; } | null; /** * - * @type {{ [key: string]: object; }} + * @type {{ [key: string]: object | null; }} * @memberof NullableClass */ - 'object_and_items_nullable_prop'?: { [key: string]: object; } | null; + 'object_and_items_nullable_prop'?: { [key: string]: object | null; } | null; /** * - * @type {{ [key: string]: object; }} + * @type {{ [key: string]: object | null; }} * @memberof NullableClass */ - 'object_items_nullable'?: { [key: string]: object; }; + 'object_items_nullable'?: { [key: string]: object | null; }; } /** * diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/NullableClass.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/NullableClass.ts index 94b8e43e6f5..52e1a217164 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/NullableClass.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/models/NullableClass.ts @@ -82,16 +82,16 @@ export interface NullableClass { objectNullableProp?: { [key: string]: object; } | null; /** * - * @type {{ [key: string]: object; }} + * @type {{ [key: string]: object | null; }} * @memberof NullableClass */ - objectAndItemsNullableProp?: { [key: string]: object; } | null; + objectAndItemsNullableProp?: { [key: string]: object | null; } | null; /** * - * @type {{ [key: string]: object; }} + * @type {{ [key: string]: object | null; }} * @memberof NullableClass */ - objectItemsNullable?: { [key: string]: object; }; + objectItemsNullable?: { [key: string]: object | null; }; } /** diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/NullableClass.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/NullableClass.ts index 94b8e43e6f5..52e1a217164 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/NullableClass.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/NullableClass.ts @@ -82,16 +82,16 @@ export interface NullableClass { objectNullableProp?: { [key: string]: object; } | null; /** * - * @type {{ [key: string]: object; }} + * @type {{ [key: string]: object | null; }} * @memberof NullableClass */ - objectAndItemsNullableProp?: { [key: string]: object; } | null; + objectAndItemsNullableProp?: { [key: string]: object | null; } | null; /** * - * @type {{ [key: string]: object; }} + * @type {{ [key: string]: object | null; }} * @memberof NullableClass */ - objectItemsNullable?: { [key: string]: object; }; + objectItemsNullable?: { [key: string]: object | null; }; } /**