@looker/sdk-codegen 21.0.24 → 21.2.1
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 +9 -9
- 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 +4 -2
- 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 +9 -9
- package/lib/typescript.gen.js.map +1 -1
- package/package.json +4 -4
package/lib/esm/sdkModels.js
CHANGED
|
@@ -12,7 +12,7 @@ export var strRequest = 'Request';
|
|
|
12
12
|
export var strWrite = 'Write';
|
|
13
13
|
var lookerValuesTag = 'x-looker-values';
|
|
14
14
|
var enumTag = 'enum';
|
|
15
|
-
var simpleName = /^[a-z_][a-z_\d]
|
|
15
|
+
var simpleName = /^[a-z_][a-z_\d]*(\[])?$/im;
|
|
16
16
|
export var TypeOfType;
|
|
17
17
|
|
|
18
18
|
(function (TypeOfType) {
|
|
@@ -76,8 +76,9 @@ var searchIt = value => value ? value + '\t' : '';
|
|
|
76
76
|
|
|
77
77
|
var localeSort = (a, b) => a.localeCompare(b);
|
|
78
78
|
|
|
79
|
-
export var keyValues =
|
|
80
|
-
|
|
79
|
+
export var keyValues = list => {
|
|
80
|
+
if (!list) return [];
|
|
81
|
+
return Array.from(list.values()).sort();
|
|
81
82
|
};
|
|
82
83
|
export var mayQuote = function mayQuote(value) {
|
|
83
84
|
var quoteChar = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "'";
|
|
@@ -99,12 +100,65 @@ export var typeRefs = (api, refs) => {
|
|
|
99
100
|
var keys = keyValues(refs);
|
|
100
101
|
var result = [];
|
|
101
102
|
keys.forEach(k => {
|
|
102
|
-
|
|
103
|
-
|
|
103
|
+
var ref = api.types[k];
|
|
104
|
+
|
|
105
|
+
if (ref) {
|
|
106
|
+
result.push(ref);
|
|
104
107
|
}
|
|
105
108
|
});
|
|
106
109
|
return result;
|
|
107
110
|
};
|
|
111
|
+
export var firstMethodRef = function firstMethodRef(api, type) {
|
|
112
|
+
var stack = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set();
|
|
113
|
+
stack.add(type.name);
|
|
114
|
+
var method = methodRefs(api, type.methodRefs)[0];
|
|
115
|
+
|
|
116
|
+
if (!method) {
|
|
117
|
+
var parents = typeRefs(api, type.parentTypes);
|
|
118
|
+
|
|
119
|
+
for (var parent of parents) {
|
|
120
|
+
if (!stack.has(parent.name)) {
|
|
121
|
+
method = firstMethodRef(api, parent, stack);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (method) break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return method;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
var anyWriter = function anyWriter(api, type) {
|
|
132
|
+
var stack = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : new Set();
|
|
133
|
+
var result;
|
|
134
|
+
if (stack.has(type.name)) return undefined;
|
|
135
|
+
stack.add(type.name);
|
|
136
|
+
var methods = methodRefs(api, type.methodRefs);
|
|
137
|
+
|
|
138
|
+
for (var _method of methods) {
|
|
139
|
+
if (_method.httpMethod === 'POST' || _method.httpMethod === 'PUT' || _method.httpMethod === 'PATCH') {
|
|
140
|
+
result = _method;
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
if (!result) {
|
|
146
|
+
var allTypes = new Set([...type.parentTypes, ...type.customTypes]);
|
|
147
|
+
allTypes.delete(type.name);
|
|
148
|
+
var refs = typeRefs(api, allTypes);
|
|
149
|
+
|
|
150
|
+
for (var ref of refs) {
|
|
151
|
+
result = anyWriter(api, ref, stack);
|
|
152
|
+
|
|
153
|
+
if (result) {
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return result;
|
|
160
|
+
};
|
|
161
|
+
|
|
108
162
|
export var SearchCriterion;
|
|
109
163
|
|
|
110
164
|
(function (SearchCriterion) {
|
|
@@ -121,7 +175,7 @@ export var SearchCriterion;
|
|
|
121
175
|
})(SearchCriterion || (SearchCriterion = {}));
|
|
122
176
|
|
|
123
177
|
export var SearchAll = new Set([SearchCriterion.method, SearchCriterion.type, SearchCriterion.name, SearchCriterion.description, SearchCriterion.argument, SearchCriterion.property, SearchCriterion.title, SearchCriterion.activityType, SearchCriterion.status, SearchCriterion.response]);
|
|
124
|
-
export var
|
|
178
|
+
export var criteriaToSet = criteria => {
|
|
125
179
|
var result = new Set();
|
|
126
180
|
criteria.forEach(name => {
|
|
127
181
|
var val = SearchCriterion[name];
|
|
@@ -129,11 +183,50 @@ export var CriteriaToSet = criteria => {
|
|
|
129
183
|
});
|
|
130
184
|
return result;
|
|
131
185
|
};
|
|
132
|
-
export var
|
|
186
|
+
export var setToCriteria = criteria => {
|
|
133
187
|
var result = [];
|
|
134
188
|
criteria.forEach(value => result.push(SearchCriterion[value]));
|
|
135
189
|
return result;
|
|
136
190
|
};
|
|
191
|
+
export var MetaType;
|
|
192
|
+
|
|
193
|
+
(function (MetaType) {
|
|
194
|
+
MetaType["Intrinsic"] = "Intrinsic";
|
|
195
|
+
MetaType["Specification"] = "Specification";
|
|
196
|
+
MetaType["Write"] = "Write";
|
|
197
|
+
MetaType["Request"] = "Request";
|
|
198
|
+
MetaType["Enumerated"] = "Enumerated";
|
|
199
|
+
})(MetaType || (MetaType = {}));
|
|
200
|
+
|
|
201
|
+
export var tagTypes = (api, types) => {
|
|
202
|
+
var typeTags = {};
|
|
203
|
+
Object.entries(types).filter(_ref => {
|
|
204
|
+
var [_, type] = _ref;
|
|
205
|
+
return !type.intrinsic;
|
|
206
|
+
}).forEach(_ref2 => {
|
|
207
|
+
var [name, type] = _ref2;
|
|
208
|
+
var methods = methodRefs(api, type.methodRefs);
|
|
209
|
+
|
|
210
|
+
if (methods.length === 0) {
|
|
211
|
+
var first = firstMethodRef(api, type);
|
|
212
|
+
if (first) methods = [first];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
methods.forEach(method => {
|
|
216
|
+
for (var tag of method.schema.tags) {
|
|
217
|
+
var _list = typeTags[tag];
|
|
218
|
+
|
|
219
|
+
if (!_list) {
|
|
220
|
+
_list = {};
|
|
221
|
+
typeTags[tag] = _list;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
_list[name] = type;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
return typeTags;
|
|
229
|
+
};
|
|
137
230
|
|
|
138
231
|
class MethodResponse {
|
|
139
232
|
constructor(statusCode, mediaType, type, description) {
|
|
@@ -445,8 +538,8 @@ export class Method extends SchemadSymbol {
|
|
|
445
538
|
api.getRequestType(this);
|
|
446
539
|
}
|
|
447
540
|
|
|
448
|
-
Object.entries(this.params).forEach(
|
|
449
|
-
var [, param] =
|
|
541
|
+
Object.entries(this.params).forEach(_ref3 => {
|
|
542
|
+
var [, param] = _ref3;
|
|
450
543
|
var writer = api.mayGetWriteableType(param.type);
|
|
451
544
|
|
|
452
545
|
if (writer) {
|
|
@@ -754,6 +847,14 @@ export class Type {
|
|
|
754
847
|
this.description = this.schema.description || '';
|
|
755
848
|
}
|
|
756
849
|
|
|
850
|
+
get metaType() {
|
|
851
|
+
if (this.intrinsic) return MetaType.Intrinsic;
|
|
852
|
+
if (this instanceof RequestType) return MetaType.Request;
|
|
853
|
+
if (this instanceof WriteType) return MetaType.Write;
|
|
854
|
+
if (this instanceof EnumType) return MetaType.Enumerated;
|
|
855
|
+
return MetaType.Specification;
|
|
856
|
+
}
|
|
857
|
+
|
|
757
858
|
get fullName() {
|
|
758
859
|
return this.name;
|
|
759
860
|
}
|
|
@@ -819,16 +920,16 @@ export class Type {
|
|
|
819
920
|
}
|
|
820
921
|
|
|
821
922
|
get readOnly() {
|
|
822
|
-
return Object.entries(this.properties).every(
|
|
823
|
-
var [, prop] =
|
|
923
|
+
return Object.entries(this.properties).every(_ref4 => {
|
|
924
|
+
var [, prop] = _ref4;
|
|
824
925
|
return prop.readOnly;
|
|
825
926
|
});
|
|
826
927
|
}
|
|
827
928
|
|
|
828
929
|
filterRequiredProps(required) {
|
|
829
930
|
var filteredProps = {};
|
|
830
|
-
Object.entries(this.properties).forEach(
|
|
831
|
-
var [key, prop] =
|
|
931
|
+
Object.entries(this.properties).forEach(_ref5 => {
|
|
932
|
+
var [key, prop] = _ref5;
|
|
832
933
|
var condition = required ? prop.required : !prop.required;
|
|
833
934
|
|
|
834
935
|
if (condition) {
|
|
@@ -847,16 +948,16 @@ export class Type {
|
|
|
847
948
|
}
|
|
848
949
|
|
|
849
950
|
get hasSpecialNeeds() {
|
|
850
|
-
return !!Object.entries(this.properties).find(
|
|
851
|
-
var [, prop] =
|
|
951
|
+
return !!Object.entries(this.properties).find(_ref6 => {
|
|
952
|
+
var [, prop] = _ref6;
|
|
852
953
|
return prop.hasSpecialNeeds;
|
|
853
954
|
});
|
|
854
955
|
}
|
|
855
956
|
|
|
856
957
|
load(api) {
|
|
857
|
-
Object.entries(this.schema.properties || {}).forEach(
|
|
858
|
-
var [propName, propSchema] =
|
|
859
|
-
var propType = api.resolveType(propSchema, undefined, propName);
|
|
958
|
+
Object.entries(this.schema.properties || {}).forEach(_ref7 => {
|
|
959
|
+
var [propName, propSchema] = _ref7;
|
|
960
|
+
var propType = api.resolveType(propSchema, undefined, propName, this.name);
|
|
860
961
|
|
|
861
962
|
if (propType.instanceOf('EnumType')) {
|
|
862
963
|
api.registerEnum(propType, propName);
|
|
@@ -885,12 +986,12 @@ export class Type {
|
|
|
885
986
|
|
|
886
987
|
asHashString() {
|
|
887
988
|
var result = "".concat(this.name, ":");
|
|
888
|
-
Object.entries(this.properties).sort((
|
|
889
|
-
var [a] =
|
|
890
|
-
var [b] =
|
|
989
|
+
Object.entries(this.properties).sort((_ref8, _ref9) => {
|
|
990
|
+
var [a] = _ref8;
|
|
991
|
+
var [b] = _ref9;
|
|
891
992
|
return a.localeCompare(b);
|
|
892
|
-
}).forEach(
|
|
893
|
-
var [, prop] =
|
|
993
|
+
}).forEach(_ref10 => {
|
|
994
|
+
var [, prop] = _ref10;
|
|
894
995
|
result += prop.asHashString() + ':';
|
|
895
996
|
});
|
|
896
997
|
return result;
|
|
@@ -898,8 +999,8 @@ export class Type {
|
|
|
898
999
|
|
|
899
1000
|
isRecursive() {
|
|
900
1001
|
var selfType = this.name;
|
|
901
|
-
return Object.entries(this.properties).some(
|
|
902
|
-
var [, prop] =
|
|
1002
|
+
return Object.entries(this.properties).some(_ref11 => {
|
|
1003
|
+
var [, prop] = _ref11;
|
|
903
1004
|
return prop.type.name === selfType;
|
|
904
1005
|
});
|
|
905
1006
|
}
|
|
@@ -938,8 +1039,8 @@ export class Type {
|
|
|
938
1039
|
}
|
|
939
1040
|
|
|
940
1041
|
if (criteria.has(SearchCriterion.property)) {
|
|
941
|
-
Object.entries(this.properties).forEach(
|
|
942
|
-
var [, prop] =
|
|
1042
|
+
Object.entries(this.properties).forEach(_ref12 => {
|
|
1043
|
+
var [, prop] = _ref12;
|
|
943
1044
|
|
|
944
1045
|
if (this.name !== prop.type.name) {
|
|
945
1046
|
result += prop.searchString(criteria);
|
|
@@ -968,7 +1069,7 @@ export class ArrayType extends Type {
|
|
|
968
1069
|
|
|
969
1070
|
}
|
|
970
1071
|
export class EnumType extends Type {
|
|
971
|
-
constructor(elementType, schema,
|
|
1072
|
+
constructor(elementType, schema, api, typeName, methodName) {
|
|
972
1073
|
super(schema, schema.name);
|
|
973
1074
|
this.elementType = elementType;
|
|
974
1075
|
|
|
@@ -985,27 +1086,36 @@ export class EnumType extends Type {
|
|
|
985
1086
|
}
|
|
986
1087
|
|
|
987
1088
|
if (methodName) {
|
|
988
|
-
this.description = "
|
|
1089
|
+
this.description = "".concat(this.description).concat(this.description ? ' ' : '', "(Enum defined in ").concat(methodName, ")");
|
|
989
1090
|
}
|
|
990
1091
|
|
|
991
|
-
this.name = this.findName(
|
|
1092
|
+
this.name = this.findName(api, typeName, methodName);
|
|
992
1093
|
}
|
|
993
1094
|
|
|
994
|
-
findName(
|
|
1095
|
+
findName(api, typeName, methodName) {
|
|
1096
|
+
var hash = md5(this.asHashString());
|
|
1097
|
+
var enums = api.getEnumList();
|
|
995
1098
|
var name = titleCase(this.name || typeName || 'Enum');
|
|
996
1099
|
|
|
997
|
-
if (name in types) {
|
|
1100
|
+
if (name in api.types) {
|
|
1101
|
+
var matched = enums[hash];
|
|
1102
|
+
|
|
1103
|
+
if ((matched === null || matched === void 0 ? void 0 : matched.name) === name) {
|
|
1104
|
+
return name;
|
|
1105
|
+
}
|
|
1106
|
+
|
|
998
1107
|
var baseName = methodName ? titleCase("".concat(methodName, "_").concat(name)) : name;
|
|
999
1108
|
var newName = baseName;
|
|
1000
1109
|
var i = 0;
|
|
1001
1110
|
|
|
1002
|
-
while (newName in types) {
|
|
1111
|
+
while (newName in api.types) {
|
|
1003
1112
|
newName = "".concat(baseName).concat(++i);
|
|
1004
1113
|
}
|
|
1005
1114
|
|
|
1006
1115
|
name = newName;
|
|
1007
1116
|
}
|
|
1008
1117
|
|
|
1118
|
+
enums[hash] = this;
|
|
1009
1119
|
return name;
|
|
1010
1120
|
}
|
|
1011
1121
|
|
|
@@ -1138,11 +1248,11 @@ export class WriteType extends Type {
|
|
|
1138
1248
|
|
|
1139
1249
|
_defineProperty(WriteType, "readonlyProps", properties => {
|
|
1140
1250
|
var result = [];
|
|
1141
|
-
Object.entries(properties).filter(
|
|
1142
|
-
var [, prop] =
|
|
1251
|
+
Object.entries(properties).filter(_ref21 => {
|
|
1252
|
+
var [, prop] = _ref21;
|
|
1143
1253
|
return prop.readOnly || prop.type.readOnly;
|
|
1144
|
-
}).forEach(
|
|
1145
|
-
var [, prop] =
|
|
1254
|
+
}).forEach(_ref22 => {
|
|
1255
|
+
var [, prop] = _ref22;
|
|
1146
1256
|
return result.push(prop);
|
|
1147
1257
|
});
|
|
1148
1258
|
return result;
|
|
@@ -1164,6 +1274,8 @@ export class ApiModel {
|
|
|
1164
1274
|
|
|
1165
1275
|
_defineProperty(this, "tags", {});
|
|
1166
1276
|
|
|
1277
|
+
_defineProperty(this, "typeTags", {});
|
|
1278
|
+
|
|
1167
1279
|
;
|
|
1168
1280
|
['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));
|
|
1169
1281
|
this.load();
|
|
@@ -1201,14 +1313,14 @@ export class ApiModel {
|
|
|
1201
1313
|
|
|
1202
1314
|
static addMethodToTags(tags, method) {
|
|
1203
1315
|
for (var tag of method.schema.tags) {
|
|
1204
|
-
var
|
|
1316
|
+
var _list2 = tags[tag];
|
|
1205
1317
|
|
|
1206
|
-
if (!
|
|
1207
|
-
|
|
1208
|
-
tags[tag] =
|
|
1318
|
+
if (!_list2) {
|
|
1319
|
+
_list2 = {};
|
|
1320
|
+
tags[tag] = _list2;
|
|
1209
1321
|
}
|
|
1210
1322
|
|
|
1211
|
-
|
|
1323
|
+
_list2[method.name] = method;
|
|
1212
1324
|
}
|
|
1213
1325
|
|
|
1214
1326
|
return tags;
|
|
@@ -1241,8 +1353,8 @@ export class ApiModel {
|
|
|
1241
1353
|
}
|
|
1242
1354
|
|
|
1243
1355
|
if (ApiModel.isMethodSearch(criteria)) {
|
|
1244
|
-
Object.entries(this.methods).forEach(
|
|
1245
|
-
var [, method] =
|
|
1356
|
+
Object.entries(this.methods).forEach(_ref13 => {
|
|
1357
|
+
var [, method] = _ref13;
|
|
1246
1358
|
|
|
1247
1359
|
if (method.search(rx, criteria)) {
|
|
1248
1360
|
methodCount++;
|
|
@@ -1252,8 +1364,8 @@ export class ApiModel {
|
|
|
1252
1364
|
}
|
|
1253
1365
|
|
|
1254
1366
|
if (ApiModel.isTypeSearch(criteria)) {
|
|
1255
|
-
Object.entries(this.types).forEach(
|
|
1256
|
-
var [key, type] =
|
|
1367
|
+
Object.entries(this.types).forEach(_ref14 => {
|
|
1368
|
+
var [key, type] = _ref14;
|
|
1257
1369
|
|
|
1258
1370
|
if (!rx) {
|
|
1259
1371
|
throw Error("".concat(key, " rx undefined"));
|
|
@@ -1339,7 +1451,7 @@ export class ApiModel {
|
|
|
1339
1451
|
}
|
|
1340
1452
|
|
|
1341
1453
|
if (this.schemaHasEnums(schema)) {
|
|
1342
|
-
var num = new EnumType(resolved, schema, this
|
|
1454
|
+
var num = new EnumType(resolved, schema, this, typeName, methodName);
|
|
1343
1455
|
this.registerEnum(num, methodName);
|
|
1344
1456
|
var result = new ArrayType(num, schema);
|
|
1345
1457
|
return result;
|
|
@@ -1349,7 +1461,9 @@ export class ApiModel {
|
|
|
1349
1461
|
}
|
|
1350
1462
|
|
|
1351
1463
|
if (this.schemaHasEnums(schema)) {
|
|
1352
|
-
var
|
|
1464
|
+
var _resolved = this.resolveType(schema.type, style, typeName, methodName);
|
|
1465
|
+
|
|
1466
|
+
var _result = new EnumType(_resolved, schema, this, typeName, methodName);
|
|
1353
1467
|
|
|
1354
1468
|
if (_result) {
|
|
1355
1469
|
return this.registerEnum(_result, methodName);
|
|
@@ -1391,23 +1505,26 @@ export class ApiModel {
|
|
|
1391
1505
|
|
|
1392
1506
|
registerEnum(type, methodName) {
|
|
1393
1507
|
if (!(type instanceof EnumType)) return type;
|
|
1394
|
-
var hash = md5(type.asHashString());
|
|
1395
1508
|
|
|
1396
|
-
if (
|
|
1397
|
-
|
|
1509
|
+
if (type.name in this.types) {
|
|
1510
|
+
var hash = md5(type.asHashString());
|
|
1511
|
+
var matched = this.enumTypes[hash];
|
|
1512
|
+
|
|
1513
|
+
if ((matched === null || matched === void 0 ? void 0 : matched.name) === type.name) {
|
|
1514
|
+
return this.enumTypes[hash];
|
|
1515
|
+
}
|
|
1398
1516
|
}
|
|
1399
1517
|
|
|
1400
1518
|
if (methodName) {
|
|
1401
|
-
var
|
|
1519
|
+
var _method2 = this.methods[methodName];
|
|
1402
1520
|
|
|
1403
|
-
if (
|
|
1404
|
-
|
|
1521
|
+
if (_method2) {
|
|
1522
|
+
_method2.types.add(type.name);
|
|
1405
1523
|
|
|
1406
|
-
|
|
1524
|
+
_method2.customTypes.add(type.name);
|
|
1407
1525
|
}
|
|
1408
1526
|
}
|
|
1409
1527
|
|
|
1410
|
-
this.enumTypes[hash] = type;
|
|
1411
1528
|
this.types[type.name] = type;
|
|
1412
1529
|
return type;
|
|
1413
1530
|
}
|
|
@@ -1429,6 +1546,10 @@ export class ApiModel {
|
|
|
1429
1546
|
return result;
|
|
1430
1547
|
}
|
|
1431
1548
|
|
|
1549
|
+
getEnumList() {
|
|
1550
|
+
return this.enumTypes;
|
|
1551
|
+
}
|
|
1552
|
+
|
|
1432
1553
|
makeWriteableType(hash, type) {
|
|
1433
1554
|
var writer = new WriteType(this, type);
|
|
1434
1555
|
this.types[writer.name] = writer;
|
|
@@ -1442,8 +1563,9 @@ export class ApiModel {
|
|
|
1442
1563
|
if (type.intrinsic) return undefined;
|
|
1443
1564
|
if ((_type$elementType = type.elementType) !== null && _type$elementType !== void 0 && _type$elementType.intrinsic) return undefined;
|
|
1444
1565
|
if (type instanceof WriteType) return type;
|
|
1445
|
-
|
|
1446
|
-
|
|
1566
|
+
if (!anyWriter(this, type)) return undefined;
|
|
1567
|
+
var props = Object.entries(type.properties).map(_ref15 => {
|
|
1568
|
+
var [, prop] = _ref15;
|
|
1447
1569
|
return prop;
|
|
1448
1570
|
});
|
|
1449
1571
|
if (props.length === 0) return undefined;
|
|
@@ -1472,8 +1594,8 @@ export class ApiModel {
|
|
|
1472
1594
|
}
|
|
1473
1595
|
|
|
1474
1596
|
loadDynamicTypes() {
|
|
1475
|
-
Object.entries(this.methods).forEach(
|
|
1476
|
-
var [, method] =
|
|
1597
|
+
Object.entries(this.methods).forEach(_ref16 => {
|
|
1598
|
+
var [, method] = _ref16;
|
|
1477
1599
|
method.makeTypes(this);
|
|
1478
1600
|
});
|
|
1479
1601
|
}
|
|
@@ -1493,14 +1615,19 @@ export class ApiModel {
|
|
|
1493
1615
|
this.methods = this.sortList(this.methods);
|
|
1494
1616
|
this.types = this.sortList(this.types);
|
|
1495
1617
|
this.tags = this.sortList(this.tags);
|
|
1618
|
+
this.typeTags = this.sortList(this.typeTags);
|
|
1619
|
+
var typeKeys = Object.keys(this.typeTags);
|
|
1620
|
+
typeKeys.forEach(key => {
|
|
1621
|
+
this.typeTags[key] = this.sortList(this.typeTags[key]);
|
|
1622
|
+
});
|
|
1496
1623
|
}
|
|
1497
1624
|
|
|
1498
1625
|
load() {
|
|
1499
1626
|
var _this$spec3, _this$spec3$component, _this$spec4;
|
|
1500
1627
|
|
|
1501
1628
|
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) {
|
|
1502
|
-
Object.entries(this.spec.components.schemas).forEach(
|
|
1503
|
-
var [name, schema] =
|
|
1629
|
+
Object.entries(this.spec.components.schemas).forEach(_ref17 => {
|
|
1630
|
+
var [name, schema] = _ref17;
|
|
1504
1631
|
var t = new Type(schema, name);
|
|
1505
1632
|
this.types[name] = t;
|
|
1506
1633
|
this.refs["#/components/schemas/".concat(name)] = t;
|
|
@@ -1524,8 +1651,8 @@ export class ApiModel {
|
|
|
1524
1651
|
}
|
|
1525
1652
|
|
|
1526
1653
|
if ((_this$spec4 = this.spec) !== null && _this$spec4 !== void 0 && _this$spec4.paths) {
|
|
1527
|
-
Object.entries(this.spec.paths).forEach(
|
|
1528
|
-
var [path, schema] =
|
|
1654
|
+
Object.entries(this.spec.paths).forEach(_ref18 => {
|
|
1655
|
+
var [path, schema] = _ref18;
|
|
1529
1656
|
var methods = this.loadMethods(path, schema);
|
|
1530
1657
|
methods.forEach(method => {
|
|
1531
1658
|
this.methods[method.name] = method;
|
|
@@ -1534,6 +1661,7 @@ export class ApiModel {
|
|
|
1534
1661
|
}
|
|
1535
1662
|
|
|
1536
1663
|
this.loadDynamicTypes();
|
|
1664
|
+
this.typeTags = tagTypes(this, this.types);
|
|
1537
1665
|
this.sortLists();
|
|
1538
1666
|
}
|
|
1539
1667
|
|
|
@@ -1546,10 +1674,10 @@ export class ApiModel {
|
|
|
1546
1674
|
var params = this.methodParameters(opSchema);
|
|
1547
1675
|
var body = this.requestBody(opSchema.requestBody);
|
|
1548
1676
|
|
|
1549
|
-
var
|
|
1677
|
+
var _method3 = new Method(this, httpMethod, endpoint, opSchema, params, responses, body);
|
|
1550
1678
|
|
|
1551
|
-
methods.push(
|
|
1552
|
-
this.tagMethod(
|
|
1679
|
+
methods.push(_method3);
|
|
1680
|
+
this.tagMethod(_method3);
|
|
1553
1681
|
}
|
|
1554
1682
|
};
|
|
1555
1683
|
|
|
@@ -1563,13 +1691,13 @@ export class ApiModel {
|
|
|
1563
1691
|
|
|
1564
1692
|
methodResponses(schema) {
|
|
1565
1693
|
var responses = [];
|
|
1566
|
-
Object.entries(schema.responses).forEach(
|
|
1567
|
-
var [statusCode, contentSchema] =
|
|
1694
|
+
Object.entries(schema.responses).forEach(_ref19 => {
|
|
1695
|
+
var [statusCode, contentSchema] = _ref19;
|
|
1568
1696
|
var desc = contentSchema.description || '';
|
|
1569
1697
|
|
|
1570
1698
|
if (contentSchema.content) {
|
|
1571
|
-
Object.entries(contentSchema.content).forEach(
|
|
1572
|
-
var [mediaType, response] =
|
|
1699
|
+
Object.entries(contentSchema.content).forEach(_ref20 => {
|
|
1700
|
+
var [mediaType, response] = _ref20;
|
|
1573
1701
|
responses.push(new MethodResponse(parseInt(statusCode, 10), mediaType, this.resolveType(response.schema || {}), desc));
|
|
1574
1702
|
});
|
|
1575
1703
|
} else if (statusCode === '204') {
|