Skip to content

Commit ea1dff7

Browse files
committed
Add comments to fix oneOf handling
1 parent cdd9e00 commit ea1dff7

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

templates-v7/typescript/model/modelOneOf.mustache

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
} from './';
77

88
{{/hasImports}}
9+
910
/**
1011
* @type {{classname}}
1112
* Type
@@ -19,14 +20,14 @@ export type {{classname}} = {{#oneOf}}{{{.}}}{{^-last}} | {{/-last}}{{/oneOf}};
1920
* @export
2021
*/
2122
export class {{classname}}Class {
23+
2224
{{#discriminator}}
2325

2426
static readonly discriminator: string | undefined = "{{discriminatorName}}";
25-
// static readonly discriminator: string = "type";
26-
2727
{{/discriminator}}
2828
{{^discriminator}}
29-
static readonly discriminator: string | undefined = undefined;
29+
{{! Note: discriminator is not defined in OpenAPI spec, fallback to `type` }}
30+
static readonly discriminator: string = "type";
3031
{{/discriminator}}
3132
{{#hasDiscriminatorWithNonEmptyMapping}}
3233

@@ -35,19 +36,18 @@ export class {{classname}}Class {
3536
"{{mappingName}}": "{{modelName}}",
3637
{{/discriminator.mappedModels}}
3738
};
39+
{{! Note: discriminator is not defined in OpenAPI spec, it should generate something like this:
40+
static readonly mapping: { [key: string]: string } = {
41+
"await": "CheckoutAwaitAction",
42+
"bankTransfer": "CheckoutBankTransferAction",
43+
"redirect": "CheckoutRedirectAction",
44+
"threeDS2": "CheckoutThreeDS2Action",
45+
"sdk": "CheckoutSDKAction",
46+
"voucher": "CheckoutVoucherAction",
47+
}; }}
3848
{{/hasDiscriminatorWithNonEmptyMapping}}
3949
{{^hasDiscriminatorWithNonEmptyMapping}}
4050

4151
static readonly mapping: {[index: string]: string} | undefined = undefined;
4252
{{/hasDiscriminatorWithNonEmptyMapping}}
43-
44-
// static readonly mapping: { [key: string]: string } = {
45-
// "await": "CheckoutAwaitAction",
46-
// "bankTransfer": "CheckoutBankTransferAction",
47-
// "redirect": "CheckoutRedirectAction",
48-
// "threeDS2": "CheckoutThreeDS2Action",
49-
// "sdk": "CheckoutSDKAction",
50-
// "voucher": "CheckoutVoucherAction",
51-
// Add all other action types...
52-
};
5353
}

0 commit comments

Comments
 (0)