openapi-gen-typescript
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -35,2 +35,3 @@ "use strict"; | ||
const constants_1 = require("./constants"); | ||
const axios_1 = require("axios"); | ||
function getCamelcase(urlPath, options) { | ||
@@ -112,6 +113,19 @@ return camelcase(urlPath.split('/').join('_'), options); | ||
const { dereference, parse } = swaggerParser; | ||
const params = url || filePath; | ||
let params = url || filePath; | ||
if (version === '2') { | ||
const { convertUrl, convertFile } = swagger2openapi; | ||
const openapiConvert = url ? convertUrl : convertFile; | ||
// convertUrl响应速度很慢,改为使用convertObj | ||
const { convertObj, convertFile } = swagger2openapi; | ||
const openapiConvert = url ? convertObj : convertFile; | ||
if (url) { | ||
try { | ||
const result = yield axios_1.default.get(url); | ||
if (result.status !== 200) { | ||
throw Error(`未返回正确的status code ${result.status}: ${url}`); | ||
} | ||
params = result.data; | ||
} | ||
catch (e) { | ||
console.error('e :>> ', e.message); | ||
} | ||
} | ||
const openapi = yield openapiConvert(params, { | ||
@@ -118,0 +132,0 @@ patch: true, |
{ | ||
"name": "openapi-gen-typescript", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -22,2 +22,3 @@ // @ts-ignore | ||
import RequestBodyObject = OpenAPIV3.RequestBodyObject; | ||
import Axios from 'axios'; | ||
@@ -171,6 +172,18 @@ type ContentObject = { | ||
const { dereference, parse } = swaggerParser; | ||
const params: any = url || filePath; | ||
let params: any = url || filePath; | ||
if (version === '2') { | ||
const { convertUrl, convertFile } = swagger2openapi; | ||
const openapiConvert = url ? convertUrl : convertFile; | ||
// convertUrl响应速度很慢,改为使用convertObj | ||
const { convertObj, convertFile } = swagger2openapi; | ||
const openapiConvert = url ? convertObj : convertFile; | ||
if (url) { | ||
try { | ||
const result = await Axios.get(url); | ||
if (result.status !== 200) { | ||
throw Error(`未返回正确的status code ${result.status}: ${url}`); | ||
} | ||
params = result.data; | ||
} catch (e) { | ||
console.error('e :>> ', e.message); | ||
} | ||
} | ||
const openapi = await openapiConvert(params, { | ||
@@ -177,0 +190,0 @@ patch: true, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64939
1391