@looker/sdk-codegen 21.0.25 → 21.3.0
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/CHANGELOG.md +76 -0
- package/lib/codeGen.d.ts +7 -5
- package/lib/codeGen.js +24 -13
- package/lib/codeGen.js.map +1 -1
- package/lib/codeGenerators.d.ts +2 -2
- package/lib/codeGenerators.js.map +1 -1
- package/lib/csharp.gen.d.ts +3 -2
- package/lib/csharp.gen.js.map +1 -1
- package/lib/declarationInfo.d.ts +2 -2
- package/lib/declarationInfo.js.map +1 -1
- package/lib/esm/codeGen.js +24 -13
- package/lib/esm/codeGen.js.map +1 -1
- package/lib/esm/codeGenerators.js.map +1 -1
- package/lib/esm/csharp.gen.js.map +1 -1
- package/lib/esm/declarationInfo.js.map +1 -1
- package/lib/esm/exampleInfo.js.map +1 -1
- package/lib/esm/go.gen.js.map +1 -1
- package/lib/esm/kotlin.gen.js +89 -9
- package/lib/esm/kotlin.gen.js.map +1 -1
- package/lib/esm/pseudo.gen.js.map +1 -1
- package/lib/esm/python.gen.js +2 -2
- package/lib/esm/python.gen.js.map +1 -1
- package/lib/esm/sdkModels.js +199 -71
- package/lib/esm/sdkModels.js.map +1 -1
- package/lib/esm/specConverter.js.map +1 -1
- package/lib/esm/specDiff.js +1 -1
- package/lib/esm/specDiff.js.map +1 -1
- package/lib/esm/swift.gen.js +60 -8
- package/lib/esm/swift.gen.js.map +1 -1
- package/lib/esm/typescript.gen.js +12 -11
- package/lib/esm/typescript.gen.js.map +1 -1
- package/lib/exampleInfo.d.ts +1 -1
- package/lib/exampleInfo.js.map +1 -1
- package/lib/go.gen.d.ts +3 -2
- package/lib/go.gen.js.map +1 -1
- package/lib/kotlin.gen.d.ts +16 -2
- package/lib/kotlin.gen.js +88 -8
- package/lib/kotlin.gen.js.map +1 -1
- package/lib/pseudo.gen.d.ts +1 -1
- package/lib/pseudo.gen.js.map +1 -1
- package/lib/python.gen.d.ts +3 -2
- package/lib/python.gen.js +2 -2
- package/lib/python.gen.js.map +1 -1
- package/lib/sdkModels.d.ts +20 -5
- package/lib/sdkModels.js +208 -74
- package/lib/sdkModels.js.map +1 -1
- package/lib/specConverter.d.ts +7 -6
- package/lib/specConverter.js.map +1 -1
- package/lib/specDiff.d.ts +1 -1
- package/lib/specDiff.js +1 -1
- package/lib/specDiff.js.map +1 -1
- package/lib/swift.gen.d.ts +6 -2
- package/lib/swift.gen.js +60 -8
- package/lib/swift.gen.js.map +1 -1
- package/lib/typescript.gen.d.ts +4 -2
- package/lib/typescript.gen.js +12 -11
- package/lib/typescript.gen.js.map +1 -1
- package/package.json +4 -4
package/lib/sdkModels.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.ApiModel = exports.WriteType = exports.RequestType = exports.IntrinsicType = exports.HashType = exports.DelimArrayType = exports.EnumType = exports.ArrayType = exports.Type = exports.Method = exports.Parameter = exports.Property = exports.
|
|
6
|
+
exports.ApiModel = exports.WriteType = exports.RequestType = exports.IntrinsicType = exports.HashType = exports.DelimArrayType = exports.EnumType = exports.ArrayType = exports.Type = exports.Method = exports.Parameter = exports.Property = exports.tagTypes = exports.MetaType = exports.setToCriteria = exports.criteriaToSet = exports.SearchAll = exports.SearchCriterion = exports.firstMethodRef = exports.typeRefs = exports.methodRefs = exports.mayQuote = exports.keyValues = exports.firstCase = exports.titleCase = exports.camelCase = exports.safeName = exports.isSpecialName = exports.typeOfType = exports.TypeOfType = exports.strWrite = exports.strRequest = exports.strBody = void 0;
|
|
7
7
|
|
|
8
8
|
var OAS = _interopRequireWildcard(require("openapi3-ts"));
|
|
9
9
|
|
|
@@ -31,7 +31,7 @@ var strWrite = 'Write';
|
|
|
31
31
|
exports.strWrite = strWrite;
|
|
32
32
|
var lookerValuesTag = 'x-looker-values';
|
|
33
33
|
var enumTag = 'enum';
|
|
34
|
-
var simpleName = /^[a-z_][a-z_\d]
|
|
34
|
+
var simpleName = /^[a-z_][a-z_\d]*(\[])?$/im;
|
|
35
35
|
var TypeOfType;
|
|
36
36
|
exports.TypeOfType = TypeOfType;
|
|
37
37
|
|
|
@@ -113,8 +113,9 @@ var searchIt = value => value ? value + '\t' : '';
|
|
|
113
113
|
|
|
114
114
|
var localeSort = (a, b) => a.localeCompare(b);
|
|
115
115
|
|
|
116
|
-
var keyValues =
|
|
117
|
-
|
|
116
|
+
var keyValues = list => {
|
|
117
|
+
if (!list) return [];
|
|
118
|
+
return Array.from(list.values()).sort();
|
|
118
119
|
};
|
|
119
120
|
|
|
120
121
|
exports.keyValues = keyValues;
|
|
@@ -145,14 +146,70 @@ var typeRefs = (api, refs) => {
|
|
|
145
146
|
var keys = keyValues(refs);
|
|
146
147
|
var result = [];
|
|
147
148
|
keys.forEach(k => {
|
|
148
|
-
|
|
149
|
-
|
|
149
|
+
var ref = api.types[k];
|
|
150
|
+
|
|
151
|
+
if (ref) {
|
|
152
|
+
result.push(ref);
|
|
150
153
|
}
|
|
151
154
|
});
|
|
152
155
|
return result;
|
|
153
156
|
};
|
|
154
157
|
|
|
155
158
|
exports.typeRefs = typeRefs;
|
|
159
|
+
|
|
160
|
+
var firstMethodRef = function firstMethodRef(api, type) {
|
|
161
|
+
var stack = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set();
|
|
162
|
+
stack.add(type.name);
|
|
163
|
+
var method = methodRefs(api, type.methodRefs)[0];
|
|
164
|
+
|
|
165
|
+
if (!method) {
|
|
166
|
+
var parents = typeRefs(api, type.parentTypes);
|
|
167
|
+
|
|
168
|
+
for (var parent of parents) {
|
|
169
|
+
if (!stack.has(parent.name)) {
|
|
170
|
+
method = firstMethodRef(api, parent, stack);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (method) break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return method;
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
exports.firstMethodRef = firstMethodRef;
|
|
181
|
+
|
|
182
|
+
var anyWriter = function anyWriter(api, type) {
|
|
183
|
+
var stack = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set();
|
|
184
|
+
var result;
|
|
185
|
+
if (stack.has(type.name)) return undefined;
|
|
186
|
+
stack.add(type.name);
|
|
187
|
+
var methods = methodRefs(api, type.methodRefs);
|
|
188
|
+
|
|
189
|
+
for (var _method of methods) {
|
|
190
|
+
if (_method.httpMethod === 'POST' || _method.httpMethod === 'PUT' || _method.httpMethod === 'PATCH') {
|
|
191
|
+
result = _method;
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (!result) {
|
|
197
|
+
var allTypes = new Set([...type.parentTypes, ...type.customTypes]);
|
|
198
|
+
allTypes.delete(type.name);
|
|
199
|
+
var refs = typeRefs(api, allTypes);
|
|
200
|
+
|
|
201
|
+
for (var ref of refs) {
|
|
202
|
+
result = anyWriter(api, ref, stack);
|
|
203
|
+
|
|
204
|
+
if (result) {
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
return result;
|
|
211
|
+
};
|
|
212
|
+
|
|
156
213
|
var SearchCriterion;
|
|
157
214
|
exports.SearchCriterion = SearchCriterion;
|
|
158
215
|
|
|
@@ -172,7 +229,7 @@ exports.SearchCriterion = SearchCriterion;
|
|
|
172
229
|
var SearchAll = new Set([SearchCriterion.method, SearchCriterion.type, SearchCriterion.name, SearchCriterion.description, SearchCriterion.argument, SearchCriterion.property, SearchCriterion.title, SearchCriterion.activityType, SearchCriterion.status, SearchCriterion.response]);
|
|
173
230
|
exports.SearchAll = SearchAll;
|
|
174
231
|
|
|
175
|
-
var
|
|
232
|
+
var criteriaToSet = criteria => {
|
|
176
233
|
var result = new Set();
|
|
177
234
|
criteria.forEach(name => {
|
|
178
235
|
var val = SearchCriterion[name];
|
|
@@ -181,15 +238,57 @@ var CriteriaToSet = criteria => {
|
|
|
181
238
|
return result;
|
|
182
239
|
};
|
|
183
240
|
|
|
184
|
-
exports.
|
|
241
|
+
exports.criteriaToSet = criteriaToSet;
|
|
185
242
|
|
|
186
|
-
var
|
|
243
|
+
var setToCriteria = criteria => {
|
|
187
244
|
var result = [];
|
|
188
245
|
criteria.forEach(value => result.push(SearchCriterion[value]));
|
|
189
246
|
return result;
|
|
190
247
|
};
|
|
191
248
|
|
|
192
|
-
exports.
|
|
249
|
+
exports.setToCriteria = setToCriteria;
|
|
250
|
+
var MetaType;
|
|
251
|
+
exports.MetaType = MetaType;
|
|
252
|
+
|
|
253
|
+
(function (MetaType) {
|
|
254
|
+
MetaType["Intrinsic"] = "Intrinsic";
|
|
255
|
+
MetaType["Specification"] = "Specification";
|
|
256
|
+
MetaType["Write"] = "Write";
|
|
257
|
+
MetaType["Request"] = "Request";
|
|
258
|
+
MetaType["Enumerated"] = "Enumerated";
|
|
259
|
+
})(MetaType || (exports.MetaType = MetaType = {}));
|
|
260
|
+
|
|
261
|
+
var tagTypes = (api, types) => {
|
|
262
|
+
var typeTags = {};
|
|
263
|
+
Object.entries(types).filter(_ref => {
|
|
264
|
+
var [_, type] = _ref;
|
|
265
|
+
return !type.intrinsic;
|
|
266
|
+
}).forEach(_ref2 => {
|
|
267
|
+
var [name, type] = _ref2;
|
|
268
|
+
var methods = methodRefs(api, type.methodRefs);
|
|
269
|
+
|
|
270
|
+
if (methods.length === 0) {
|
|
271
|
+
var first = firstMethodRef(api, type);
|
|
272
|
+
if (first) methods = [first];
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
methods.forEach(method => {
|
|
276
|
+
for (var tag of method.schema.tags) {
|
|
277
|
+
var _list = typeTags[tag];
|
|
278
|
+
|
|
279
|
+
if (!_list) {
|
|
280
|
+
_list = {};
|
|
281
|
+
typeTags[tag] = _list;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
_list[name] = type;
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
});
|
|
288
|
+
return typeTags;
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
exports.tagTypes = tagTypes;
|
|
193
292
|
|
|
194
293
|
class MethodResponse {
|
|
195
294
|
constructor(statusCode, mediaType, type, description) {
|
|
@@ -507,8 +606,8 @@ class Method extends SchemadSymbol {
|
|
|
507
606
|
api.getRequestType(this);
|
|
508
607
|
}
|
|
509
608
|
|
|
510
|
-
Object.entries(this.params).forEach(
|
|
511
|
-
var [, param] =
|
|
609
|
+
Object.entries(this.params).forEach(_ref3 => {
|
|
610
|
+
var [, param] = _ref3;
|
|
512
611
|
var writer = api.mayGetWriteableType(param.type);
|
|
513
612
|
|
|
514
613
|
if (writer) {
|
|
@@ -819,6 +918,14 @@ class Type {
|
|
|
819
918
|
this.description = this.schema.description || '';
|
|
820
919
|
}
|
|
821
920
|
|
|
921
|
+
get metaType() {
|
|
922
|
+
if (this.intrinsic) return MetaType.Intrinsic;
|
|
923
|
+
if (this instanceof RequestType) return MetaType.Request;
|
|
924
|
+
if (this instanceof WriteType) return MetaType.Write;
|
|
925
|
+
if (this instanceof EnumType) return MetaType.Enumerated;
|
|
926
|
+
return MetaType.Specification;
|
|
927
|
+
}
|
|
928
|
+
|
|
822
929
|
get fullName() {
|
|
823
930
|
return this.name;
|
|
824
931
|
}
|
|
@@ -884,16 +991,16 @@ class Type {
|
|
|
884
991
|
}
|
|
885
992
|
|
|
886
993
|
get readOnly() {
|
|
887
|
-
return Object.entries(this.properties).every(
|
|
888
|
-
var [, prop] =
|
|
994
|
+
return Object.entries(this.properties).every(_ref4 => {
|
|
995
|
+
var [, prop] = _ref4;
|
|
889
996
|
return prop.readOnly;
|
|
890
997
|
});
|
|
891
998
|
}
|
|
892
999
|
|
|
893
1000
|
filterRequiredProps(required) {
|
|
894
1001
|
var filteredProps = {};
|
|
895
|
-
Object.entries(this.properties).forEach(
|
|
896
|
-
var [key, prop] =
|
|
1002
|
+
Object.entries(this.properties).forEach(_ref5 => {
|
|
1003
|
+
var [key, prop] = _ref5;
|
|
897
1004
|
var condition = required ? prop.required : !prop.required;
|
|
898
1005
|
|
|
899
1006
|
if (condition) {
|
|
@@ -912,16 +1019,16 @@ class Type {
|
|
|
912
1019
|
}
|
|
913
1020
|
|
|
914
1021
|
get hasSpecialNeeds() {
|
|
915
|
-
return !!Object.entries(this.properties).find(
|
|
916
|
-
var [, prop] =
|
|
1022
|
+
return !!Object.entries(this.properties).find(_ref6 => {
|
|
1023
|
+
var [, prop] = _ref6;
|
|
917
1024
|
return prop.hasSpecialNeeds;
|
|
918
1025
|
});
|
|
919
1026
|
}
|
|
920
1027
|
|
|
921
1028
|
load(api) {
|
|
922
|
-
Object.entries(this.schema.properties || {}).forEach(
|
|
923
|
-
var [propName, propSchema] =
|
|
924
|
-
var propType = api.resolveType(propSchema, undefined, propName);
|
|
1029
|
+
Object.entries(this.schema.properties || {}).forEach(_ref7 => {
|
|
1030
|
+
var [propName, propSchema] = _ref7;
|
|
1031
|
+
var propType = api.resolveType(propSchema, undefined, propName, this.name);
|
|
925
1032
|
|
|
926
1033
|
if (propType.instanceOf('EnumType')) {
|
|
927
1034
|
api.registerEnum(propType, propName);
|
|
@@ -950,12 +1057,12 @@ class Type {
|
|
|
950
1057
|
|
|
951
1058
|
asHashString() {
|
|
952
1059
|
var result = "".concat(this.name, ":");
|
|
953
|
-
Object.entries(this.properties).sort((
|
|
954
|
-
var [a] =
|
|
955
|
-
var [b] =
|
|
1060
|
+
Object.entries(this.properties).sort((_ref8, _ref9) => {
|
|
1061
|
+
var [a] = _ref8;
|
|
1062
|
+
var [b] = _ref9;
|
|
956
1063
|
return a.localeCompare(b);
|
|
957
|
-
}).forEach(
|
|
958
|
-
var [, prop] =
|
|
1064
|
+
}).forEach(_ref10 => {
|
|
1065
|
+
var [, prop] = _ref10;
|
|
959
1066
|
result += prop.asHashString() + ':';
|
|
960
1067
|
});
|
|
961
1068
|
return result;
|
|
@@ -963,8 +1070,8 @@ class Type {
|
|
|
963
1070
|
|
|
964
1071
|
isRecursive() {
|
|
965
1072
|
var selfType = this.name;
|
|
966
|
-
return Object.entries(this.properties).some(
|
|
967
|
-
var [, prop] =
|
|
1073
|
+
return Object.entries(this.properties).some(_ref11 => {
|
|
1074
|
+
var [, prop] = _ref11;
|
|
968
1075
|
return prop.type.name === selfType;
|
|
969
1076
|
});
|
|
970
1077
|
}
|
|
@@ -1003,8 +1110,8 @@ class Type {
|
|
|
1003
1110
|
}
|
|
1004
1111
|
|
|
1005
1112
|
if (criteria.has(SearchCriterion.property)) {
|
|
1006
|
-
Object.entries(this.properties).forEach(
|
|
1007
|
-
var [, prop] =
|
|
1113
|
+
Object.entries(this.properties).forEach(_ref12 => {
|
|
1114
|
+
var [, prop] = _ref12;
|
|
1008
1115
|
|
|
1009
1116
|
if (this.name !== prop.type.name) {
|
|
1010
1117
|
result += prop.searchString(criteria);
|
|
@@ -1039,7 +1146,7 @@ class ArrayType extends Type {
|
|
|
1039
1146
|
exports.ArrayType = ArrayType;
|
|
1040
1147
|
|
|
1041
1148
|
class EnumType extends Type {
|
|
1042
|
-
constructor(elementType, schema,
|
|
1149
|
+
constructor(elementType, schema, api, typeName, methodName) {
|
|
1043
1150
|
super(schema, schema.name);
|
|
1044
1151
|
this.elementType = elementType;
|
|
1045
1152
|
|
|
@@ -1056,27 +1163,36 @@ class EnumType extends Type {
|
|
|
1056
1163
|
}
|
|
1057
1164
|
|
|
1058
1165
|
if (methodName) {
|
|
1059
|
-
this.description = "
|
|
1166
|
+
this.description = "".concat(this.description).concat(this.description ? ' ' : '', "(Enum defined in ").concat(methodName, ")");
|
|
1060
1167
|
}
|
|
1061
1168
|
|
|
1062
|
-
this.name = this.findName(
|
|
1169
|
+
this.name = this.findName(api, typeName, methodName);
|
|
1063
1170
|
}
|
|
1064
1171
|
|
|
1065
|
-
findName(
|
|
1172
|
+
findName(api, typeName, methodName) {
|
|
1173
|
+
var hash = (0, _blueimpMd.default)(this.asHashString());
|
|
1174
|
+
var enums = api.getEnumList();
|
|
1066
1175
|
var name = titleCase(this.name || typeName || 'Enum');
|
|
1067
1176
|
|
|
1068
|
-
if (name in types) {
|
|
1177
|
+
if (name in api.types) {
|
|
1178
|
+
var matched = enums[hash];
|
|
1179
|
+
|
|
1180
|
+
if ((matched === null || matched === void 0 ? void 0 : matched.name) === name) {
|
|
1181
|
+
return name;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1069
1184
|
var baseName = methodName ? titleCase("".concat(methodName, "_").concat(name)) : name;
|
|
1070
1185
|
var newName = baseName;
|
|
1071
1186
|
var i = 0;
|
|
1072
1187
|
|
|
1073
|
-
while (newName in types) {
|
|
1188
|
+
while (newName in api.types) {
|
|
1074
1189
|
newName = "".concat(baseName).concat(++i);
|
|
1075
1190
|
}
|
|
1076
1191
|
|
|
1077
1192
|
name = newName;
|
|
1078
1193
|
}
|
|
1079
1194
|
|
|
1195
|
+
enums[hash] = this;
|
|
1080
1196
|
return name;
|
|
1081
1197
|
}
|
|
1082
1198
|
|
|
@@ -1225,11 +1341,11 @@ exports.WriteType = WriteType;
|
|
|
1225
1341
|
|
|
1226
1342
|
_defineProperty(WriteType, "readonlyProps", properties => {
|
|
1227
1343
|
var result = [];
|
|
1228
|
-
Object.entries(properties).filter(
|
|
1229
|
-
var [, prop] =
|
|
1344
|
+
Object.entries(properties).filter(_ref21 => {
|
|
1345
|
+
var [, prop] = _ref21;
|
|
1230
1346
|
return prop.readOnly || prop.type.readOnly;
|
|
1231
|
-
}).forEach(
|
|
1232
|
-
var [, prop] =
|
|
1347
|
+
}).forEach(_ref22 => {
|
|
1348
|
+
var [, prop] = _ref22;
|
|
1233
1349
|
return result.push(prop);
|
|
1234
1350
|
});
|
|
1235
1351
|
return result;
|
|
@@ -1251,6 +1367,8 @@ class ApiModel {
|
|
|
1251
1367
|
|
|
1252
1368
|
_defineProperty(this, "tags", {});
|
|
1253
1369
|
|
|
1370
|
+
_defineProperty(this, "typeTags", {});
|
|
1371
|
+
|
|
1254
1372
|
;
|
|
1255
1373
|
['string', 'integer', 'int64', 'boolean', 'object', 'uri', 'float', 'double', 'void', 'datetime', 'email', 'uuid', 'uri', 'hostname', 'ipv4', 'ipv6', 'any'].forEach(name => this.types[name] = new IntrinsicType(name));
|
|
1256
1374
|
this.load();
|
|
@@ -1288,14 +1406,14 @@ class ApiModel {
|
|
|
1288
1406
|
|
|
1289
1407
|
static addMethodToTags(tags, method) {
|
|
1290
1408
|
for (var tag of method.schema.tags) {
|
|
1291
|
-
var
|
|
1409
|
+
var _list2 = tags[tag];
|
|
1292
1410
|
|
|
1293
|
-
if (!
|
|
1294
|
-
|
|
1295
|
-
tags[tag] =
|
|
1411
|
+
if (!_list2) {
|
|
1412
|
+
_list2 = {};
|
|
1413
|
+
tags[tag] = _list2;
|
|
1296
1414
|
}
|
|
1297
1415
|
|
|
1298
|
-
|
|
1416
|
+
_list2[method.name] = method;
|
|
1299
1417
|
}
|
|
1300
1418
|
|
|
1301
1419
|
return tags;
|
|
@@ -1328,8 +1446,8 @@ class ApiModel {
|
|
|
1328
1446
|
}
|
|
1329
1447
|
|
|
1330
1448
|
if (ApiModel.isMethodSearch(criteria)) {
|
|
1331
|
-
Object.entries(this.methods).forEach(
|
|
1332
|
-
var [, method] =
|
|
1449
|
+
Object.entries(this.methods).forEach(_ref13 => {
|
|
1450
|
+
var [, method] = _ref13;
|
|
1333
1451
|
|
|
1334
1452
|
if (method.search(rx, criteria)) {
|
|
1335
1453
|
methodCount++;
|
|
@@ -1339,8 +1457,8 @@ class ApiModel {
|
|
|
1339
1457
|
}
|
|
1340
1458
|
|
|
1341
1459
|
if (ApiModel.isTypeSearch(criteria)) {
|
|
1342
|
-
Object.entries(this.types).forEach(
|
|
1343
|
-
var [key, type] =
|
|
1460
|
+
Object.entries(this.types).forEach(_ref14 => {
|
|
1461
|
+
var [key, type] = _ref14;
|
|
1344
1462
|
|
|
1345
1463
|
if (!rx) {
|
|
1346
1464
|
throw Error("".concat(key, " rx undefined"));
|
|
@@ -1426,7 +1544,7 @@ class ApiModel {
|
|
|
1426
1544
|
}
|
|
1427
1545
|
|
|
1428
1546
|
if (this.schemaHasEnums(schema)) {
|
|
1429
|
-
var num = new EnumType(resolved, schema, this
|
|
1547
|
+
var num = new EnumType(resolved, schema, this, typeName, methodName);
|
|
1430
1548
|
this.registerEnum(num, methodName);
|
|
1431
1549
|
var result = new ArrayType(num, schema);
|
|
1432
1550
|
return result;
|
|
@@ -1436,7 +1554,9 @@ class ApiModel {
|
|
|
1436
1554
|
}
|
|
1437
1555
|
|
|
1438
1556
|
if (this.schemaHasEnums(schema)) {
|
|
1439
|
-
var
|
|
1557
|
+
var _resolved = this.resolveType(schema.type, style, typeName, methodName);
|
|
1558
|
+
|
|
1559
|
+
var _result = new EnumType(_resolved, schema, this, typeName, methodName);
|
|
1440
1560
|
|
|
1441
1561
|
if (_result) {
|
|
1442
1562
|
return this.registerEnum(_result, methodName);
|
|
@@ -1478,23 +1598,26 @@ class ApiModel {
|
|
|
1478
1598
|
|
|
1479
1599
|
registerEnum(type, methodName) {
|
|
1480
1600
|
if (!(type instanceof EnumType)) return type;
|
|
1481
|
-
var hash = (0, _blueimpMd.default)(type.asHashString());
|
|
1482
1601
|
|
|
1483
|
-
if (
|
|
1484
|
-
|
|
1602
|
+
if (type.name in this.types) {
|
|
1603
|
+
var hash = (0, _blueimpMd.default)(type.asHashString());
|
|
1604
|
+
var matched = this.enumTypes[hash];
|
|
1605
|
+
|
|
1606
|
+
if ((matched === null || matched === void 0 ? void 0 : matched.name) === type.name) {
|
|
1607
|
+
return this.enumTypes[hash];
|
|
1608
|
+
}
|
|
1485
1609
|
}
|
|
1486
1610
|
|
|
1487
1611
|
if (methodName) {
|
|
1488
|
-
var
|
|
1612
|
+
var _method2 = this.methods[methodName];
|
|
1489
1613
|
|
|
1490
|
-
if (
|
|
1491
|
-
|
|
1614
|
+
if (_method2) {
|
|
1615
|
+
_method2.types.add(type.name);
|
|
1492
1616
|
|
|
1493
|
-
|
|
1617
|
+
_method2.customTypes.add(type.name);
|
|
1494
1618
|
}
|
|
1495
1619
|
}
|
|
1496
1620
|
|
|
1497
|
-
this.enumTypes[hash] = type;
|
|
1498
1621
|
this.types[type.name] = type;
|
|
1499
1622
|
return type;
|
|
1500
1623
|
}
|
|
@@ -1516,6 +1639,10 @@ class ApiModel {
|
|
|
1516
1639
|
return result;
|
|
1517
1640
|
}
|
|
1518
1641
|
|
|
1642
|
+
getEnumList() {
|
|
1643
|
+
return this.enumTypes;
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1519
1646
|
makeWriteableType(hash, type) {
|
|
1520
1647
|
var writer = new WriteType(this, type);
|
|
1521
1648
|
this.types[writer.name] = writer;
|
|
@@ -1529,8 +1656,9 @@ class ApiModel {
|
|
|
1529
1656
|
if (type.intrinsic) return undefined;
|
|
1530
1657
|
if ((_type$elementType = type.elementType) !== null && _type$elementType !== void 0 && _type$elementType.intrinsic) return undefined;
|
|
1531
1658
|
if (type instanceof WriteType) return type;
|
|
1532
|
-
|
|
1533
|
-
|
|
1659
|
+
if (!anyWriter(this, type)) return undefined;
|
|
1660
|
+
var props = Object.entries(type.properties).map(_ref15 => {
|
|
1661
|
+
var [, prop] = _ref15;
|
|
1534
1662
|
return prop;
|
|
1535
1663
|
});
|
|
1536
1664
|
if (props.length === 0) return undefined;
|
|
@@ -1559,8 +1687,8 @@ class ApiModel {
|
|
|
1559
1687
|
}
|
|
1560
1688
|
|
|
1561
1689
|
loadDynamicTypes() {
|
|
1562
|
-
Object.entries(this.methods).forEach(
|
|
1563
|
-
var [, method] =
|
|
1690
|
+
Object.entries(this.methods).forEach(_ref16 => {
|
|
1691
|
+
var [, method] = _ref16;
|
|
1564
1692
|
method.makeTypes(this);
|
|
1565
1693
|
});
|
|
1566
1694
|
}
|
|
@@ -1580,14 +1708,19 @@ class ApiModel {
|
|
|
1580
1708
|
this.methods = this.sortList(this.methods);
|
|
1581
1709
|
this.types = this.sortList(this.types);
|
|
1582
1710
|
this.tags = this.sortList(this.tags);
|
|
1711
|
+
this.typeTags = this.sortList(this.typeTags);
|
|
1712
|
+
var typeKeys = Object.keys(this.typeTags);
|
|
1713
|
+
typeKeys.forEach(key => {
|
|
1714
|
+
this.typeTags[key] = this.sortList(this.typeTags[key]);
|
|
1715
|
+
});
|
|
1583
1716
|
}
|
|
1584
1717
|
|
|
1585
1718
|
load() {
|
|
1586
1719
|
var _this$spec3, _this$spec3$component, _this$spec4;
|
|
1587
1720
|
|
|
1588
1721
|
if ((_this$spec3 = this.spec) !== null && _this$spec3 !== void 0 && (_this$spec3$component = _this$spec3.components) !== null && _this$spec3$component !== void 0 && _this$spec3$component.schemas) {
|
|
1589
|
-
Object.entries(this.spec.components.schemas).forEach(
|
|
1590
|
-
var [name, schema] =
|
|
1722
|
+
Object.entries(this.spec.components.schemas).forEach(_ref17 => {
|
|
1723
|
+
var [name, schema] = _ref17;
|
|
1591
1724
|
var t = new Type(schema, name);
|
|
1592
1725
|
this.types[name] = t;
|
|
1593
1726
|
this.refs["#/components/schemas/".concat(name)] = t;
|
|
@@ -1611,8 +1744,8 @@ class ApiModel {
|
|
|
1611
1744
|
}
|
|
1612
1745
|
|
|
1613
1746
|
if ((_this$spec4 = this.spec) !== null && _this$spec4 !== void 0 && _this$spec4.paths) {
|
|
1614
|
-
Object.entries(this.spec.paths).forEach(
|
|
1615
|
-
var [path, schema] =
|
|
1747
|
+
Object.entries(this.spec.paths).forEach(_ref18 => {
|
|
1748
|
+
var [path, schema] = _ref18;
|
|
1616
1749
|
var methods = this.loadMethods(path, schema);
|
|
1617
1750
|
methods.forEach(method => {
|
|
1618
1751
|
this.methods[method.name] = method;
|
|
@@ -1621,6 +1754,7 @@ class ApiModel {
|
|
|
1621
1754
|
}
|
|
1622
1755
|
|
|
1623
1756
|
this.loadDynamicTypes();
|
|
1757
|
+
this.typeTags = tagTypes(this, this.types);
|
|
1624
1758
|
this.sortLists();
|
|
1625
1759
|
}
|
|
1626
1760
|
|
|
@@ -1633,10 +1767,10 @@ class ApiModel {
|
|
|
1633
1767
|
var params = this.methodParameters(opSchema);
|
|
1634
1768
|
var body = this.requestBody(opSchema.requestBody);
|
|
1635
1769
|
|
|
1636
|
-
var
|
|
1770
|
+
var _method3 = new Method(this, httpMethod, endpoint, opSchema, params, responses, body);
|
|
1637
1771
|
|
|
1638
|
-
methods.push(
|
|
1639
|
-
this.tagMethod(
|
|
1772
|
+
methods.push(_method3);
|
|
1773
|
+
this.tagMethod(_method3);
|
|
1640
1774
|
}
|
|
1641
1775
|
};
|
|
1642
1776
|
|
|
@@ -1650,13 +1784,13 @@ class ApiModel {
|
|
|
1650
1784
|
|
|
1651
1785
|
methodResponses(schema) {
|
|
1652
1786
|
var responses = [];
|
|
1653
|
-
Object.entries(schema.responses).forEach(
|
|
1654
|
-
var [statusCode, contentSchema] =
|
|
1787
|
+
Object.entries(schema.responses).forEach(_ref19 => {
|
|
1788
|
+
var [statusCode, contentSchema] = _ref19;
|
|
1655
1789
|
var desc = contentSchema.description || '';
|
|
1656
1790
|
|
|
1657
1791
|
if (contentSchema.content) {
|
|
1658
|
-
Object.entries(contentSchema.content).forEach(
|
|
1659
|
-
var [mediaType, response] =
|
|
1792
|
+
Object.entries(contentSchema.content).forEach(_ref20 => {
|
|
1793
|
+
var [mediaType, response] = _ref20;
|
|
1660
1794
|
responses.push(new MethodResponse(parseInt(statusCode, 10), mediaType, this.resolveType(response.schema || {}), desc));
|
|
1661
1795
|
});
|
|
1662
1796
|
} else if (statusCode === '204') {
|