Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openapi-gen-typescript

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openapi-gen-typescript - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

2

dist/defaultFetch.d.ts

@@ -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}`);
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc