openapi-gen-typescript
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -5,3 +5,3 @@ export default function fetch(options: { | ||
body?: any; | ||
header?: any; | ||
headers?: any; | ||
cookie?: any; | ||
@@ -8,0 +8,0 @@ }): Promise<{ |
@@ -17,3 +17,3 @@ "use strict"; | ||
url: options.url, | ||
headers: options.header, | ||
headers: options.headers, | ||
data: options.body, | ||
@@ -20,0 +20,0 @@ params: options.query, |
@@ -66,3 +66,3 @@ "use strict"; | ||
return yield json_schema_to_typescript_1.compile(Object.assign(Object.assign({}, content[mediaType].schema), { title: responseTypeName }), responseTypeName, { | ||
bannerComment: comment, | ||
bannerComment: `/** ${comment} */`, | ||
$refOptions: { resolve: { file: null, external: true } }, | ||
@@ -121,2 +121,3 @@ }); | ||
const responsesCode = (yield Promise.all(Object.keys(responses) | ||
.filter(key => key !== 'default') | ||
.map((statusCode) => __awaiter(this, void 0, void 0, function* () { | ||
@@ -166,3 +167,3 @@ const responsesObjectElement = responses[statusCode]; | ||
body${requestBodyRequired ? '' : '?'}: ${requestBodyTypeNames.length > 0 ? requestBodyTypeNames.join('|') : 'any'}; | ||
header?: RequestHeader; | ||
headers?: RequestHeader; | ||
cookie?: Cookie; | ||
@@ -188,3 +189,3 @@ }): Promise<{ body: ${responseTypeNames.length > 0 ? responseTypeNames.join('|') : 'any'} }> { | ||
/** | ||
* This file was automatically generated by openapi-ts. | ||
* This file was automatically generated by openapi-gen-typescript. | ||
* DO NOT MODIFY IT BY HAND. | ||
@@ -198,5 +199,5 @@ */`, | ||
fs.writeFileSync(`${outputDir}/index.ts`, code); | ||
process.exit(0); | ||
console.info(`Generate code successful in directory: ${outputDir}`); | ||
}); | ||
} | ||
exports.gen = gen; |
{ | ||
"name": "openapi-gen-typescript", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"license": "Apache License 2.0", | ||
"scripts": { | ||
"prepublish": "npm run compile", | ||
"compile": "gts clean && tsc -p ." | ||
"compile": "gts clean && tsc -p .", | ||
"test": "node -r ts-node/register test/test.ts" | ||
}, | ||
@@ -10,0 +12,0 @@ "devDependencies": { |
# openapi-ts | ||
Generate typescript code for openapi | ||
Generate typescript code for openapi. | ||
## Usage | ||
```javascript | ||
gen({ | ||
url: 'https://petstore.swagger.io/v2/swagger.json', | ||
version: "2", | ||
outputDir: `${__dirname}/gen` | ||
}); | ||
``` | ||
## doc | ||
Param | Description | ||
---|--- | ||
url | The url of fetch openapi or swagger data | ||
version | The version of Swagger or OpenApi, example: `2`, `3` | ||
outputDir | Dir of output files | ||
fetchModuleFile | Fetch impl file path | ||
@@ -7,3 +7,3 @@ import axios from "axios"; | ||
body?: any; | ||
header?: any; | ||
headers?: any; | ||
cookie?: any; | ||
@@ -13,3 +13,3 @@ }): Promise<{ body: any }> { | ||
url: options.url, | ||
headers: options.header, | ||
headers: options.headers, | ||
data: options.body, | ||
@@ -16,0 +16,0 @@ params: options.query, |
@@ -77,3 +77,3 @@ // @ts-ignore | ||
{ | ||
bannerComment: comment, | ||
bannerComment: `/** ${comment} */`, | ||
$refOptions: { resolve: { file: null, external: true } as any }, | ||
@@ -154,2 +154,3 @@ }, | ||
const responsesCode: string = (await Promise.all(Object.keys(responses) | ||
.filter(key => key !== 'default') | ||
.map(async (statusCode) => { | ||
@@ -204,3 +205,3 @@ const responsesObjectElement = responses[statusCode]; | ||
body${requestBodyRequired ? '' : '?'}: ${requestBodyTypeNames.length > 0 ? requestBodyTypeNames.join('|') : 'any'}; | ||
header?: RequestHeader; | ||
headers?: RequestHeader; | ||
cookie?: Cookie; | ||
@@ -227,3 +228,3 @@ }): Promise<{ body: ${responseTypeNames.length > 0 ? responseTypeNames.join('|') : 'any'} }> { | ||
/** | ||
* This file was automatically generated by openapi-ts. | ||
* This file was automatically generated by openapi-gen-typescript. | ||
* DO NOT MODIFY IT BY HAND. | ||
@@ -238,3 +239,4 @@ */`, | ||
fs.writeFileSync(`${outputDir}/index.ts`, code); | ||
process.exit(0); | ||
console.info(`Generate code successful in directory: ${outputDir}`); | ||
} |
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
32369
490
24