openapi-gen-typescript
Advanced tools
Comparing version 0.0.9 to 0.1.0
@@ -18,2 +18,3 @@ import { OpenAPI, OpenAPIV3 } from "openapi-types"; | ||
url?: string; | ||
path?: string; | ||
version: string; | ||
@@ -20,0 +21,0 @@ object?: OpenAPI.Document; |
@@ -80,3 +80,3 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { url, version, object, fetchModuleFile = `${__dirname}/defaultFetch.ts`, outputDir, pascalCase = true, } = options; | ||
const { url, path: filePath, version, object, fetchModuleFile = `${__dirname}/defaultFetch.ts`, outputDir, pascalCase = true, } = options; | ||
const fetchModuleImportCode = `import fetchImpl from '${path.relative(outputDir, fetchModuleFile).replace(/\.ts$/, '')}';\n`; | ||
@@ -95,2 +95,13 @@ let openApiData; | ||
} | ||
else if (filePath) { | ||
if (version === '2') { | ||
const openapi = yield swagger2openapi.convertFile(filePath, { | ||
patch: true, | ||
}); | ||
openApiData = openapi.openapi || (yield swaggerParser.dereference(openapi.openapi)); | ||
} | ||
else { | ||
openApiData = (yield swaggerParser.parse(filePath)); | ||
} | ||
} | ||
else if (!object) { | ||
@@ -97,0 +108,0 @@ throw 'option: url or object must be specified one'; |
{ | ||
"name": "openapi-gen-typescript", | ||
"version": "0.0.9", | ||
"version": "0.1.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
@@ -97,2 +97,3 @@ // @ts-ignore | ||
url?: string; | ||
path?: string; | ||
version: string; | ||
@@ -109,2 +110,3 @@ object?: OpenAPI.Document; | ||
url, | ||
path: filePath, | ||
version, | ||
@@ -129,2 +131,11 @@ object, | ||
} | ||
} else if (filePath) { | ||
if (version === '2') { | ||
const openapi = await swagger2openapi.convertFile(filePath, { | ||
patch: true, | ||
}); | ||
openApiData = openapi.openapi || await swaggerParser.dereference(openapi.openapi); | ||
} else { | ||
openApiData = await swaggerParser.parse(filePath) as OpenAPIV3.Document; | ||
} | ||
} else if (!object) { | ||
@@ -131,0 +142,0 @@ throw 'option: url or object must be specified one' |
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
51014
1002