api-gensdk
Advanced tools
Comparing version 0.1.19 to 0.1.20
@@ -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` |
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
24660
523
31
54