yapi-apifox-to-typescript 4.2.3 → 5.0.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.
@@ -1,496 +1,282 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
-
5
- exports.__esModule = true;
6
- exports.swaggerJsonToYApiData = swaggerJsonToYApiData;
7
-
8
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
-
10
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
-
12
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
-
14
- var _dayjs = _interopRequireDefault(require("dayjs"));
15
-
16
- var _swaggerClient = _interopRequireDefault(require("swagger-client"));
17
-
18
- var _vtils = require("vtils");
19
-
20
- // @ts-nocheck
21
- // ref: https://github.com/YMFE/yapi/blob/master/exts/yapi-plugin-import-swagger/run.js
22
- var SwaggerData, isOAS3;
23
-
1
+ const require_runtime = require("./_virtual/_rolldown/runtime.js");
2
+ const require_mini_ut = require("./mini-ut.js");
3
+ let dayjs = require("dayjs");
4
+ dayjs = require_runtime.__toESM(dayjs);
5
+ let swagger_client = require("swagger-client");
6
+ swagger_client = require_runtime.__toESM(swagger_client);
7
+ //#region src/swaggerJsonToYApiData.ts
8
+ var SwaggerData;
9
+ var isOAS3;
24
10
  function handlePath(path) {
25
- if (path === '/') return path;
26
-
27
- if (path.charAt(0) !== '/') {
28
- path = "/" + path;
29
- }
30
-
31
- if (path.charAt(path.length - 1) === '/') {
32
- path = path.substr(0, path.length - 1);
33
- }
34
-
35
- return path;
11
+ if (path === "/") return path;
12
+ if (path.charAt(0) !== "/") path = `/${path}`;
13
+ if (path.charAt(path.length - 1) === "/") path = path.substr(0, path.length - 1);
14
+ return path;
36
15
  }
37
-
38
16
  function openapi2swagger(data) {
39
- data.swagger = '2.0';
40
- (0, _vtils.each)(data.paths, function (apis) {
41
- (0, _vtils.each)(apis, function (api) {
42
- (0, _vtils.each)(api.responses, function (res) {
43
- if (res.content && res.content['application/json'] && typeof res.content['application/json'] === 'object') {
44
- Object.assign(res, res.content['application/json']);
45
- delete res.content;
46
- }
47
-
48
- if (res.content && res.content['application/hal+json'] && typeof res.content['application/hal+json'] === 'object') {
49
- Object.assign(res, res.content['application/hal+json']);
50
- delete res.content;
51
- }
52
-
53
- if (res.content && res.content['*/*'] && typeof res.content['*/*'] === 'object') {
54
- Object.assign(res, res.content['*/*']);
55
- delete res.content;
56
- }
57
- });
58
-
59
- if (api.requestBody) {
60
- if (!api.parameters) api.parameters = [];
61
- var body = {
62
- type: 'object',
63
- name: 'body',
64
- in: 'body'
65
- };
66
-
67
- try {
68
- body.schema = api.requestBody.content['application/json'].schema;
69
- } catch (e) {
70
- body.schema = {};
71
- }
72
-
73
- api.parameters.push(body);
74
- }
75
- });
76
- });
77
- return data;
78
- }
79
-
80
- function handleSwaggerData(_x) {
81
- return _handleSwaggerData.apply(this, arguments);
17
+ data.swagger = "2.0";
18
+ require_mini_ut.each(data.paths, (apis) => {
19
+ require_mini_ut.each(apis, (api) => {
20
+ require_mini_ut.each(api.responses, (res) => {
21
+ if (res.content && res.content["application/json"] && typeof res.content["application/json"] === "object") {
22
+ Object.assign(res, res.content["application/json"]);
23
+ delete res.content;
24
+ }
25
+ if (res.content && res.content["application/hal+json"] && typeof res.content["application/hal+json"] === "object") {
26
+ Object.assign(res, res.content["application/hal+json"]);
27
+ delete res.content;
28
+ }
29
+ if (res.content && res.content["*/*"] && typeof res.content["*/*"] === "object") {
30
+ Object.assign(res, res.content["*/*"]);
31
+ delete res.content;
32
+ }
33
+ });
34
+ if (api.requestBody) {
35
+ if (!api.parameters) api.parameters = [];
36
+ const body = {
37
+ type: "object",
38
+ name: "body",
39
+ in: "body"
40
+ };
41
+ try {
42
+ body.schema = api.requestBody.content["application/json"].schema;
43
+ } catch (e) {
44
+ body.schema = {};
45
+ }
46
+ api.parameters.push(body);
47
+ }
48
+ });
49
+ });
50
+ return data;
82
51
  }
