From 20d9f678cbaffe8fa394142cc1805814d2fba2d9 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Tue, 25 Jun 2024 12:36:20 +0300 Subject: [PATCH 01/15] Add oneOf model for Typescript generator --- .../main/resources/typescript/model/model.mustache | 3 +++ .../resources/typescript/model/modelOneOf.mustache | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache diff --git a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache index 798297cba063..26fefac4bdba 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache @@ -11,6 +11,8 @@ import { HttpFile } from '../http/http{{importFileExtension}}'; * {{{.}}} */ {{/description}} +{{#oneOf}}{{#-first}}{{>model/modelOneOf}}{{/-first}}{{/oneOf}} +{{^oneOf}} {{^isEnum}} export class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ {{#vars}} @@ -92,5 +94,6 @@ export enum {{classname}} { {{/allowableValues}} } {{/isEnum}} +{{/oneOf}} {{/model}} {{/models}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache b/modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache new file mode 100644 index 000000000000..16864cadb1d2 --- /dev/null +++ b/modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache @@ -0,0 +1,14 @@ +{{#hasImports}} +import { + {{#imports}} + {{{.}}}{{importFileExtension}}, + {{/imports}} +} from './'; + +{{/hasImports}} +/** + * @type {{classname}}{{#description}} + * {{{.}}}{{/description}} + * @export + */ +export type {{classname}} = {{#oneOf}}{{{.}}}{{^-last}} | {{/-last}}{{/oneOf}}; From 93a16931d7097737cfd7857016a2fdc18adc4870 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Thu, 27 Jun 2024 11:57:25 +0300 Subject: [PATCH 02/15] Update import procces: For oneOfs only import $refs within the oneOf --- .../codegen/languages/TypeScriptClientCodegen.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java index 7b1e9804e1de..c1fb9468a3f6 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptClientCodegen.java @@ -354,6 +354,16 @@ public ModelsMap postProcessModels(ModelsMap objs) { } } } + if (!cm.oneOf.isEmpty()) { + // For oneOfs only import $refs within the oneOf + TreeSet oneOfRefs = new TreeSet<>(); + for (String im : cm.imports) { + if (cm.oneOf.contains(im)) { + oneOfRefs.add(im); + } + } + cm.imports = oneOfRefs; + } } for (ModelMap mo : models) { CodegenModel cm = mo.getModel(); From c36d1b36da40c646116b396fe5034cc291702100 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Thu, 27 Jun 2024 15:15:34 +0300 Subject: [PATCH 03/15] Remove new line after description --- .../src/main/resources/typescript/model/model.mustache | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache index 26fefac4bdba..04b1bbb0cab0 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache @@ -11,10 +11,8 @@ import { HttpFile } from '../http/http{{importFileExtension}}'; * {{{.}}} */ {{/description}} -{{#oneOf}}{{#-first}}{{>model/modelOneOf}}{{/-first}}{{/oneOf}} -{{^oneOf}} {{^isEnum}} -export class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ +{{#oneOf}}{{#-first}}{{>model/modelOneOf}}{{/-first}}{{/oneOf}}{{^oneOf}}export class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ {{#vars}} {{#description}} /** @@ -68,7 +66,7 @@ export class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ {{/discriminatorName}} } } - +{{/oneOf}} {{#hasEnums}} {{#vars}} @@ -94,6 +92,5 @@ export enum {{classname}} { {{/allowableValues}} } {{/isEnum}} -{{/oneOf}} {{/model}} {{/models}} \ No newline at end of file From 8473d47982073e99f74c556ac229465c827b7a6a Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Thu, 27 Jun 2024 15:54:14 +0300 Subject: [PATCH 04/15] Update samples --- .../with-unique-items/models/Response.ts | 1 - .../builds/browser/models/ApiResponse.ts | 1 - .../builds/browser/models/Category.ts | 1 - .../typescript/builds/browser/models/Order.ts | 1 - .../typescript/builds/browser/models/Pet.ts | 1 - .../typescript/builds/browser/models/Tag.ts | 1 - .../typescript/builds/browser/models/User.ts | 1 - .../builds/composed-schemas/models/Cat.ts | 1 - .../builds/composed-schemas/models/Dog.ts | 1 - .../models/FilePostRequest.ts | 1 - .../composed-schemas/models/PetByAge.ts | 1 - .../composed-schemas/models/PetByType.ts | 1 - .../models/PetsFilteredPatchRequest.ts | 1 - .../models/PetsPatchRequest.ts | 48 ++----------------- .../builds/default/models/ApiResponse.ts | 1 - .../builds/default/models/Category.ts | 1 - .../typescript/builds/default/models/Order.ts | 1 - .../typescript/builds/default/models/Pet.ts | 1 - .../typescript/builds/default/models/Tag.ts | 1 - .../typescript/builds/default/models/User.ts | 1 - .../builds/deno/models/ApiResponse.ts | 1 - .../typescript/builds/deno/models/Category.ts | 1 - .../typescript/builds/deno/models/Order.ts | 1 - .../typescript/builds/deno/models/Pet.ts | 1 - .../typescript/builds/deno/models/Tag.ts | 1 - .../typescript/builds/deno/models/User.ts | 1 - .../builds/inversify/models/ApiResponse.ts | 1 - .../builds/inversify/models/Category.ts | 1 - .../builds/inversify/models/Order.ts | 1 - .../typescript/builds/inversify/models/Pet.ts | 1 - .../typescript/builds/inversify/models/Tag.ts | 1 - .../builds/inversify/models/User.ts | 1 - .../builds/jquery/models/ApiResponse.ts | 1 - .../builds/jquery/models/Category.ts | 1 - .../typescript/builds/jquery/models/Order.ts | 1 - .../typescript/builds/jquery/models/Pet.ts | 1 - .../typescript/builds/jquery/models/Tag.ts | 1 - .../typescript/builds/jquery/models/User.ts | 1 - .../object_params/models/ApiResponse.ts | 1 - .../builds/object_params/models/Category.ts | 1 - .../builds/object_params/models/Order.ts | 1 - .../builds/object_params/models/Pet.ts | 1 - .../builds/object_params/models/Tag.ts | 1 - .../builds/object_params/models/User.ts | 1 - 44 files changed, 5 insertions(+), 86 deletions(-) diff --git a/samples/client/others/typescript/builds/with-unique-items/models/Response.ts b/samples/client/others/typescript/builds/with-unique-items/models/Response.ts index 6a53fbd9f9d0..635fd38941db 100644 --- a/samples/client/others/typescript/builds/with-unique-items/models/Response.ts +++ b/samples/client/others/typescript/builds/with-unique-items/models/Response.ts @@ -39,4 +39,3 @@ export class Response { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/ApiResponse.ts index f4b2d010fb71..a4e90552df29 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/ApiResponse.ts @@ -49,4 +49,3 @@ export class ApiResponse { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/Category.ts index 5d63fc87a998..688258faa32f 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/Category.ts @@ -42,4 +42,3 @@ export class Category { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/Order.ts index 4d80550bb2af..ba3136527368 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/Order.ts @@ -74,7 +74,6 @@ export class Order { } } - export enum OrderStatusEnum { Placed = 'placed', Approved = 'approved', diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/Pet.ts index ecaefffea4ff..9ad87fbd3ea2 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/Pet.ts @@ -76,7 +76,6 @@ export class Pet { } } - export enum PetStatusEnum { Available = 'available', Pending = 'pending', diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/Tag.ts index 8c4f6967b9a1..7d20d20f876b 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/Tag.ts @@ -42,4 +42,3 @@ export class Tag { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/User.ts index 68528ad3c9e0..a91ce00961d5 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/User.ts @@ -87,4 +87,3 @@ export class User { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Cat.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Cat.ts index 2790b653b556..b044880be045 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Cat.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Cat.ts @@ -39,4 +39,3 @@ export class Cat { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Dog.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Dog.ts index 4d83c9db7549..562c90a0a16e 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Dog.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Dog.ts @@ -40,7 +40,6 @@ export class Dog { } } - export enum DogBreedEnum { Dingo = 'Dingo', Husky = 'Husky', diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/FilePostRequest.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/FilePostRequest.ts index ddd7a052d56a..371d069b36d4 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/FilePostRequest.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/FilePostRequest.ts @@ -32,4 +32,3 @@ export class FilePostRequest { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByAge.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByAge.ts index 6c7e3c20f0f4..bede17f68ce1 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByAge.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByAge.ts @@ -39,4 +39,3 @@ export class PetByAge { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByType.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByType.ts index 4306e8ead938..da5364d8fd67 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByType.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByType.ts @@ -40,7 +40,6 @@ export class PetByType { } } - export enum PetByTypePetTypeEnum { Cat = 'Cat', Dog = 'Dog' diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsFilteredPatchRequest.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsFilteredPatchRequest.ts index 4eaec36a60c6..79e8c3ce41a3 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsFilteredPatchRequest.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsFilteredPatchRequest.ts @@ -56,7 +56,6 @@ export class PetsFilteredPatchRequest { } } - export enum PetsFilteredPatchRequestPetTypeEnum { Cat = 'Cat', Dog = 'Dog' diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts index 7c1009e3d515..3a125d4c1196 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts @@ -14,49 +14,11 @@ import { Cat } from '../models/Cat'; import { Dog } from '../models/Dog'; import { HttpFile } from '../http/http'; -export class PetsPatchRequest { - 'hunts'?: boolean; - 'age'?: number; - 'bark'?: boolean; - 'breed'?: PetsPatchRequestBreedEnum; - - static readonly discriminator: string | undefined = "petType"; - - static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ - { - "name": "hunts", - "baseName": "hunts", - "type": "boolean", - "format": "" - }, - { - "name": "age", - "baseName": "age", - "type": "number", - "format": "" - }, - { - "name": "bark", - "baseName": "bark", - "type": "boolean", - "format": "" - }, - { - "name": "breed", - "baseName": "breed", - "type": "PetsPatchRequestBreedEnum", - "format": "" - } ]; - - static getAttributeTypeMap() { - return PetsPatchRequest.attributeTypeMap; - } - - public constructor() { - this.petType = "PetsPatchRequest"; - } -} - +/** + * @type PetsPatchRequest + * @export + */ +export type PetsPatchRequest = Cat | Dog; export enum PetsPatchRequestBreedEnum { Dingo = 'Dingo', diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/ApiResponse.ts index f4b2d010fb71..a4e90552df29 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/ApiResponse.ts @@ -49,4 +49,3 @@ export class ApiResponse { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/Category.ts index 5d63fc87a998..688258faa32f 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/Category.ts @@ -42,4 +42,3 @@ export class Category { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/Order.ts index 4d80550bb2af..ba3136527368 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/Order.ts @@ -74,7 +74,6 @@ export class Order { } } - export enum OrderStatusEnum { Placed = 'placed', Approved = 'approved', diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/Pet.ts index ecaefffea4ff..9ad87fbd3ea2 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/Pet.ts @@ -76,7 +76,6 @@ export class Pet { } } - export enum PetStatusEnum { Available = 'available', Pending = 'pending', diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/Tag.ts index 8c4f6967b9a1..7d20d20f876b 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/Tag.ts @@ -42,4 +42,3 @@ export class Tag { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/User.ts index 68528ad3c9e0..a91ce00961d5 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/User.ts @@ -87,4 +87,3 @@ export class User { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/ApiResponse.ts index b5cfa4948a07..c90dab7b3e1a 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/ApiResponse.ts @@ -49,4 +49,3 @@ export class ApiResponse { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/Category.ts index 9c1bdd236145..e6bdeaba9443 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/Category.ts @@ -42,4 +42,3 @@ export class Category { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/Order.ts index 63e6b8fe3f12..690f12cc5574 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/Order.ts @@ -74,7 +74,6 @@ export class Order { } } - export enum OrderStatusEnum { Placed = 'placed', Approved = 'approved', diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/Pet.ts index 1404661b6de0..afb6c6d4324f 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/Pet.ts @@ -76,7 +76,6 @@ export class Pet { } } - export enum PetStatusEnum { Available = 'available', Pending = 'pending', diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/Tag.ts index dc2c98212c34..34c51f57a7a5 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/Tag.ts @@ -42,4 +42,3 @@ export class Tag { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/User.ts index 76c6a9ae8692..7335131173ff 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/User.ts @@ -87,4 +87,3 @@ export class User { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ApiResponse.ts index f4b2d010fb71..a4e90552df29 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ApiResponse.ts @@ -49,4 +49,3 @@ export class ApiResponse { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Category.ts index 5d63fc87a998..688258faa32f 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Category.ts @@ -42,4 +42,3 @@ export class Category { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Order.ts index 4d80550bb2af..ba3136527368 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Order.ts @@ -74,7 +74,6 @@ export class Order { } } - export enum OrderStatusEnum { Placed = 'placed', Approved = 'approved', diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Pet.ts index ecaefffea4ff..9ad87fbd3ea2 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Pet.ts @@ -76,7 +76,6 @@ export class Pet { } } - export enum PetStatusEnum { Available = 'available', Pending = 'pending', diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Tag.ts index 8c4f6967b9a1..7d20d20f876b 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Tag.ts @@ -42,4 +42,3 @@ export class Tag { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/User.ts index 68528ad3c9e0..a91ce00961d5 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/User.ts @@ -87,4 +87,3 @@ export class User { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ApiResponse.ts index f4b2d010fb71..a4e90552df29 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ApiResponse.ts @@ -49,4 +49,3 @@ export class ApiResponse { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Category.ts index 5d63fc87a998..688258faa32f 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Category.ts @@ -42,4 +42,3 @@ export class Category { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Order.ts index 4d80550bb2af..ba3136527368 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Order.ts @@ -74,7 +74,6 @@ export class Order { } } - export enum OrderStatusEnum { Placed = 'placed', Approved = 'approved', diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Pet.ts index ecaefffea4ff..9ad87fbd3ea2 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Pet.ts @@ -76,7 +76,6 @@ export class Pet { } } - export enum PetStatusEnum { Available = 'available', Pending = 'pending', diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Tag.ts index 8c4f6967b9a1..7d20d20f876b 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Tag.ts @@ -42,4 +42,3 @@ export class Tag { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/User.ts index 68528ad3c9e0..a91ce00961d5 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/User.ts @@ -87,4 +87,3 @@ export class User { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ApiResponse.ts index f4b2d010fb71..a4e90552df29 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ApiResponse.ts @@ -49,4 +49,3 @@ export class ApiResponse { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Category.ts index 5d63fc87a998..688258faa32f 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Category.ts @@ -42,4 +42,3 @@ export class Category { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts index 4d80550bb2af..ba3136527368 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts @@ -74,7 +74,6 @@ export class Order { } } - export enum OrderStatusEnum { Placed = 'placed', Approved = 'approved', diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts index ecaefffea4ff..9ad87fbd3ea2 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts @@ -76,7 +76,6 @@ export class Pet { } } - export enum PetStatusEnum { Available = 'available', Pending = 'pending', diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Tag.ts index 8c4f6967b9a1..7d20d20f876b 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Tag.ts @@ -42,4 +42,3 @@ export class Tag { public constructor() { } } - diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/User.ts index 68528ad3c9e0..a91ce00961d5 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/User.ts @@ -87,4 +87,3 @@ export class User { public constructor() { } } - From 8330958bece21a0cbdb1c9d0a08bca2733518ba2 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Wed, 10 Jul 2024 14:07:06 +0300 Subject: [PATCH 05/15] Typescript: Update model.mustache --- .../src/main/resources/typescript/model/model.mustache | 6 +++++- .../builds/composed-schemas/models/PetsPatchRequest.ts | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache index 04b1bbb0cab0..a84a31ef5173 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache @@ -12,7 +12,11 @@ import { HttpFile } from '../http/http{{importFileExtension}}'; */ {{/description}} {{^isEnum}} -{{#oneOf}}{{#-first}}{{>model/modelOneOf}}{{/-first}}{{/oneOf}}{{^oneOf}}export class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ +{{#oneOf}} +{{#-first}}{{>model/modelOneOf}}{{/-first}} +{{/oneOf}} +{{^oneOf}} +export class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ {{#vars}} {{#description}} /** diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts index 3a125d4c1196..5d75a7737f77 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts @@ -20,6 +20,8 @@ import { HttpFile } from '../http/http'; */ export type PetsPatchRequest = Cat | Dog; + + export enum PetsPatchRequestBreedEnum { Dingo = 'Dingo', Husky = 'Husky', From b3c8ad796c3fe075131451518bb7cf297cbe25a6 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Tue, 16 Jul 2024 12:06:45 +0300 Subject: [PATCH 06/15] Typescript: Remove emun from oneOf models --- .../src/main/resources/typescript/model/model.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache index a84a31ef5173..d97480ba3205 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache @@ -70,7 +70,6 @@ export class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ {{/discriminatorName}} } } -{{/oneOf}} {{#hasEnums}} {{#vars}} @@ -86,6 +85,7 @@ export enum {{classname}}{{enumName}} { {{/vars}} {{/hasEnums}} +{{/oneOf}} {{/isEnum}} {{#isEnum}} export enum {{classname}} { From 86730d65e20569a5a3e5be1265bfbb4a3cfbb995 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Tue, 16 Jul 2024 12:08:29 +0300 Subject: [PATCH 07/15] Update samples --- .../builds/composed-schemas/models/PetsPatchRequest.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts index 5d75a7737f77..8b7bd80b282c 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts @@ -21,11 +21,3 @@ import { HttpFile } from '../http/http'; export type PetsPatchRequest = Cat | Dog; - -export enum PetsPatchRequestBreedEnum { - Dingo = 'Dingo', - Husky = 'Husky', - Retriever = 'Retriever', - Shepherd = 'Shepherd' -} - From 5e054ae1de980dd95022bbecb17f6f6978a77cbf Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Wed, 24 Jul 2024 10:05:39 +0300 Subject: [PATCH 08/15] Typescript oneOf: add discriminator and update deserialize procces --- .../typescript/model/ObjectSerializer.mustache | 5 +++-- .../typescript/model/modelOneOf.mustache | 18 ++++++++++++++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache index d84cdec5ff86..34774a9e5df8 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache @@ -6,7 +6,7 @@ export * from '{{{ importPath }}}{{importFileExtension}}'; {{#models}} {{#model}} -import { {{classname}}{{#hasEnums}}{{#vars}}{{#isEnum}}, {{classname}}{{enumName}} {{/isEnum}} {{/vars}}{{/hasEnums}} } from '{{{ importPath }}}{{importFileExtension}}'; +import { {{classname}}{{#oneOf}}{{#-first}}Class{{/-first}}{{/oneOf}}{{^oneOf}}{{#hasEnums}}{{#vars}}{{#isEnum}}, {{classname}}{{enumName}} {{/isEnum}} {{/vars}}{{/hasEnums}}{{/oneOf}} } from '{{{ importPath }}}{{importFileExtension}}'; {{/model}} {{/models}} @@ -43,7 +43,8 @@ let typeMap: {[index: string]: any} = { {{#models}} {{#model}} {{^isEnum}} - "{{classname}}": {{classname}}, + "{{classname}}": {{classname}}{{#oneOf}}{{#-first}}Class{{/-first}}{{/oneOf}},{{#hasDiscriminatorWithNonEmptyMapping}}{{#discriminator.mappedModels}} + "{{mappingName}}": {{modelName}},{{/discriminator.mappedModels}}{{/hasDiscriminatorWithNonEmptyMapping}} {{/isEnum}} {{/model}} {{/models}} diff --git a/modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache b/modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache index 16864cadb1d2..0854474290db 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache @@ -7,8 +7,22 @@ import { {{/hasImports}} /** - * @type {{classname}}{{#description}} - * {{{.}}}{{/description}} + * @type {{classname}} + * Type * @export */ export type {{classname}} = {{#oneOf}}{{{.}}}{{^-last}} | {{/-last}}{{/oneOf}}; + +/** +* @type {{classname}}Class{{#description}} + * {{{.}}}{{/description}} +* @export +*/ +export class {{classname}}Class { + {{#discriminator}} + static readonly discriminator: string | undefined = "{{discriminatorName}}"; + {{/discriminator}} + {{^discriminator}} + static readonly discriminator: string | undefined = undefined; + {{/discriminator}} +} \ No newline at end of file From 04f0c94f4ee8c795bb5f4598d9312f0111a77229 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Wed, 24 Jul 2024 10:08:38 +0300 Subject: [PATCH 09/15] Typescript: update tests --- .../builds/composed-schemas/models/ObjectSerializer.ts | 4 ++-- .../builds/composed-schemas/models/PetsPatchRequest.ts | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts index c98b183b5b66..176b32ee1623 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts @@ -12,7 +12,7 @@ import { FilePostRequest } from '../models/FilePostRequest'; import { PetByAge } from '../models/PetByAge'; import { PetByType, PetByTypePetTypeEnum } from '../models/PetByType'; import { PetsFilteredPatchRequest , PetsFilteredPatchRequestPetTypeEnum } from '../models/PetsFilteredPatchRequest'; -import { PetsPatchRequest , PetsPatchRequestBreedEnum } from '../models/PetsPatchRequest'; +import { PetsPatchRequestClass } from '../models/PetsPatchRequest'; /* tslint:disable:no-unused-variable */ let primitives = [ @@ -40,7 +40,7 @@ let typeMap: {[index: string]: any} = { "PetByAge": PetByAge, "PetByType": PetByType, "PetsFilteredPatchRequest": PetsFilteredPatchRequest, - "PetsPatchRequest": PetsPatchRequest, + "PetsPatchRequest": PetsPatchRequestClass, } type MimeTypeDescriptor = { diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts index 8b7bd80b282c..d761ad446348 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts @@ -16,8 +16,16 @@ import { HttpFile } from '../http/http'; /** * @type PetsPatchRequest + * Type * @export */ export type PetsPatchRequest = Cat | Dog; +/** +* @type PetsPatchRequestClass +* @export +*/ +export class PetsPatchRequestClass { + static readonly discriminator: string | undefined = "petType"; +} From 38e9852ff72cb8c92781cf2a85840222bc0f7de5 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Wed, 24 Jul 2024 11:42:40 +0300 Subject: [PATCH 10/15] Typescript oneOf: move type mapping to models --- .../typescript/model/ObjectSerializer.mustache | 10 +++++----- .../resources/typescript/model/model.mustache | 12 ++++++++++++ .../typescript/model/modelOneOf.mustache | 16 ++++++++++++++-- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache index 34774a9e5df8..2b5e7c1d534d 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache @@ -43,8 +43,7 @@ let typeMap: {[index: string]: any} = { {{#models}} {{#model}} {{^isEnum}} - "{{classname}}": {{classname}}{{#oneOf}}{{#-first}}Class{{/-first}}{{/oneOf}},{{#hasDiscriminatorWithNonEmptyMapping}}{{#discriminator.mappedModels}} - "{{mappingName}}": {{modelName}},{{/discriminator.mappedModels}}{{/hasDiscriminatorWithNonEmptyMapping}} + "{{classname}}": {{classname}}{{#oneOf}}{{#-first}}Class{{/-first}}{{/oneOf}}, {{/isEnum}} {{/model}} {{/models}} @@ -121,13 +120,14 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - if (discriminatorProperty == null) { + let mapping = typeMap[expectedType].mapping; + if (discriminatorProperty == null || mapping == undefined) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(typeMap[discriminatorType]){ - return discriminatorType; // use the type given in the discriminator + if(mapping[discriminatorType]) { + return mapping[discriminatorType]; // use the type given in the discriminator } else { return expectedType; // discriminator did not map to a type } diff --git a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache index d97480ba3205..206972534f63 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache @@ -32,6 +32,18 @@ export class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ {{^discriminator}} static readonly discriminator: string | undefined = undefined; {{/discriminator}} + {{#hasDiscriminatorWithNonEmptyMapping}} + + static readonly mapping: {[index: string]: any} | undefined = { + {{#discriminator.mappedModels}} + "{{mappingName}}": "{{modelName}}", + {{/discriminator.mappedModels}} + }; + {{/hasDiscriminatorWithNonEmptyMapping}} + {{^hasDiscriminatorWithNonEmptyMapping}} + + static readonly mapping: {[index: string]: any} | undefined = undefined; + {{/hasDiscriminatorWithNonEmptyMapping}} {{^isArray}} static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ diff --git a/modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache b/modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache index 0854474290db..469a7a9e6014 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache @@ -20,9 +20,21 @@ export type {{classname}} = {{#oneOf}}{{{.}}}{{^-last}} | {{/-last}}{{/oneOf}}; */ export class {{classname}}Class { {{#discriminator}} - static readonly discriminator: string | undefined = "{{discriminatorName}}"; + static readonly discriminator: string | undefined = "{{discriminatorName}}"; {{/discriminator}} {{^discriminator}} - static readonly discriminator: string | undefined = undefined; + static readonly discriminator: string | undefined = undefined; {{/discriminator}} + {{#hasDiscriminatorWithNonEmptyMapping}} + + static readonly mapping: {[index: string]: any} | undefined = { + {{#discriminator.mappedModels}} + "{{mappingName}}": "{{modelName}}", + {{/discriminator.mappedModels}} + }; + {{/hasDiscriminatorWithNonEmptyMapping}} + {{^hasDiscriminatorWithNonEmptyMapping}} + + static readonly mapping: {[index: string]: any} | undefined = undefined; + {{/hasDiscriminatorWithNonEmptyMapping}} } \ No newline at end of file From 5f5cfbbfd857ea4be1252ca33de83eebc7f14ce8 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Wed, 24 Jul 2024 11:50:19 +0300 Subject: [PATCH 11/15] Typescript: Update samples --- .../builds/with-unique-items/models/ObjectSerializer.ts | 7 ++++--- .../typescript/builds/with-unique-items/models/Response.ts | 2 ++ .../typescript/builds/browser/models/ApiResponse.ts | 2 ++ .../petstore/typescript/builds/browser/models/Category.ts | 2 ++ .../typescript/builds/browser/models/ObjectSerializer.ts | 7 ++++--- .../petstore/typescript/builds/browser/models/Order.ts | 2 ++ .../petstore/typescript/builds/browser/models/Pet.ts | 2 ++ .../petstore/typescript/builds/browser/models/Tag.ts | 2 ++ .../petstore/typescript/builds/browser/models/User.ts | 2 ++ .../typescript/builds/composed-schemas/models/Cat.ts | 2 ++ .../typescript/builds/composed-schemas/models/Dog.ts | 2 ++ .../builds/composed-schemas/models/FilePostRequest.ts | 2 ++ .../builds/composed-schemas/models/ObjectSerializer.ts | 7 ++++--- .../typescript/builds/composed-schemas/models/PetByAge.ts | 2 ++ .../typescript/builds/composed-schemas/models/PetByType.ts | 2 ++ .../composed-schemas/models/PetsFilteredPatchRequest.ts | 2 ++ .../builds/composed-schemas/models/PetsPatchRequest.ts | 4 +++- .../typescript/builds/default/models/ApiResponse.ts | 2 ++ .../petstore/typescript/builds/default/models/Category.ts | 2 ++ .../typescript/builds/default/models/ObjectSerializer.ts | 7 ++++--- .../petstore/typescript/builds/default/models/Order.ts | 2 ++ .../petstore/typescript/builds/default/models/Pet.ts | 2 ++ .../petstore/typescript/builds/default/models/Tag.ts | 2 ++ .../petstore/typescript/builds/default/models/User.ts | 2 ++ .../petstore/typescript/builds/deno/models/ApiResponse.ts | 2 ++ .../petstore/typescript/builds/deno/models/Category.ts | 2 ++ .../typescript/builds/deno/models/ObjectSerializer.ts | 7 ++++--- .../client/petstore/typescript/builds/deno/models/Order.ts | 2 ++ .../client/petstore/typescript/builds/deno/models/Pet.ts | 2 ++ .../client/petstore/typescript/builds/deno/models/Tag.ts | 2 ++ .../client/petstore/typescript/builds/deno/models/User.ts | 2 ++ .../typescript/builds/inversify/models/ApiResponse.ts | 2 ++ .../typescript/builds/inversify/models/Category.ts | 2 ++ .../typescript/builds/inversify/models/ObjectSerializer.ts | 7 ++++--- .../petstore/typescript/builds/inversify/models/Order.ts | 2 ++ .../petstore/typescript/builds/inversify/models/Pet.ts | 2 ++ .../petstore/typescript/builds/inversify/models/Tag.ts | 2 ++ .../petstore/typescript/builds/inversify/models/User.ts | 2 ++ .../typescript/builds/jquery/models/ApiResponse.ts | 2 ++ .../petstore/typescript/builds/jquery/models/Category.ts | 2 ++ .../typescript/builds/jquery/models/ObjectSerializer.ts | 7 ++++--- .../petstore/typescript/builds/jquery/models/Order.ts | 2 ++ .../client/petstore/typescript/builds/jquery/models/Pet.ts | 2 ++ .../client/petstore/typescript/builds/jquery/models/Tag.ts | 2 ++ .../petstore/typescript/builds/jquery/models/User.ts | 2 ++ .../typescript/builds/object_params/models/ApiResponse.ts | 2 ++ .../typescript/builds/object_params/models/Category.ts | 2 ++ .../builds/object_params/models/ObjectSerializer.ts | 7 ++++--- .../typescript/builds/object_params/models/Order.ts | 2 ++ .../petstore/typescript/builds/object_params/models/Pet.ts | 2 ++ .../petstore/typescript/builds/object_params/models/Tag.ts | 2 ++ .../typescript/builds/object_params/models/User.ts | 2 ++ 52 files changed, 121 insertions(+), 25 deletions(-) diff --git a/samples/client/others/typescript/builds/with-unique-items/models/ObjectSerializer.ts b/samples/client/others/typescript/builds/with-unique-items/models/ObjectSerializer.ts index d994fd35e982..c6752af9cf85 100644 --- a/samples/client/others/typescript/builds/with-unique-items/models/ObjectSerializer.ts +++ b/samples/client/others/typescript/builds/with-unique-items/models/ObjectSerializer.ts @@ -92,13 +92,14 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - if (discriminatorProperty == null) { + let mapping = typeMap[expectedType].mapping; + if (discriminatorProperty == null || mapping == undefined) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(typeMap[discriminatorType]){ - return discriminatorType; // use the type given in the discriminator + if(mapping[discriminatorType]) { + return mapping[discriminatorType]; // use the type given in the discriminator } else { return expectedType; // discriminator did not map to a type } diff --git a/samples/client/others/typescript/builds/with-unique-items/models/Response.ts b/samples/client/others/typescript/builds/with-unique-items/models/Response.ts index 635fd38941db..18b0b22addc1 100644 --- a/samples/client/others/typescript/builds/with-unique-items/models/Response.ts +++ b/samples/client/others/typescript/builds/with-unique-items/models/Response.ts @@ -18,6 +18,8 @@ export class Response { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "nonUniqueArray", diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/ApiResponse.ts index a4e90552df29..f982197a85c9 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/ApiResponse.ts @@ -22,6 +22,8 @@ export class ApiResponse { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "code", diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/Category.ts index 688258faa32f..43871eb1e2be 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/Category.ts @@ -21,6 +21,8 @@ export class Category { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/ObjectSerializer.ts index 97a82f53c206..8c5348569f9c 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/ObjectSerializer.ts @@ -109,13 +109,14 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - if (discriminatorProperty == null) { + let mapping = typeMap[expectedType].mapping; + if (discriminatorProperty == null || mapping == undefined) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(typeMap[discriminatorType]){ - return discriminatorType; // use the type given in the discriminator + if(mapping[discriminatorType]) { + return mapping[discriminatorType]; // use the type given in the discriminator } else { return expectedType; // discriminator did not map to a type } diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/Order.ts index ba3136527368..316cb32a51ce 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/Order.ts @@ -28,6 +28,8 @@ export class Order { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/Pet.ts index 9ad87fbd3ea2..cb554448b2d5 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/Pet.ts @@ -30,6 +30,8 @@ export class Pet { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/Tag.ts index 7d20d20f876b..8dd1a2dc47c9 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/Tag.ts @@ -21,6 +21,8 @@ export class Tag { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/User.ts index a91ce00961d5..539cef643b79 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/User.ts @@ -30,6 +30,8 @@ export class User { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Cat.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Cat.ts index b044880be045..14b305057953 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Cat.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Cat.ts @@ -18,6 +18,8 @@ export class Cat { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "hunts", diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Dog.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Dog.ts index 562c90a0a16e..6a9d93d9d107 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Dog.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Dog.ts @@ -18,6 +18,8 @@ export class Dog { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "bark", diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/FilePostRequest.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/FilePostRequest.ts index 371d069b36d4..c28b89f3227a 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/FilePostRequest.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/FilePostRequest.ts @@ -17,6 +17,8 @@ export class FilePostRequest { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "file", diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts index 176b32ee1623..6e8ada4ecc89 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts @@ -114,13 +114,14 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - if (discriminatorProperty == null) { + let mapping = typeMap[expectedType].mapping; + if (discriminatorProperty == null || mapping == undefined) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(typeMap[discriminatorType]){ - return discriminatorType; // use the type given in the discriminator + if(mapping[discriminatorType]) { + return mapping[discriminatorType]; // use the type given in the discriminator } else { return expectedType; // discriminator did not map to a type } diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByAge.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByAge.ts index bede17f68ce1..04bdd44458ff 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByAge.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByAge.ts @@ -18,6 +18,8 @@ export class PetByAge { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "age", diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByType.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByType.ts index da5364d8fd67..5e3488153200 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByType.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByType.ts @@ -18,6 +18,8 @@ export class PetByType { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "petType", diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsFilteredPatchRequest.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsFilteredPatchRequest.ts index 79e8c3ce41a3..365259910b8f 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsFilteredPatchRequest.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsFilteredPatchRequest.ts @@ -22,6 +22,8 @@ export class PetsFilteredPatchRequest { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "age", diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts index d761ad446348..752f0d5f6f13 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts @@ -26,6 +26,8 @@ export type PetsPatchRequest = Cat | Dog; * @export */ export class PetsPatchRequestClass { - static readonly discriminator: string | undefined = "petType"; + static readonly discriminator: string | undefined = "petType"; + + static readonly mapping: {[index: string]: any} | undefined = undefined; } diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/ApiResponse.ts index a4e90552df29..f982197a85c9 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/ApiResponse.ts @@ -22,6 +22,8 @@ export class ApiResponse { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "code", diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/Category.ts index 688258faa32f..43871eb1e2be 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/Category.ts @@ -21,6 +21,8 @@ export class Category { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts index 97a82f53c206..8c5348569f9c 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts @@ -109,13 +109,14 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - if (discriminatorProperty == null) { + let mapping = typeMap[expectedType].mapping; + if (discriminatorProperty == null || mapping == undefined) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(typeMap[discriminatorType]){ - return discriminatorType; // use the type given in the discriminator + if(mapping[discriminatorType]) { + return mapping[discriminatorType]; // use the type given in the discriminator } else { return expectedType; // discriminator did not map to a type } diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/Order.ts index ba3136527368..316cb32a51ce 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/Order.ts @@ -28,6 +28,8 @@ export class Order { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/Pet.ts index 9ad87fbd3ea2..cb554448b2d5 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/Pet.ts @@ -30,6 +30,8 @@ export class Pet { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/Tag.ts index 7d20d20f876b..8dd1a2dc47c9 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/Tag.ts @@ -21,6 +21,8 @@ export class Tag { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/User.ts index a91ce00961d5..539cef643b79 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/User.ts @@ -30,6 +30,8 @@ export class User { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/ApiResponse.ts index c90dab7b3e1a..c215c1256fec 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/ApiResponse.ts @@ -22,6 +22,8 @@ export class ApiResponse { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "code", diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/Category.ts index e6bdeaba9443..05b7388208c7 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/Category.ts @@ -21,6 +21,8 @@ export class Category { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/ObjectSerializer.ts index bea859c615bc..c995c1c9e031 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/ObjectSerializer.ts @@ -109,13 +109,14 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - if (discriminatorProperty == null) { + let mapping = typeMap[expectedType].mapping; + if (discriminatorProperty == null || mapping == undefined) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(typeMap[discriminatorType]){ - return discriminatorType; // use the type given in the discriminator + if(mapping[discriminatorType]) { + return mapping[discriminatorType]; // use the type given in the discriminator } else { return expectedType; // discriminator did not map to a type } diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/Order.ts index 690f12cc5574..3adbb099d11e 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/Order.ts @@ -28,6 +28,8 @@ export class Order { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/Pet.ts index afb6c6d4324f..4403f284466d 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/Pet.ts @@ -30,6 +30,8 @@ export class Pet { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/Tag.ts index 34c51f57a7a5..22b45dc6e34b 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/Tag.ts @@ -21,6 +21,8 @@ export class Tag { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/User.ts index 7335131173ff..ade5f2024abe 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/User.ts @@ -30,6 +30,8 @@ export class User { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ApiResponse.ts index a4e90552df29..f982197a85c9 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ApiResponse.ts @@ -22,6 +22,8 @@ export class ApiResponse { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "code", diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Category.ts index 688258faa32f..43871eb1e2be 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Category.ts @@ -21,6 +21,8 @@ export class Category { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts index 97a82f53c206..8c5348569f9c 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts @@ -109,13 +109,14 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - if (discriminatorProperty == null) { + let mapping = typeMap[expectedType].mapping; + if (discriminatorProperty == null || mapping == undefined) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(typeMap[discriminatorType]){ - return discriminatorType; // use the type given in the discriminator + if(mapping[discriminatorType]) { + return mapping[discriminatorType]; // use the type given in the discriminator } else { return expectedType; // discriminator did not map to a type } diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Order.ts index ba3136527368..316cb32a51ce 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Order.ts @@ -28,6 +28,8 @@ export class Order { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Pet.ts index 9ad87fbd3ea2..cb554448b2d5 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Pet.ts @@ -30,6 +30,8 @@ export class Pet { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Tag.ts index 7d20d20f876b..8dd1a2dc47c9 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Tag.ts @@ -21,6 +21,8 @@ export class Tag { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/User.ts index a91ce00961d5..539cef643b79 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/User.ts @@ -30,6 +30,8 @@ export class User { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ApiResponse.ts index a4e90552df29..f982197a85c9 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ApiResponse.ts @@ -22,6 +22,8 @@ export class ApiResponse { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "code", diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Category.ts index 688258faa32f..43871eb1e2be 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Category.ts @@ -21,6 +21,8 @@ export class Category { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts index 97a82f53c206..8c5348569f9c 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts @@ -109,13 +109,14 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - if (discriminatorProperty == null) { + let mapping = typeMap[expectedType].mapping; + if (discriminatorProperty == null || mapping == undefined) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(typeMap[discriminatorType]){ - return discriminatorType; // use the type given in the discriminator + if(mapping[discriminatorType]) { + return mapping[discriminatorType]; // use the type given in the discriminator } else { return expectedType; // discriminator did not map to a type } diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Order.ts index ba3136527368..316cb32a51ce 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Order.ts @@ -28,6 +28,8 @@ export class Order { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Pet.ts index 9ad87fbd3ea2..cb554448b2d5 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Pet.ts @@ -30,6 +30,8 @@ export class Pet { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Tag.ts index 7d20d20f876b..8dd1a2dc47c9 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Tag.ts @@ -21,6 +21,8 @@ export class Tag { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/User.ts index a91ce00961d5..539cef643b79 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/User.ts @@ -30,6 +30,8 @@ export class User { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ApiResponse.ts index a4e90552df29..f982197a85c9 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ApiResponse.ts @@ -22,6 +22,8 @@ export class ApiResponse { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "code", diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Category.ts index 688258faa32f..43871eb1e2be 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Category.ts @@ -21,6 +21,8 @@ export class Category { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts index 97a82f53c206..8c5348569f9c 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts @@ -109,13 +109,14 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - if (discriminatorProperty == null) { + let mapping = typeMap[expectedType].mapping; + if (discriminatorProperty == null || mapping == undefined) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(typeMap[discriminatorType]){ - return discriminatorType; // use the type given in the discriminator + if(mapping[discriminatorType]) { + return mapping[discriminatorType]; // use the type given in the discriminator } else { return expectedType; // discriminator did not map to a type } diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts index ba3136527368..316cb32a51ce 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts @@ -28,6 +28,8 @@ export class Order { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts index 9ad87fbd3ea2..cb554448b2d5 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts @@ -30,6 +30,8 @@ export class Pet { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Tag.ts index 7d20d20f876b..8dd1a2dc47c9 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Tag.ts @@ -21,6 +21,8 @@ export class Tag { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/User.ts index a91ce00961d5..539cef643b79 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/User.ts @@ -30,6 +30,8 @@ export class User { static readonly discriminator: string | undefined = undefined; + static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { "name": "id", From a9564d8ee95eca3d46d9ec2d81c97895fde6a1a7 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Wed, 24 Jul 2024 12:04:27 +0300 Subject: [PATCH 12/15] Typescript: Update type of mappig --- .../src/main/resources/typescript/model/model.mustache | 4 ++-- .../src/main/resources/typescript/model/modelOneOf.mustache | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache index 206972534f63..4f30fea765b0 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/model.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/model.mustache @@ -34,7 +34,7 @@ export class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ {{/discriminator}} {{#hasDiscriminatorWithNonEmptyMapping}} - static readonly mapping: {[index: string]: any} | undefined = { + static readonly mapping: {[index: string]: string} | undefined = { {{#discriminator.mappedModels}} "{{mappingName}}": "{{modelName}}", {{/discriminator.mappedModels}} @@ -42,7 +42,7 @@ export class {{classname}} {{#parent}}extends {{{.}}} {{/parent}}{ {{/hasDiscriminatorWithNonEmptyMapping}} {{^hasDiscriminatorWithNonEmptyMapping}} - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; {{/hasDiscriminatorWithNonEmptyMapping}} {{^isArray}} diff --git a/modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache b/modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache index 469a7a9e6014..d5e026ac6d45 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/modelOneOf.mustache @@ -27,7 +27,7 @@ export class {{classname}}Class { {{/discriminator}} {{#hasDiscriminatorWithNonEmptyMapping}} - static readonly mapping: {[index: string]: any} | undefined = { + static readonly mapping: {[index: string]: string} | undefined = { {{#discriminator.mappedModels}} "{{mappingName}}": "{{modelName}}", {{/discriminator.mappedModels}} @@ -35,6 +35,6 @@ export class {{classname}}Class { {{/hasDiscriminatorWithNonEmptyMapping}} {{^hasDiscriminatorWithNonEmptyMapping}} - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; {{/hasDiscriminatorWithNonEmptyMapping}} } \ No newline at end of file From e17cb9161d532379ec57f4766321d2ed382499b3 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Wed, 24 Jul 2024 12:10:38 +0300 Subject: [PATCH 13/15] Typescript: Update type of mappig --- .../typescript/builds/with-unique-items/models/Response.ts | 2 +- .../petstore/typescript/builds/browser/models/ApiResponse.ts | 2 +- .../petstore/typescript/builds/browser/models/Category.ts | 2 +- .../client/petstore/typescript/builds/browser/models/Order.ts | 2 +- .../client/petstore/typescript/builds/browser/models/Pet.ts | 2 +- .../client/petstore/typescript/builds/browser/models/Tag.ts | 2 +- .../client/petstore/typescript/builds/browser/models/User.ts | 2 +- .../petstore/typescript/builds/composed-schemas/models/Cat.ts | 2 +- .../petstore/typescript/builds/composed-schemas/models/Dog.ts | 2 +- .../builds/composed-schemas/models/FilePostRequest.ts | 2 +- .../typescript/builds/composed-schemas/models/PetByAge.ts | 2 +- .../typescript/builds/composed-schemas/models/PetByType.ts | 2 +- .../builds/composed-schemas/models/PetsFilteredPatchRequest.ts | 2 +- .../builds/composed-schemas/models/PetsPatchRequest.ts | 2 +- .../petstore/typescript/builds/default/models/ApiResponse.ts | 2 +- .../petstore/typescript/builds/default/models/Category.ts | 2 +- .../client/petstore/typescript/builds/default/models/Order.ts | 2 +- .../client/petstore/typescript/builds/default/models/Pet.ts | 2 +- .../client/petstore/typescript/builds/default/models/Tag.ts | 2 +- .../client/petstore/typescript/builds/default/models/User.ts | 2 +- .../petstore/typescript/builds/deno/models/ApiResponse.ts | 2 +- .../client/petstore/typescript/builds/deno/models/Category.ts | 2 +- .../client/petstore/typescript/builds/deno/models/Order.ts | 2 +- .../client/petstore/typescript/builds/deno/models/Pet.ts | 2 +- .../client/petstore/typescript/builds/deno/models/Tag.ts | 2 +- .../client/petstore/typescript/builds/deno/models/User.ts | 2 +- .../petstore/typescript/builds/inversify/models/ApiResponse.ts | 2 +- .../petstore/typescript/builds/inversify/models/Category.ts | 2 +- .../client/petstore/typescript/builds/inversify/models/Order.ts | 2 +- .../client/petstore/typescript/builds/inversify/models/Pet.ts | 2 +- .../client/petstore/typescript/builds/inversify/models/Tag.ts | 2 +- .../client/petstore/typescript/builds/inversify/models/User.ts | 2 +- .../petstore/typescript/builds/jquery/models/ApiResponse.ts | 2 +- .../client/petstore/typescript/builds/jquery/models/Category.ts | 2 +- .../client/petstore/typescript/builds/jquery/models/Order.ts | 2 +- .../client/petstore/typescript/builds/jquery/models/Pet.ts | 2 +- .../client/petstore/typescript/builds/jquery/models/Tag.ts | 2 +- .../client/petstore/typescript/builds/jquery/models/User.ts | 2 +- .../typescript/builds/object_params/models/ApiResponse.ts | 2 +- .../petstore/typescript/builds/object_params/models/Category.ts | 2 +- .../petstore/typescript/builds/object_params/models/Order.ts | 2 +- .../petstore/typescript/builds/object_params/models/Pet.ts | 2 +- .../petstore/typescript/builds/object_params/models/Tag.ts | 2 +- .../petstore/typescript/builds/object_params/models/User.ts | 2 +- 44 files changed, 44 insertions(+), 44 deletions(-) diff --git a/samples/client/others/typescript/builds/with-unique-items/models/Response.ts b/samples/client/others/typescript/builds/with-unique-items/models/Response.ts index 18b0b22addc1..9ba6412f2445 100644 --- a/samples/client/others/typescript/builds/with-unique-items/models/Response.ts +++ b/samples/client/others/typescript/builds/with-unique-items/models/Response.ts @@ -18,7 +18,7 @@ export class Response { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/ApiResponse.ts index f982197a85c9..3dd68507b210 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/ApiResponse.ts @@ -22,7 +22,7 @@ export class ApiResponse { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/Category.ts index 43871eb1e2be..e025011174d3 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/Category.ts @@ -21,7 +21,7 @@ export class Category { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/Order.ts index 316cb32a51ce..b8d4a26c7d47 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/Order.ts @@ -28,7 +28,7 @@ export class Order { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/Pet.ts index cb554448b2d5..ddb68aa82a19 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/Pet.ts @@ -30,7 +30,7 @@ export class Pet { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/Tag.ts index 8dd1a2dc47c9..7a7a36ba59aa 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/Tag.ts @@ -21,7 +21,7 @@ export class Tag { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/User.ts index 539cef643b79..4dbe18f7fed4 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/User.ts @@ -30,7 +30,7 @@ export class User { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Cat.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Cat.ts index 14b305057953..7812787becba 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Cat.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Cat.ts @@ -18,7 +18,7 @@ export class Cat { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Dog.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Dog.ts index 6a9d93d9d107..5a3e5f0fa481 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Dog.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/Dog.ts @@ -18,7 +18,7 @@ export class Dog { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/FilePostRequest.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/FilePostRequest.ts index c28b89f3227a..5a51233579e6 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/FilePostRequest.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/FilePostRequest.ts @@ -17,7 +17,7 @@ export class FilePostRequest { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByAge.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByAge.ts index 04bdd44458ff..5ddcb270eb2a 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByAge.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByAge.ts @@ -18,7 +18,7 @@ export class PetByAge { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByType.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByType.ts index 5e3488153200..60d1fd207e2d 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByType.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetByType.ts @@ -18,7 +18,7 @@ export class PetByType { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsFilteredPatchRequest.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsFilteredPatchRequest.ts index 365259910b8f..067783a53328 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsFilteredPatchRequest.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsFilteredPatchRequest.ts @@ -22,7 +22,7 @@ export class PetsFilteredPatchRequest { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts index 752f0d5f6f13..29d1f50c615e 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/PetsPatchRequest.ts @@ -28,6 +28,6 @@ export type PetsPatchRequest = Cat | Dog; export class PetsPatchRequestClass { static readonly discriminator: string | undefined = "petType"; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; } diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/ApiResponse.ts index f982197a85c9..3dd68507b210 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/ApiResponse.ts @@ -22,7 +22,7 @@ export class ApiResponse { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/Category.ts index 43871eb1e2be..e025011174d3 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/Category.ts @@ -21,7 +21,7 @@ export class Category { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/Order.ts index 316cb32a51ce..b8d4a26c7d47 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/Order.ts @@ -28,7 +28,7 @@ export class Order { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/Pet.ts index cb554448b2d5..ddb68aa82a19 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/Pet.ts @@ -30,7 +30,7 @@ export class Pet { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/Tag.ts index 8dd1a2dc47c9..7a7a36ba59aa 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/Tag.ts @@ -21,7 +21,7 @@ export class Tag { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/User.ts index 539cef643b79..4dbe18f7fed4 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/User.ts @@ -30,7 +30,7 @@ export class User { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/ApiResponse.ts index c215c1256fec..55426844f46a 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/ApiResponse.ts @@ -22,7 +22,7 @@ export class ApiResponse { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/Category.ts index 05b7388208c7..69f46a847ef9 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/Category.ts @@ -21,7 +21,7 @@ export class Category { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/Order.ts index 3adbb099d11e..ca36df140b3c 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/Order.ts @@ -28,7 +28,7 @@ export class Order { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/Pet.ts index 4403f284466d..7cbaa216062f 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/Pet.ts @@ -30,7 +30,7 @@ export class Pet { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/Tag.ts index 22b45dc6e34b..e443aa102307 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/Tag.ts @@ -21,7 +21,7 @@ export class Tag { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/User.ts index ade5f2024abe..c728f6fd7634 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/User.ts @@ -30,7 +30,7 @@ export class User { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ApiResponse.ts index f982197a85c9..3dd68507b210 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ApiResponse.ts @@ -22,7 +22,7 @@ export class ApiResponse { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Category.ts index 43871eb1e2be..e025011174d3 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Category.ts @@ -21,7 +21,7 @@ export class Category { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Order.ts index 316cb32a51ce..b8d4a26c7d47 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Order.ts @@ -28,7 +28,7 @@ export class Order { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Pet.ts index cb554448b2d5..ddb68aa82a19 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Pet.ts @@ -30,7 +30,7 @@ export class Pet { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Tag.ts index 8dd1a2dc47c9..7a7a36ba59aa 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/Tag.ts @@ -21,7 +21,7 @@ export class Tag { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/User.ts index 539cef643b79..4dbe18f7fed4 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/User.ts @@ -30,7 +30,7 @@ export class User { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ApiResponse.ts index f982197a85c9..3dd68507b210 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ApiResponse.ts @@ -22,7 +22,7 @@ export class ApiResponse { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Category.ts index 43871eb1e2be..e025011174d3 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Category.ts @@ -21,7 +21,7 @@ export class Category { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Order.ts index 316cb32a51ce..b8d4a26c7d47 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Order.ts @@ -28,7 +28,7 @@ export class Order { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Pet.ts index cb554448b2d5..ddb68aa82a19 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Pet.ts @@ -30,7 +30,7 @@ export class Pet { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Tag.ts index 8dd1a2dc47c9..7a7a36ba59aa 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/Tag.ts @@ -21,7 +21,7 @@ export class Tag { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/User.ts index 539cef643b79..4dbe18f7fed4 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/User.ts @@ -30,7 +30,7 @@ export class User { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/ApiResponse.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ApiResponse.ts index f982197a85c9..3dd68507b210 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/ApiResponse.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ApiResponse.ts @@ -22,7 +22,7 @@ export class ApiResponse { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Category.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Category.ts index 43871eb1e2be..e025011174d3 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Category.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Category.ts @@ -21,7 +21,7 @@ export class Category { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts index 316cb32a51ce..b8d4a26c7d47 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Order.ts @@ -28,7 +28,7 @@ export class Order { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts index cb554448b2d5..ddb68aa82a19 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Pet.ts @@ -30,7 +30,7 @@ export class Pet { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Tag.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Tag.ts index 8dd1a2dc47c9..7a7a36ba59aa 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/Tag.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/Tag.ts @@ -21,7 +21,7 @@ export class Tag { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/User.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/User.ts index 539cef643b79..4dbe18f7fed4 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/User.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/User.ts @@ -30,7 +30,7 @@ export class User { static readonly discriminator: string | undefined = undefined; - static readonly mapping: {[index: string]: any} | undefined = undefined; + static readonly mapping: {[index: string]: string} | undefined = undefined; static readonly attributeTypeMap: Array<{name: string, baseName: string, type: string, format: string}> = [ { From 5e673955d044d12ed90d41a65ebcfb352b221d74 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Wed, 24 Jul 2024 14:30:21 +0300 Subject: [PATCH 14/15] Typescript oneOf: update deserializing logic --- .../resources/typescript/model/ObjectSerializer.mustache | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache index 2b5e7c1d534d..f08a7af94f38 100644 --- a/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache +++ b/modules/openapi-generator/src/main/resources/typescript/model/ObjectSerializer.mustache @@ -120,14 +120,16 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - let mapping = typeMap[expectedType].mapping; - if (discriminatorProperty == null || mapping == undefined) { + if (discriminatorProperty == null) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(mapping[discriminatorType]) { + let mapping = typeMap[expectedType].mapping; + if (mapping != undefined && mapping[discriminatorType]) { return mapping[discriminatorType]; // use the type given in the discriminator + } else if(typeMap[discriminatorType]) { + return discriminatorType; } else { return expectedType; // discriminator did not map to a type } From 885b776d112aeb22ff7cfa76604a56798f492a84 Mon Sep 17 00:00:00 2001 From: ksvirkou-hubspot Date: Wed, 24 Jul 2024 14:38:42 +0300 Subject: [PATCH 15/15] Typescript: Update samples --- .../builds/with-unique-items/models/ObjectSerializer.ts | 8 +++++--- .../typescript/builds/browser/models/ObjectSerializer.ts | 8 +++++--- .../builds/composed-schemas/models/ObjectSerializer.ts | 8 +++++--- .../typescript/builds/default/models/ObjectSerializer.ts | 8 +++++--- .../typescript/builds/deno/models/ObjectSerializer.ts | 8 +++++--- .../builds/inversify/models/ObjectSerializer.ts | 8 +++++--- .../typescript/builds/jquery/models/ObjectSerializer.ts | 8 +++++--- .../builds/object_params/models/ObjectSerializer.ts | 8 +++++--- 8 files changed, 40 insertions(+), 24 deletions(-) diff --git a/samples/client/others/typescript/builds/with-unique-items/models/ObjectSerializer.ts b/samples/client/others/typescript/builds/with-unique-items/models/ObjectSerializer.ts index c6752af9cf85..8a1b41ec04c3 100644 --- a/samples/client/others/typescript/builds/with-unique-items/models/ObjectSerializer.ts +++ b/samples/client/others/typescript/builds/with-unique-items/models/ObjectSerializer.ts @@ -92,14 +92,16 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - let mapping = typeMap[expectedType].mapping; - if (discriminatorProperty == null || mapping == undefined) { + if (discriminatorProperty == null) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(mapping[discriminatorType]) { + let mapping = typeMap[expectedType].mapping; + if (mapping != undefined && mapping[discriminatorType]) { return mapping[discriminatorType]; // use the type given in the discriminator + } else if(typeMap[discriminatorType]) { + return discriminatorType; } else { return expectedType; // discriminator did not map to a type } diff --git a/samples/openapi3/client/petstore/typescript/builds/browser/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/browser/models/ObjectSerializer.ts index 8c5348569f9c..ec5282483271 100644 --- a/samples/openapi3/client/petstore/typescript/builds/browser/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/browser/models/ObjectSerializer.ts @@ -109,14 +109,16 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - let mapping = typeMap[expectedType].mapping; - if (discriminatorProperty == null || mapping == undefined) { + if (discriminatorProperty == null) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(mapping[discriminatorType]) { + let mapping = typeMap[expectedType].mapping; + if (mapping != undefined && mapping[discriminatorType]) { return mapping[discriminatorType]; // use the type given in the discriminator + } else if(typeMap[discriminatorType]) { + return discriminatorType; } else { return expectedType; // discriminator did not map to a type } diff --git a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts index 6e8ada4ecc89..dff7067ea8de 100644 --- a/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/composed-schemas/models/ObjectSerializer.ts @@ -114,14 +114,16 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - let mapping = typeMap[expectedType].mapping; - if (discriminatorProperty == null || mapping == undefined) { + if (discriminatorProperty == null) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(mapping[discriminatorType]) { + let mapping = typeMap[expectedType].mapping; + if (mapping != undefined && mapping[discriminatorType]) { return mapping[discriminatorType]; // use the type given in the discriminator + } else if(typeMap[discriminatorType]) { + return discriminatorType; } else { return expectedType; // discriminator did not map to a type } diff --git a/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts index 8c5348569f9c..ec5282483271 100644 --- a/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/default/models/ObjectSerializer.ts @@ -109,14 +109,16 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - let mapping = typeMap[expectedType].mapping; - if (discriminatorProperty == null || mapping == undefined) { + if (discriminatorProperty == null) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(mapping[discriminatorType]) { + let mapping = typeMap[expectedType].mapping; + if (mapping != undefined && mapping[discriminatorType]) { return mapping[discriminatorType]; // use the type given in the discriminator + } else if(typeMap[discriminatorType]) { + return discriminatorType; } else { return expectedType; // discriminator did not map to a type } diff --git a/samples/openapi3/client/petstore/typescript/builds/deno/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/deno/models/ObjectSerializer.ts index c995c1c9e031..32490364bb7e 100644 --- a/samples/openapi3/client/petstore/typescript/builds/deno/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/deno/models/ObjectSerializer.ts @@ -109,14 +109,16 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - let mapping = typeMap[expectedType].mapping; - if (discriminatorProperty == null || mapping == undefined) { + if (discriminatorProperty == null) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(mapping[discriminatorType]) { + let mapping = typeMap[expectedType].mapping; + if (mapping != undefined && mapping[discriminatorType]) { return mapping[discriminatorType]; // use the type given in the discriminator + } else if(typeMap[discriminatorType]) { + return discriminatorType; } else { return expectedType; // discriminator did not map to a type } diff --git a/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts index 8c5348569f9c..ec5282483271 100644 --- a/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/inversify/models/ObjectSerializer.ts @@ -109,14 +109,16 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - let mapping = typeMap[expectedType].mapping; - if (discriminatorProperty == null || mapping == undefined) { + if (discriminatorProperty == null) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(mapping[discriminatorType]) { + let mapping = typeMap[expectedType].mapping; + if (mapping != undefined && mapping[discriminatorType]) { return mapping[discriminatorType]; // use the type given in the discriminator + } else if(typeMap[discriminatorType]) { + return discriminatorType; } else { return expectedType; // discriminator did not map to a type } diff --git a/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts index 8c5348569f9c..ec5282483271 100644 --- a/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/jquery/models/ObjectSerializer.ts @@ -109,14 +109,16 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - let mapping = typeMap[expectedType].mapping; - if (discriminatorProperty == null || mapping == undefined) { + if (discriminatorProperty == null) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(mapping[discriminatorType]) { + let mapping = typeMap[expectedType].mapping; + if (mapping != undefined && mapping[discriminatorType]) { return mapping[discriminatorType]; // use the type given in the discriminator + } else if(typeMap[discriminatorType]) { + return discriminatorType; } else { return expectedType; // discriminator did not map to a type } diff --git a/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts index 8c5348569f9c..ec5282483271 100644 --- a/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts +++ b/samples/openapi3/client/petstore/typescript/builds/object_params/models/ObjectSerializer.ts @@ -109,14 +109,16 @@ export class ObjectSerializer { // Check the discriminator let discriminatorProperty = typeMap[expectedType].discriminator; - let mapping = typeMap[expectedType].mapping; - if (discriminatorProperty == null || mapping == undefined) { + if (discriminatorProperty == null) { return expectedType; // the type does not have a discriminator. use it. } else { if (data[discriminatorProperty]) { var discriminatorType = data[discriminatorProperty]; - if(mapping[discriminatorType]) { + let mapping = typeMap[expectedType].mapping; + if (mapping != undefined && mapping[discriminatorType]) { return mapping[discriminatorType]; // use the type given in the discriminator + } else if(typeMap[discriminatorType]) { + return discriminatorType; } else { return expectedType; // discriminator did not map to a type }