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

api-gensdk

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

api-gensdk - npm Package Compare versions

Comparing version 0.1.19 to 0.1.20

31

lib/cli/genSdk.js

@@ -101,10 +101,25 @@ "use strict";

}));
const postData = requestBody.content && requestBody.content['application/json'].schema.properties || {};
for (const k in postData) {
params.push({
name: k,
paramName: k,
in: 'body',
type: getType_1.getType(postData[k]),
});
const bodySchema = requestBody.content && requestBody.content['application/json'].schema;
if (bodySchema) {
switch (bodySchema.type) {
case 'object':
const postData = bodySchema.properties || {};
for (const k in postData) {
params.push({
name: k,
paramName: k,
in: 'body',
type: getType_1.getType(postData[k]),
});
}
break;
default:
params.push({
name: '$body',
paramName: '$body',
in: 'body',
type: getType_1.getType(bodySchema),
});
break;
}
}

@@ -111,0 +126,0 @@ return params;

{
"name": "api-gensdk",
"version": "0.1.19",
"version": "0.1.20",
"description": "",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -24,34 +24,24 @@ # api-gensdk

# Quick View
gensdk from swagger 2.0 or OpenAPI 3.0:
## Simple
`gensdk url http://xxx/v2/api-docs -c true`
## Use Config
`gensdk config ./xxx.js` or `gensdk config ./xxx.json`
Config interface:
```ts
export interface RouteMetadataType {
/** 类名 */
className: string;
/** 方法名 */
functionName: string;
/** 路由名称 */
name: string;
/** 路由描述 */
description: string;
/** http method */
method: string;
/** http url */
url: string;
/** 参数定义 */
params: {
/** 函数参数名 */
name: string,
/** 请求参数名 */
paramName: string,
/** 类型 */
type: string,
}[];
}
export class GenConfig {
/** 生成目录 */
interface CliConfig {
api: string;
/** dir for gensdk */
sdkDir: string;
/** 模版目录 */
/** path for template */
templatePath: string;
/** filename style */
camelCase?: boolean = false;
/** filename style, true 为大驼峰,lower 为小驼峰 */
camelCase?: boolean | 'lower' = false;
/** gen type */

@@ -63,2 +53,3 @@ type?: 'ts' | 'js' = 'ts';

### genAPISDK
`function genAPISDK(data: RouteMetadataType[], config: GenConfig) => void`
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