83
-
84
- function _handleSwaggerData() {
85
- _handleSwaggerData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(res) {
86
- return _regenerator.default.wrap(function _callee$(_context) {
87
- while (1) {
88
- switch (_context.prev = _context.next) {
89
- case 0:
90
- return _context.abrupt("return", new Promise(function (resolve) {
91
- var data = (0, _swaggerClient.default)({
92
- spec: res
93
- });
94
- data.then(function (res) {
95
- resolve(res.spec);
96
- });
97
- }));
98
-
99
- case 1:
100
- case "end":
101
- return _context.stop();
102
- }
103
- }
104
- }, _callee);
105
- }));
106
- return _handleSwaggerData.apply(this, arguments);
52
+ async function handleSwaggerData(res) {
53
+ return new Promise((resolve) => {
54
+ (0, swagger_client.default)({ spec: res }).then((res) => {
55
+ resolve(res.spec);
56
+ });
57
+ });
107
58
  }
108
-
109
- function run(_x2) {
110
- return _run.apply(this, arguments);
59
+ async function run(res) {
60
+ const interfaceData = {
61
+ apis: [],
62
+ cats: [],
63
+ basePath: "",
64
+ swaggerData: {}
65
+ };
66
+ if (typeof res === "string" && res) try {
67
+ res = JSON.parse(res);
68
+ } catch (e) {
69
+ console.error("json 解析出错", e.message);
70
+ }
71
+ isOAS3 = res.openapi && String(res.openapi).startsWith("3.");
72
+ if (isOAS3) res = openapi2swagger(res);
73
+ res = await handleSwaggerData(res);
74
+ SwaggerData = res;
75
+ interfaceData.swaggerData = SwaggerData;
76
+ interfaceData.basePath = res.basePath || "";
77
+ if (res.tags && Array.isArray(res.tags)) res.tags.forEach((tag) => {
78
+ interfaceData.cats.push({
79
+ name: tag.name,
80
+ desc: tag.description
81
+ });
82
+ });
83
+ else res.tags = [];
84
+ require_mini_ut.each(res.paths, (apis, path) => {
85
+ delete apis.parameters;
86
+ require_mini_ut.each(apis, (api, method) => {
87
+ api.path = path;
88
+ api.method = method;
89
+ let data = null;
90
+ try {
91
+ data = handleSwagger(api, res.tags);
92
+ if (data.catname) {
93
+ if (!require_mini_ut.find(interfaceData.cats, (item) => item.name === data.catname)) {
94
+ if (res.tags.length === 0) interfaceData.cats.push({
95
+ name: data.catname,
96
+ desc: data.catname
97
+ });
98
+ }
99
+ }
100
+ } catch (err) {
101
+ data = null;
102
+ }
103
+ if (data) interfaceData.apis.push(data);
104
+ });
105
+ });
106
+ interfaceData.cats = interfaceData.cats.filter((catData) => {
107
+ const catName = catData.name;
108
+ return require_mini_ut.find(interfaceData.apis, (apiData) => {
109
+ return apiData.catname === catName;
110
+ });
111
+ });
112
+ return interfaceData;
111
113
  }
112
-
113
- function _run() {
114
- _run = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2(res) {
115
- var interfaceData;
116
- return _regenerator.default.wrap(function _callee2$(_context2) {
117
- while (1) {
118
- switch (_context2.prev = _context2.next) {
119
- case 0:
120
- interfaceData = {
121
- apis: [],
122
- cats: [],
123
- basePath: '',
124
- swaggerData: {}
125
- };
126
-
127
- if (typeof res === 'string' && res) {
128
- try {
129
- res = JSON.parse(res);
130
- } catch (e) {
131
- console.error('json 解析出错', e.message);
132
- }
133
- }
134
-
135
- isOAS3 = res.openapi && String(res.openapi).startsWith('3.');
136
-
137
- if (isOAS3) {
138
- res = openapi2swagger(res);
139
- }
140
-
141
- _context2.next = 6;
142
- return handleSwaggerData(res);
143
-
144
- case 6:
145
- res = _context2.sent;
146
- SwaggerData = res;
147
- interfaceData.swaggerData = SwaggerData;
148
- interfaceData.basePath = res.basePath || '';
149
-
150
- if (res.tags && Array.isArray(res.tags)) {
151
- res.tags.forEach(function (tag) {
152
- interfaceData.cats.push({
153
- name: tag.name,
154
- desc: tag.description
155
- });
156
- });
157
- } else {
158
- res.tags = [];
159
- }
160
-
161
- (0, _vtils.each)(res.paths, function (apis, path) {
162
- // parameters is common parameters, not a method
163
- delete apis.parameters;
164
- (0, _vtils.each)(apis, function (api, method) {
165
- api.path = path;
166
- api.method = method;
167
- var data = null;
168
-
169
- try {
170
- data = handleSwagger(api, res.tags);
171
-
172
- if (data.catname) {
173
- if (!(0, _vtils.find)(interfaceData.cats, function (item) {
174
- return item.name === data.catname;
175
- })) {
176
- if (res.tags.length === 0) {
177
- interfaceData.cats.push({
178
- name: data.catname,
179
- desc: data.catname
180
- });
181
- }
182
- }
183
- }
184
- } catch (err) {
185
- data = null;
186
- }
187
-
188
- if (data) {
189
- interfaceData.apis.push(data);
190
- }
191
- });
192
- });
193
- interfaceData.cats = interfaceData.cats.filter(function (catData) {
194
- var catName = catData.name;
195
- return (0, _vtils.find)(interfaceData.apis, function (apiData) {
196
- return apiData.catname === catName;
197
- });
198
- });
199
- return _context2.abrupt("return", interfaceData);
200
-
201
- case 14:
202
- case "end":
203
- return _context2.stop();
204
- }
205
- }
206
- }, _callee2);
207
- }));
208
- return _run.apply(this, arguments);
114
+ function handleSwagger(data, originTags = []) {
115
+ const api = {};
116
+ api.method = data.method.toUpperCase();
117
+ api.title = data.summary || data.path;
118
+ api.desc = data.description;
119
+ api.catname = null;
120
+ if (data.tags && Array.isArray(data.tags)) {
121
+ api.tag = data.tags;
122
+ for (let i = 0; i < data.tags.length; i++) {
123
+ if (/v[0-9.]+/.test(data.tags[i])) continue;
124
+ if (originTags.length > 0 && require_mini_ut.find(originTags, (item) => {
125
+ return item.name === data.tags[i];
126
+ })) {
127
+ api.catname = data.tags[i];
128
+ break;
129
+ }
130
+ if (originTags.length === 0) {
131
+ api.catname = data.tags[i];
132
+ break;
133
+ }
134
+ }
135
+ }
136
+ api.path = handlePath(data.path);
137
+ api.req_params = [];
138
+ api.req_body_form = [];
139
+ api.req_headers = [];
140
+ api.req_query = [];
141
+ api.req_body_type = "raw";
142
+ api.res_body_type = "raw";
143
+ if (data.produces && data.produces.indexOf("application/json") > -1) {
144
+ api.res_body_type = "json";
145
+ api.res_body_is_json_schema = true;
146
+ }
147
+ if (data.consumes && Array.isArray(data.consumes)) {
148
+ if (data.consumes.indexOf("application/x-www-form-urlencoded") > -1 || data.consumes.indexOf("multipart/form-data") > -1) api.req_body_type = "form";
149
+ else if (data.consumes.indexOf("application/json") > -1) {
150
+ api.req_body_type = "json";
151
+ api.req_body_is_json_schema = true;
152
+ }
153
+ }
154
+ api.res_body = handleResponse(data.responses);
155
+ try {
156
+ JSON.parse(api.res_body);
157
+ api.res_body_type = "json";
158
+ api.res_body_is_json_schema = true;
159
+ } catch (e) {
160
+ api.res_body_type = "raw";
161
+ }
162
+ function simpleJsonPathParse(key, json) {
163
+ if (!key || typeof key !== "string" || key.indexOf("#/") !== 0 || key.length <= 2) return null;
164
+ let keys = key.substr(2).split("/");
165
+ keys = keys.filter((item) => {
166
+ return item;
167
+ });
168
+ for (let i = 0, l = keys.length; i < l; i++) try {
169
+ json = json[keys[i]];
170
+ } catch (e) {
171
+ json = "";
172
+ break;
173
+ }
174
+ return json;
175
+ }
176
+ if (data.parameters && Array.isArray(data.parameters)) data.parameters.forEach((param) => {
177
+ if (param && typeof param === "object" && param.$ref) param = simpleJsonPathParse(param.$ref, { parameters: SwaggerData.parameters });
178
+ const defaultParam = {
179
+ name: param.name,
180
+ desc: param.description,
181
+ required: param.required ? "1" : "0"
182
+ };
183
+ if (param.in) switch (param.in) {
184
+ case "path":
185
+ defaultParam.type = param.type;
186
+ api.req_params.push(defaultParam);
187
+ break;
188
+ case "query":
189
+ defaultParam.type = param.type;
190
+ api.req_query.push(defaultParam);
191
+ break;
192
+ case "body":
193
+ handleBodyPamras(param.schema, api);
194
+ break;
195
+ case "formData":
196
+ defaultParam.type = param.type === "file" ? "file" : "text";
197
+ if (param.example) defaultParam.example = param.example;
198
+ api.req_body_form.push(defaultParam);
199
+ break;
200
+ case "header": api.req_headers.push(defaultParam);
201
+ }
202
+ else api.req_query.push(defaultParam);
203
+ });
204
+ return api;
209
205
  }
