echoapi-converter 0.0.26 → 0.0.27

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.
Files changed (2) hide show
  1. package/dist/index.js +120 -44
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -74,6 +74,28 @@ const DEFAULT_AUTH = {
74
74
  token: "",
75
75
  disableHeaderEncoding: false,
76
76
  },
77
+ oauth2: {
78
+ addTokenTo: 'header',
79
+ headerPrefix: 'Bearer',
80
+ access_token: '',
81
+ grant_type: 'authorization_code',
82
+ redirect_uri: '',
83
+ authUrl: '',
84
+ accessTokenUrl: '',
85
+ clientId: '',
86
+ clientSecret: '',
87
+ username: '',
88
+ password: '',
89
+ challengeAlgorithm: 'S256',
90
+ code_verifier: 'Bearer',
91
+ scope: '',
92
+ state: '',
93
+ client_authentication: 'header',
94
+ refreshTokenUrl: '',
95
+ authRequestParams: [],
96
+ tokenRequestParams: [],
97
+ refreshRequestParams: [],
98
+ },
77
99
  hawk: {
78
100
  authId: "",
79
101
  authKey: "",
@@ -1488,8 +1510,8 @@ class SwaggerToApipost {
1488
1510
  }
1489
1511
  }
1490
1512
  handlePathV3(path, pathItem, tags) {
1513
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1491
1514
  return __awaiter(this, void 0, void 0, function* () {
1492
- var _a, _b, _c, _d, _e, _f, _g, _h;
1493
1515
  let url = path;
1494
1516
  for (const method in pathItem) {
1495
1517
  const swaggerApi = pathItem[method];
@@ -1906,8 +1928,8 @@ class SwaggerToApipost {
1906
1928
  });
1907
1929
  }
1908
1930
  handlePathsV3(json) {
1931
+ var _a, _b;
1909
1932
  return __awaiter(this, void 0, void 0, function* () {
1910
- var _a, _b;
1911
1933
  try {
1912
1934
  const paths = ((_a = json === null || json === void 0 ? void 0 : json.openapi) === null || _a === void 0 ? void 0 : _a.paths) || json.paths;
1913
1935
  const tags = ((_b = json === null || json === void 0 ? void 0 : json.openapi) === null || _b === void 0 ? void 0 : _b.tags) || json.tags;
@@ -1939,8 +1961,8 @@ class SwaggerToApipost {
1939
1961
  }
1940
1962
  }
1941
1963
  handlePath(path, pathItem, tags) {
1964
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1942
1965
  return __awaiter(this, void 0, void 0, function* () {
1943
- var _a, _b, _c, _d, _e, _f, _g, _h;
1944
1966
  let url = path;
1945
1967
  url = decodeURI(this.basePath + url);
1946
1968
  url = fixUrlPath(url);
@@ -2347,8 +2369,8 @@ class SwaggerToApipost {
2347
2369
  catch (err) { }
2348
2370
  });
2349
2371
  }
2350
- convert(json_1) {
2351
- return __awaiter(this, arguments, void 0, function* (json, options = null) {
2372
+ convert(json, options = null) {
2373
+ return __awaiter(this, void 0, void 0, function* () {
2352
2374
  this.clear();
2353
2375
  try {
2354
2376
  if (options && options instanceof Object) {
@@ -2729,7 +2751,7 @@ class ApidocToApipost {
2729
2751
  }
2730
2752
 
2731
2753
  // @ts-nocheck
2732
- const throwResult = (status, message, data) => {
2754
+ const throwResult = (status, message, data = "") => {
2733
2755
  return {
2734
2756
  status,
2735
2757
  message,
@@ -3222,7 +3244,7 @@ class ApifoxToApipost {
3222
3244
  return [];
3223
3245
  }
3224
3246
  completionApiRequestAuth(auth) {
3225
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42;
3247
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52;
3226
3248
  const customAuth = {};
3227
3249
  if ((auth === null || auth === void 0 ? void 0 : auth.type) === "apikey") {
3228
3250
  customAuth["type"] = "kv";
@@ -3282,65 +3304,90 @@ class ApifoxToApipost {
3282
3304
  : false,
3283
3305
  };
3284
3306
  }
3307
+ else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "oauth2") {
3308
+ customAuth["type"] = "oauth2";
3309
+ customAuth["oauth2"] = {
3310
+ addTokenTo: ((_7 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _7 === void 0 ? void 0 : _7.addTokenTo) || 'header',
3311
+ headerPrefix: ((_8 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _8 === void 0 ? void 0 : _8.headerPrefix) || 'Bearer',
3312
+ access_token: '',
3313
+ grant_type: 'authorization_code',
3314
+ redirect_uri: ((_9 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _9 === void 0 ? void 0 : _9.redirect_uri) || '',
3315
+ authUrl: ((_10 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _10 === void 0 ? void 0 : _10.authUrl) || '',
3316
+ accessTokenUrl: ((_11 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _11 === void 0 ? void 0 : _11.accessTokenUrl) || '',
3317
+ clientId: ((_12 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _12 === void 0 ? void 0 : _12.clientId) || '',
3318
+ clientSecret: ((_13 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _13 === void 0 ? void 0 : _13.clientSecret) || '',
3319
+ username: '',
3320
+ password: '',
3321
+ challengeAlgorithm: 'S256',
3322
+ code_verifier: 'Bearer',
3323
+ scope: ((_14 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _14 === void 0 ? void 0 : _14.scope) || '',
3324
+ state: ((_15 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _15 === void 0 ? void 0 : _15.state) || '',
3325
+ client_authentication: ((_16 = auth === null || auth === void 0 ? void 0 : auth.oauth2) === null || _16 === void 0 ? void 0 : _16.client_authentication) || 'header',
3326
+ refreshTokenUrl: '',
3327
+ authRequestParams: [],
3328
+ tokenRequestParams: [],
3329
+ refreshRequestParams: [],
3330
+ };
3331
+ }
3285
3332
  else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "hawk") {
3286
3333
  customAuth["type"] = "hawk";
3287
3334
  customAuth["hawk"] = {
3288
- authId: ((_7 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _7 === void 0 ? void 0 : _7.authId) || "",
3289
- authKey: ((_8 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _8 === void 0 ? void 0 : _8.authKey) || "",
3290
- algorithm: ((_9 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _9 === void 0 ? void 0 : _9.algorithm) || "",
3291
- user: ((_10 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _10 === void 0 ? void 0 : _10.user) || "",
3292
- nonce: ((_11 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _11 === void 0 ? void 0 : _11.nonce) || "",
3293
- extraData: ((_12 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _12 === void 0 ? void 0 : _12.extraData) || "",
3294
- app: ((_13 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _13 === void 0 ? void 0 : _13.app) || "",
3295
- delegation: ((_14 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _14 === void 0 ? void 0 : _14.delegation) || "",
3296
- timestamp: ((_15 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _15 === void 0 ? void 0 : _15.timestamp) || "",
3297
- includePayloadHash: ((_16 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _16 === void 0 ? void 0 : _16.includePayloadHash) ? true : false,
3335
+ authId: ((_17 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _17 === void 0 ? void 0 : _17.authId) || "",
3336
+ authKey: ((_18 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _18 === void 0 ? void 0 : _18.authKey) || "",
3337
+ algorithm: ((_19 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _19 === void 0 ? void 0 : _19.algorithm) || "",
3338
+ user: ((_20 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _20 === void 0 ? void 0 : _20.user) || "",
3339
+ nonce: ((_21 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _21 === void 0 ? void 0 : _21.nonce) || "",
3340
+ extraData: ((_22 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _22 === void 0 ? void 0 : _22.extraData) || "",
3341
+ app: ((_23 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _23 === void 0 ? void 0 : _23.app) || "",
3342
+ delegation: ((_24 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _24 === void 0 ? void 0 : _24.delegation) || "",
3343
+ timestamp: ((_25 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _25 === void 0 ? void 0 : _25.timestamp) || "",
3344
+ includePayloadHash: ((_26 = auth === null || auth === void 0 ? void 0 : auth.hawk) === null || _26 === void 0 ? void 0 : _26.includePayloadHash) ? true : false,
3298
3345
  };
3299
3346
  }
3300
3347
  else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "awsv4") {
3301
3348
  customAuth["type"] = "awsv4";
3302
3349
  customAuth["awsv4"] = {
3303
- accessKey: ((_17 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _17 === void 0 ? void 0 : _17.accessKey) || "",
3304
- secretKey: ((_18 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _18 === void 0 ? void 0 : _18.secretKey) || "",
3305
- region: ((_19 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _19 === void 0 ? void 0 : _19.region) || "",
3306
- service: ((_20 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _20 === void 0 ? void 0 : _20.service) || "",
3307
- sessionToken: ((_21 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _21 === void 0 ? void 0 : _21.sessionToken) || "",
3308
- addAuthDataToQuery: ((_22 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _22 === void 0 ? void 0 : _22.addAuthDataToQuery) ? true : false,
3350
+ accessKey: ((_27 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _27 === void 0 ? void 0 : _27.accessKey) || "",
3351
+ secretKey: ((_28 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _28 === void 0 ? void 0 : _28.secretKey) || "",
3352
+ region: ((_29 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _29 === void 0 ? void 0 : _29.region) || "",
3353
+ service: ((_30 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _30 === void 0 ? void 0 : _30.service) || "",
3354
+ sessionToken: ((_31 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _31 === void 0 ? void 0 : _31.sessionToken) || "",
3355
+ addAuthDataToQuery: ((_32 = auth === null || auth === void 0 ? void 0 : auth.awsv4) === null || _32 === void 0 ? void 0 : _32.addAuthDataToQuery) ? true : false,
3309
3356
  };
3310
3357
  }
3311
3358
  else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "ntlm") {
3312
3359
  customAuth["type"] = "ntlm";
3313
3360
  customAuth["ntlm"] = {
3314
- username: ((_23 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _23 === void 0 ? void 0 : _23.username) || "",
3315
- password: ((_24 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _24 === void 0 ? void 0 : _24.password) || "",
3316
- domain: ((_25 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _25 === void 0 ? void 0 : _25.domain) || "",
3317
- workstation: ((_26 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _26 === void 0 ? void 0 : _26.workstation) || "",
3318
- disableRetryRequest: ((_27 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _27 === void 0 ? void 0 : _27.disableRetryRequest) ? true : false,
3361
+ username: ((_33 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _33 === void 0 ? void 0 : _33.username) || "",
3362
+ password: ((_34 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _34 === void 0 ? void 0 : _34.password) || "",
3363
+ domain: ((_35 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _35 === void 0 ? void 0 : _35.domain) || "",
3364
+ workstation: ((_36 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _36 === void 0 ? void 0 : _36.workstation) || "",
3365
+ disableRetryRequest: ((_37 = auth === null || auth === void 0 ? void 0 : auth.ntlm) === null || _37 === void 0 ? void 0 : _37.disableRetryRequest) ? true : false,
3319
3366
  };
3320
3367
  }
3321
3368
  else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "edgegrid") {
3322
3369
  customAuth["type"] = "edgegrid";
3323
3370
  customAuth["edgegrid"] = {
3324
- accessToken: ((_28 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _28 === void 0 ? void 0 : _28.accessToken) || "",
3325
- clientToken: ((_29 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _29 === void 0 ? void 0 : _29.clientToken) || "",
3326
- clientSecret: ((_30 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _30 === void 0 ? void 0 : _30.clientSecret) || "",
3327
- nonce: ((_31 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _31 === void 0 ? void 0 : _31.nonce) || "",
3328
- timestamp: ((_32 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _32 === void 0 ? void 0 : _32.timestamp) || "",
3329
- baseURi: ((_33 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _33 === void 0 ? void 0 : _33.baseURL) || "",
3330
- headersToSign: ((_34 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _34 === void 0 ? void 0 : _34.headersToSign) || "",
3371
+ accessToken: ((_38 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _38 === void 0 ? void 0 : _38.accessToken) || "",
3372
+ clientToken: ((_39 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _39 === void 0 ? void 0 : _39.clientToken) || "",
3373
+ clientSecret: ((_40 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _40 === void 0 ? void 0 : _40.clientSecret) || "",
3374
+ nonce: ((_41 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _41 === void 0 ? void 0 : _41.nonce) || "",
3375
+ timestamp: ((_42 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _42 === void 0 ? void 0 : _42.timestamp) || "",
3376
+ baseURi: ((_43 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _43 === void 0 ? void 0 : _43.baseURL) || "",
3377
+ headersToSign: ((_44 = auth === null || auth === void 0 ? void 0 : auth.edgegrid) === null || _44 === void 0 ? void 0 : _44.headersToSign) || "",
3331
3378
  };
3332
3379
  }
3333
3380
  else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "jwt") {
3334
3381
  customAuth["type"] = "jwt";
3335
3382
  customAuth["jwt"] = {
3336
- addTokenTo: ((_35 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _35 === void 0 ? void 0 : _35.auth) || "header",
3337
- algorithm: ((_36 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _36 === void 0 ? void 0 : _36.algorithm) || "HS256",
3338
- secret: ((_37 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _37 === void 0 ? void 0 : _37.secret) || "",
3339
- isSecretBase64Encoded: ((_38 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _38 === void 0 ? void 0 : _38.isSecretBase64Encoded) ? true : false,
3340
- payload: ((_39 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _39 === void 0 ? void 0 : _39.payload) || "",
3341
- headerPrefix: ((_40 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _40 === void 0 ? void 0 : _40.headerPrefix) || "Bearer",
3342
- queryParamKey: ((_41 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _41 === void 0 ? void 0 : _41.queryParamKey) || "token",
3343
- header: ((_42 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _42 === void 0 ? void 0 : _42.header) || "",
3383
+ addTokenTo: ((_45 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _45 === void 0 ? void 0 : _45.auth) || "header",
3384
+ algorithm: ((_46 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _46 === void 0 ? void 0 : _46.algorithm) || "HS256",
3385
+ secret: ((_47 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _47 === void 0 ? void 0 : _47.secret) || "",
3386
+ isSecretBase64Encoded: ((_48 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _48 === void 0 ? void 0 : _48.isSecretBase64Encoded) ? true : false,
3387
+ payload: ((_49 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _49 === void 0 ? void 0 : _49.payload) || "",
3388
+ headerPrefix: ((_50 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _50 === void 0 ? void 0 : _50.headerPrefix) || "Bearer",
3389
+ queryParamKey: ((_51 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _51 === void 0 ? void 0 : _51.queryParamKey) || "token",
3390
+ header: ((_52 = auth === null || auth === void 0 ? void 0 : auth.jwt) === null || _52 === void 0 ? void 0 : _52.header) || "",
3344
3391
  };
3345
3392
  }
3346
3393
  return Object.assign(Object.assign({}, DEFAULT_AUTH), customAuth);
@@ -4164,6 +4211,10 @@ class InsomniaToApipost {
4164
4211
  ? true
4165
4212
  : false, includeBodyHash: (authentication === null || authentication === void 0 ? void 0 : authentication.includeBodyHash) ? true : false, addParamsToHeader: (authentication === null || authentication === void 0 ? void 0 : authentication.addParamsToHeader) || 0, realm: (authentication === null || authentication === void 0 ? void 0 : authentication.realm) || "", version: (authentication === null || authentication === void 0 ? void 0 : authentication.version) || "", nonce: (authentication === null || authentication === void 0 ? void 0 : authentication.nonce) || "", verifier: (authentication === null || authentication === void 0 ? void 0 : authentication.verifier) || "", timestamp: (authentication === null || authentication === void 0 ? void 0 : authentication.timestamp) || "", callback: (authentication === null || authentication === void 0 ? void 0 : authentication.callback) || "", tokenSecret: (authentication === null || authentication === void 0 ? void 0 : authentication.tokenSecret) || "", token: (authentication === null || authentication === void 0 ? void 0 : authentication.token) || "" });
4166
4213
  }
4214
+ else if ((authentication === null || authentication === void 0 ? void 0 : authentication.type) === "oauth2") {
4215
+ request.auth["type"] = "oauth2";
4216
+ request.auth["oauth2"] = Object.assign(Object.assign({}, request.auth.oauth2), { addTokenTo: (authentication === null || authentication === void 0 ? void 0 : authentication.addTokenTo) || 'header', headerPrefix: (authentication === null || authentication === void 0 ? void 0 : authentication.tokenPrefix) || 'Bearer', access_token: '', grant_type: 'authorization_code', redirect_uri: (authentication === null || authentication === void 0 ? void 0 : authentication.redirectUrl) || '', authUrl: (authentication === null || authentication === void 0 ? void 0 : authentication.authorizationUrl) || '', accessTokenUrl: (authentication === null || authentication === void 0 ? void 0 : authentication.accessTokenUrl) || '', clientId: (authentication === null || authentication === void 0 ? void 0 : authentication.clientId) || '', clientSecret: (authentication === null || authentication === void 0 ? void 0 : authentication.clientSecret) || '', username: '', password: '', challengeAlgorithm: 'S256', code_verifier: 'Bearer', scope: '', state: '', client_authentication: 'header', refreshTokenUrl: '', authRequestParams: [], tokenRequestParams: [], refreshRequestParams: [] });
4217
+ }
4167
4218
  else if ((authentication === null || authentication === void 0 ? void 0 : authentication.type) === "ntlm") {
4168
4219
  request.auth["type"] = "ntlm";
4169
4220
  request.auth["ntlm"] = Object.assign(Object.assign({}, request.auth.ntlm), { username: (authentication === null || authentication === void 0 ? void 0 : authentication.username) || "", password: (authentication === null || authentication === void 0 ? void 0 : authentication.username) || "" });
@@ -4429,7 +4480,7 @@ class PostmanToApipost {
4429
4480
  };
4430
4481
  }
4431
4482
  completionApiRequestAuth(auth) {
4432
- var _a, _b, _c, _d;
4483
+ var _a, _b, _c, _d, _e, _f, _g;
4433
4484
  // 后期会修改结构
4434
4485
  const customAuth = {};
4435
4486
  if (auth && lodash.has(auth, "type")) {
@@ -4490,6 +4541,31 @@ class PostmanToApipost {
4490
4541
  disableHeaderEncoding: (authMap === null || authMap === void 0 ? void 0 : authMap.disableHeaderEncoding) ? true : false,
4491
4542
  };
4492
4543
  }
4544
+ else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "oauth2") {
4545
+ customAuth["type"] = "oauth2";
4546
+ customAuth["oauth2"] = {
4547
+ addTokenTo: (authMap === null || authMap === void 0 ? void 0 : authMap.addTokenTo) || 'header',
4548
+ headerPrefix: (authMap === null || authMap === void 0 ? void 0 : authMap.headerPrefix) || 'Bearer',
4549
+ access_token: '',
4550
+ grant_type: 'authorization_code',
4551
+ redirect_uri: (authMap === null || authMap === void 0 ? void 0 : authMap.redirect_uri) || '',
4552
+ authUrl: (authMap === null || authMap === void 0 ? void 0 : authMap.authUrl) || '',
4553
+ accessTokenUrl: (authMap === null || authMap === void 0 ? void 0 : authMap.accessTokenUrl) || '',
4554
+ clientId: (authMap === null || authMap === void 0 ? void 0 : authMap.clientId) || '',
4555
+ clientSecret: (authMap === null || authMap === void 0 ? void 0 : authMap.clientSecret) || '',
4556
+ username: (authMap === null || authMap === void 0 ? void 0 : authMap.username) || '',
4557
+ password: (authMap === null || authMap === void 0 ? void 0 : authMap.password) || '',
4558
+ challengeAlgorithm: (authMap === null || authMap === void 0 ? void 0 : authMap.challengeAlgorithm) || 'S256',
4559
+ code_verifier: (authMap === null || authMap === void 0 ? void 0 : authMap.code_verifier) || 'Bearer',
4560
+ scope: (authMap === null || authMap === void 0 ? void 0 : authMap.scope) || '',
4561
+ state: (authMap === null || authMap === void 0 ? void 0 : authMap.state) || '',
4562
+ client_authentication: (authMap === null || authMap === void 0 ? void 0 : authMap.client_authentication) || 'header',
4563
+ refreshTokenUrl: (authMap === null || authMap === void 0 ? void 0 : authMap.refreshTokenUrl) || '',
4564
+ authRequestParams: isArray(authMap === null || authMap === void 0 ? void 0 : authMap.authRequestParams) ? (_e = authMap === null || authMap === void 0 ? void 0 : authMap.authRequestParams) === null || _e === void 0 ? void 0 : _e.map((e) => (Object.assign(Object.assign({}, e), { param_id: ATools.snowflakeId() }))) : [],
4565
+ tokenRequestParams: isArray(authMap === null || authMap === void 0 ? void 0 : authMap.tokenRequestParams) ? (_f = authMap === null || authMap === void 0 ? void 0 : authMap.tokenRequestParams) === null || _f === void 0 ? void 0 : _f.map((e) => (Object.assign(Object.assign({}, e), { param_id: ATools.snowflakeId() }))) : [],
4566
+ refreshRequestParams: isArray(authMap === null || authMap === void 0 ? void 0 : authMap.refreshRequestParams) ? (_g = authMap === null || authMap === void 0 ? void 0 : authMap.refreshRequestParams) === null || _g === void 0 ? void 0 : _g.map((e) => (Object.assign(Object.assign({}, e), { param_id: ATools.snowflakeId() }))) : [],
4567
+ };
4568
+ }
4493
4569
  else if ((auth === null || auth === void 0 ? void 0 : auth.type) === "hawk") {
4494
4570
  customAuth["type"] = "hawk";
4495
4571
  customAuth["hawk"] = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "echoapi-converter",
3
- "version": "0.0.26",
3
+ "version": "0.0.27",
4
4
  "description": "echoapi to swagger",
5
5
  "main": "dist/index.js",
6
6
  "files": [