swagger-typescript-api 13.0.1 → 13.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -74,36 +74,36 @@ class DiscriminatorSchemaParser extends MonoSchemaParser {
|
|
|
74
74
|
});
|
|
75
75
|
|
|
76
76
|
if (ableToCreateMappingType) {
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
const rawTypeName = `${abstractSchemaStruct.typeName}_${discriminator.propertyName}`;
|
|
78
|
+
const generatedTypeName = this.schemaUtils.resolveTypeName(rawTypeName, {
|
|
79
|
+
suffixes: this.config.extractingOptions.discriminatorMappingSuffix,
|
|
80
|
+
resolver:
|
|
81
|
+
this.config.extractingOptions.discriminatorMappingNameResolver,
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const content = ts.IntersectionType([
|
|
85
|
+
ts.ObjectWrapper(
|
|
86
|
+
ts.TypeField({
|
|
87
|
+
key: ts.StringValue(discriminator.propertyName),
|
|
88
|
+
value: 'Key',
|
|
89
|
+
}),
|
|
87
90
|
),
|
|
91
|
+
'Type',
|
|
88
92
|
]);
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}),
|
|
99
|
-
),
|
|
100
|
-
'Type',
|
|
101
|
-
]),
|
|
102
|
-
genericArgs: [{ name: 'Key' }, { name: 'Type' }],
|
|
103
|
-
internal: true,
|
|
93
|
+
|
|
94
|
+
const component = this.schemaParserFabric.createParsedComponent({
|
|
95
|
+
typeName: generatedTypeName,
|
|
96
|
+
schema: {
|
|
97
|
+
type: 'object',
|
|
98
|
+
properties: {},
|
|
99
|
+
genericArgs: [{ name: 'Key' }, { name: 'Type' }],
|
|
100
|
+
internal: true,
|
|
101
|
+
},
|
|
104
102
|
});
|
|
105
103
|
|
|
106
|
-
|
|
104
|
+
component.typeData.content = content;
|
|
105
|
+
|
|
106
|
+
mappingTypeName = this.typeNameFormatter.format(component.typeName);
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
/** returns (GenericType<"mapping_key", MappingType>) or ({ discriminatorProperty: "mapping_key" } & MappingType) */
|
|
@@ -259,9 +259,12 @@ class DiscriminatorSchemaParser extends MonoSchemaParser {
|
|
|
259
259
|
const { discriminator, ...noDiscriminatorSchema } = this.schema;
|
|
260
260
|
const complexSchemaKeys = _.keys(this.schemaParser._complexSchemaParsers);
|
|
261
261
|
const schema = _.omit(_.clone(noDiscriminatorSchema), complexSchemaKeys);
|
|
262
|
+
const schemaIsAny =
|
|
263
|
+
this.schemaParserFabric.getInlineParseContent(_.cloneDeep(schema)) ===
|
|
264
|
+
this.config.Ts.Keyword.Any;
|
|
262
265
|
const schemaIsEmpty = !_.keys(schema).length;
|
|
263
266
|
|
|
264
|
-
if (schemaIsEmpty) return null;
|
|
267
|
+
if (schemaIsEmpty || schemaIsAny) return null;
|
|
265
268
|
|
|
266
269
|
const typeName = this.schemaUtils.resolveTypeName(this.typeName, {
|
|
267
270
|
prefixes: this.config.extractingOptions.discriminatorAbstractPrefix,
|
|
@@ -41,13 +41,7 @@ class TypeNameFormatter {
|
|
|
41
41
|
? this.config.enumKeySuffix
|
|
42
42
|
: this.config.typeSuffix;
|
|
43
43
|
|
|
44
|
-
const
|
|
45
|
-
this.formattedModelNamesMap.entries(),
|
|
46
|
-
).find((entry) => entry[1] === name);
|
|
47
|
-
|
|
48
|
-
const hashKey = existedFormattedEntry
|
|
49
|
-
? existedFormattedEntry[0]
|
|
50
|
-
: `${typePrefix}_${name}_${typeSuffix}`;
|
|
44
|
+
const hashKey = `${typePrefix}_${name}_${typeSuffix}`;
|
|
51
45
|
|
|
52
46
|
if (typeof name !== 'string') {
|
|
53
47
|
this.logger.warn('wrong name of the model name', name);
|