210
-
211
- function handleSwagger(data, originTags) {
212
- if (originTags === void 0) {
213
- originTags = [];
214
- }
215
-
216
- var api = {}; //处理基本信息
217
-
218
- api.method = data.method.toUpperCase();
219
- api.title = data.summary || data.path;
220
- api.desc = data.description;
221
- api.catname = null;
222
-
223
- if (data.tags && Array.isArray(data.tags)) {
224
- api.tag = data.tags;
225
-
226
- var _loop = function _loop(i) {
227
- if (/v[0-9.]+/.test(data.tags[i])) {
228
- return "continue";
229
- } // 如果根路径有 tags,使用根路径 tags,不使用每个接口定义的 tag 做完分类
230
-
231
-
232
- if (originTags.length > 0 && (0, _vtils.find)(originTags, function (item) {
233
- return item.name === data.tags[i];
234
- })) {
235
- api.catname = data.tags[i];
236
- return "break";
237
- }
238
-
239
- if (originTags.length === 0) {
240
- api.catname = data.tags[i];
241
- return "break";
242
- }
243
- };
244
-
245
- for (var i = 0; i < data.tags.length; i++) {
246
- var _ret = _loop(i);
247
-
248
- if (_ret === "continue") continue;
249
- if (_ret === "break") break;
250
- }
251
- }
252
-
253
- api.path = handlePath(data.path);
254
- api.req_params = [];
255
- api.req_body_form = [];
256
- api.req_headers = [];
257
- api.req_query = [];
258
- api.req_body_type = 'raw';
259
- api.res_body_type = 'raw';
260
-
261
- if (data.produces && data.produces.indexOf('application/json') > -1) {
262
- api.res_body_type = 'json';
263
- api.res_body_is_json_schema = true;
264
- }
265
-
266
- if (data.consumes && Array.isArray(data.consumes)) {
267
- if (data.consumes.indexOf('application/x-www-form-urlencoded') > -1 || data.consumes.indexOf('multipart/form-data') > -1) {
268
- api.req_body_type = 'form';
269
- } else if (data.consumes.indexOf('application/json') > -1) {
270
- api.req_body_type = 'json';
271
- api.req_body_is_json_schema = true;
272
- }
273
- } //处理response
274
-
275
-
276
- api.res_body = handleResponse(data.responses);
277
-
278
- try {
279
- JSON.parse(api.res_body);
280
- api.res_body_type = 'json';
281
- api.res_body_is_json_schema = true;
282
- } catch (e) {
283
- api.res_body_type = 'raw';
284
- } //处理参数
285
-
286
-
287
- function simpleJsonPathParse(key, json) {
288
- if (!key || typeof key !== 'string' || key.indexOf('#/') !== 0 || key.length <= 2) {
289
- return null;
290
- }
291
-
292
- var keys = key.substr(2).split('/');
293
- keys = keys.filter(function (item) {
294
- return item;
295
- });
296
-
297
- for (var _i = 0, l = keys.length; _i < l; _i++) {
298
- try {
299
- json = json[keys[_i]];
300
- } catch (e) {
301
- json = '';
302
- break;
303
- }
304
- }
305
-
306
- return json;
307
- }
308
-
309
- if (data.parameters && Array.isArray(data.parameters)) {
310
- data.parameters.forEach(function (param) {
311
- if (param && typeof param === 'object' && param.$ref) {
312
- param = simpleJsonPathParse(param.$ref, {
313
- parameters: SwaggerData.parameters
314
- });
315
- }
316
-
317
- var defaultParam = {
318
- name: param.name,
319
- desc: param.description,
320
- required: param.required ? '1' : '0'
321
- };
322
-
323
- if (param.in) {
324
- switch (param.in) {
325
- case 'path':
326
- defaultParam.type = param.type;
327
- api.req_params.push(defaultParam);
328
- break;
329
-
330
- case 'query':
331
- defaultParam.type = param.type;
332
- api.req_query.push(defaultParam);
333
- break;
334
-
335
- case 'body':
336
- handleBodyPamras(param.schema, api);
337
- break;
338
-
339
- case 'formData':
340
- defaultParam.type = param.type === 'file' ? 'file' : 'text';
341
-
342
- if (param.example) {
343
- defaultParam.example = param.example;
344
- }
345
-
346
- api.req_body_form.push(defaultParam);
347
- break;
348
-
349
- case 'header':
350
- api.req_headers.push(defaultParam);
351
- break;
352
-
353
- default:
354
- break;
355
- }
356
- } else {
357
- api.req_query.push(defaultParam);
358
- }
359
- });
360
- }
361
-
362
- return api;
363
- }
364
-
365
206
  function isJson(json) {
366
- try {
367
- return JSON.parse(json);
368
- } catch (e) {
369
- return false;
370
- }
207
+ try {
208
+ return JSON.parse(json);
209
+ } catch (e) {
210
+ return false;
211
+ }
371
212
  }
