openapi-gen-typescript
Advanced tools
Comparing version 0.2.7 to 0.3.0
@@ -307,6 +307,6 @@ "use strict"; | ||
const generateClassArr = exportArr.map(exp => { | ||
return exp | ||
.replace(/ interface | type = /g, ' class ') | ||
.replace(/ type ([^=]+) = components.([a-zA-Z.]+)[;{}]?/g, ' class $1 extends $2 {}') | ||
.replace(/ type ([^=]+) = {/g, ' class $1 {'); | ||
const exp1 = exp.replace(/ interface | type = /g, ' class '); | ||
const exp2 = exp1.replace(/ type ([^=]+) = components.([a-zA-Z._]+)[;{}]?/g, ' class $1 extends $2 {}'); | ||
const exp3 = exp2.replace(/ type ([^=]+) = {/g, ' class $1 {'); | ||
return exp3; | ||
}); | ||
@@ -340,3 +340,5 @@ pathsMap[namespaceName] = { | ||
.relative(currTagNameDir, fetchModuleFile) | ||
.replace(/\.ts$/, '')}';`, | ||
.replace(/\.ts$/, '')}';` | ||
.split(path.sep) | ||
.join('/'), | ||
schemasClassCode.length > 0 ? `import * as schemas from '../schemas';\n` : '\n', | ||
@@ -343,0 +345,0 @@ code, |
{ | ||
"name": "openapi-gen-typescript", | ||
"version": "0.2.7", | ||
"version": "0.3.0", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
# openapi-gen-typescript | ||
Generate typescript code for openapi. | ||
@@ -8,5 +9,5 @@ | ||
gen({ | ||
url: 'https://petstore.swagger.io/v2/swagger.json', | ||
version: "2", | ||
outputDir: `${__dirname}/gen` | ||
url: 'https://petstore.swagger.io/v2/swagger.json', | ||
version: '2', | ||
outputDir: `${__dirname}/gen`, | ||
}); | ||
@@ -21,2 +22,3 @@ ``` | ||
| path | The filePath of fetch openapi or swagger data | | ||
| object | The docs of fetch openapi or swagger data | | ||
| version | The version of Swagger or OpenApi, example: `2`, `3` | | ||
@@ -26,3 +28,1 @@ | outputDir | Dir of output files | | ||
| handlePostScript | post script to customize the result | | ||
@@ -439,6 +439,9 @@ // @ts-ignore | ||
const generateClassArr = exportArr.map(exp => { | ||
return exp | ||
.replace(/ interface | type = /g, ' class ') | ||
.replace(/ type ([^=]+) = components.([a-zA-Z.]+)[;{}]?/g, ' class $1 extends $2 {}') | ||
.replace(/ type ([^=]+) = {/g, ' class $1 {'); | ||
const exp1 = exp.replace(/ interface | type = /g, ' class '); | ||
const exp2 = exp1.replace( | ||
/ type ([^=]+) = components.([a-zA-Z._]+)[;{}]?/g, | ||
' class $1 extends $2 {}', | ||
); | ||
const exp3 = exp2.replace(/ type ([^=]+) = {/g, ' class $1 {'); | ||
return exp3; | ||
}); | ||
@@ -479,3 +482,5 @@ pathsMap[namespaceName] = { | ||
.relative(currTagNameDir, fetchModuleFile) | ||
.replace(/\.ts$/, '')}';`, | ||
.replace(/\.ts$/, '')}';` | ||
.split(path.sep) | ||
.join('/'), | ||
schemasClassCode.length > 0 ? `import * as schemas from '../schemas';\n` : '\n', | ||
@@ -482,0 +487,0 @@ code, |
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
69996
1524