372
-
373
213
  function handleBodyPamras(data, api) {
374
- api.req_body_other = JSON.stringify(data, null, 2);
375
-
376
- if (isJson(api.req_body_other)) {
377
- api.req_body_type = 'json';
378
- api.req_body_is_json_schema = true;
379
- }
214
+ api.req_body_other = JSON.stringify(data, null, 2);
215
+ if (isJson(api.req_body_other)) {
216
+ api.req_body_type = "json";
217
+ api.req_body_is_json_schema = true;
218
+ }
380
219
  }
381
-
382
220
  function handleResponse(api) {
383
- var res_body = '';
384
-
385
- if (!api || typeof api !== 'object') {
386
- return res_body;
387
- }
388
-
389
- var codes = Object.keys(api);
390
- var curCode;
391
-
392
- if (codes.length > 0) {
393
- if (codes.indexOf('200') > -1) {
394
- curCode = '200';
395
- } else curCode = codes[0];
396
-
397
- var res = api[curCode];
398
-
399
- if (res && typeof res === 'object') {
400
- if (res.schema) {
401
- res_body = JSON.stringify(res.schema, null, 2);
402
- } else if (res.description) {
403
- res_body = res.description;
404
- }
405
- } else if (typeof res === 'string') {
406
- res_body = res;
407
- } else {
408
- res_body = '';
409
- }
410
- } else {
411
- res_body = '';
412
- }
413
-
414
- return res_body;
221
+ let res_body = "";
222
+ if (!api || typeof api !== "object") return res_body;
223
+ const codes = Object.keys(api);
224
+ let curCode;
225
+ if (codes.length > 0) {
226
+ if (codes.indexOf("200") > -1) curCode = "200";
227
+ else curCode = codes[0];
228
+ const res = api[curCode];
229
+ if (res && typeof res === "object") {
230
+ if (res.schema) res_body = JSON.stringify(res.schema, null, 2);
231
+ else if (res.description) res_body = res.description;
232
+ } else if (typeof res === "string") res_body = res;
233
+ else res_body = "";
234
+ } else res_body = "";
235
+ return res_body;
415
236
  }
416
-
417
- function swaggerJsonToYApiData(_x3) {
418
- return _swaggerJsonToYApiData.apply(this, arguments);
237
+ async function swaggerJsonToYApiData(data) {
238
+ const yapiData = await run(data);
239
+ if (!yapiData.cats.length) {
240
+ yapiData.cats = [{
241
+ name: "default",
242
+ desc: "default"
243
+ }];
244
+ yapiData.apis.forEach((api) => {
245
+ api.catname = "default";
246
+ });
247
+ }
248
+ const currentTime = (0, dayjs.default)().unix();
249
+ const project = {
250
+ _id: 0,
251
+ name: yapiData.swaggerData.info.title,
252
+ desc: yapiData.swaggerData.info.description || "",
253
+ basepath: yapiData.swaggerData.basePath || "",
254
+ tag: [],
255
+ env: [{
256
+ name: "local",
257
+ domain: `${yapiData.swaggerData.schemes?.[0] || "http"}://${yapiData.swaggerData.host || "127.0.0.1"}`
258
+ }]
259
+ };
260
+ const cats = yapiData.cats.map((cat, index) => ({
261
+ _id: index + 1,
262
+ name: cat.name,
263
+ desc: cat.desc,
264
+ add_time: currentTime,
265
+ up_time: currentTime
266
+ }));
267
+ return {
268
+ project,
269
+ cats,
270
+ interfaces: yapiData.apis.map((api, index) => ({
271
+ ...api,
272
+ _id: index + 1,
273
+ project_id: 0,
274
+ catid: cats.find((cat) => cat.name === api.catname)?._id || -1,
275
+ tag: api.tag || [],
276
+ add_time: currentTime,
277
+ up_time: currentTime
278
+ }))
279
+ };
419
280
  }
420
-
421
- function _swaggerJsonToYApiData() {
422
- _swaggerJsonToYApiData = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(data) {
423
- var _yapiData$swaggerData;
424
-
425
- var yapiData, currentTime, project, cats, interfaces;
426
- return _regenerator.default.wrap(function _callee3$(_context3) {
427
- while (1) {
428
- switch (_context3.prev = _context3.next) {
429
- case 0:
430
- _context3.next = 2;
431
- return run(data);
432
-
433
- case 2:
434
- yapiData = _context3.sent;
435
-
436
- // 兼容没有分类的情况
437
- if (!yapiData.cats.length) {
438
- yapiData.cats = [{
439
- name: 'default',
440
- desc: 'default'
441
- }];
442
- yapiData.apis.forEach(function (api) {
443
- api.catname = 'default';
444
- });
445
- }
446
-
447
- currentTime = (0, _dayjs.default)().unix();
448
- project = {
449
- _id: 0,
450
- name: yapiData.swaggerData.info.title,
451
- desc: yapiData.swaggerData.info.description || '',
452
- basepath: yapiData.swaggerData.basePath || '',
453
- tag: [],
454
- env: [{
455
- name: 'local',
456
- domain: (((_yapiData$swaggerData = yapiData.swaggerData.schemes) == null ? void 0 : _yapiData$swaggerData[0]) || 'http') + "://" + (yapiData.swaggerData.host || '127.0.0.1')
457
- }]
458
- };
459
- cats = yapiData.cats.map(function (cat, index) {
460
- return {
461
- _id: index + 1,
462
- name: cat.name,
463
- desc: cat.desc,
464
- add_time: currentTime,
465
- up_time: currentTime
466
- };
467
- });
468
- interfaces = yapiData.apis.map(function (api, index) {
469
- var _cats$find;
470
-
471
- return (0, _extends2.default)({}, api, {
472
- _id: index + 1,
473
- project_id: 0,
474
- catid: ((_cats$find = cats.find(function (cat) {
475
- return cat.name === api.catname;
476
- })) == null ? void 0 : _cats$find._id) || -1,
477
- tag: api.tag || [],
478
- add_time: currentTime,
479
- up_time: currentTime
480
- });
481
- });
482
- return _context3.abrupt("return", {
483
- project: project,
484
- cats: cats,
485
- interfaces: interfaces
486
- });
487
-
488
- case 9:
489
- case "end":
490
- return _context3.stop();
491
- }
492
- }
493
- }, _callee3);
494
- }));
495
- return _swaggerJsonToYApiData.apply(this, arguments);
496
- }
281
+ //#endregion
282
+ exports.swaggerJsonToYApiData = swaggerJsonToYApiData;