swagger-axios-codegen
Advanced tools
Comparing version 0.2.13 to 0.2.14
@@ -0,1 +1,5 @@ | ||
## 0.2.14 | ||
- Adds support of primitive response types ([bbc907](https://github.com/Manweill/swagger-axios-codegen/commit/bbc9072a634a996beab19e1a8fd58ea52b8d09d7) by [kt81](https://github.com/Manweill/swagger-axios-codegen/commits?author=kt81)) | ||
## 0.2.13 | ||
@@ -2,0 +6,0 @@ |
@@ -38,2 +38,4 @@ export interface ISwaggerOptions { | ||
'$ref': string; | ||
'type'?: string; | ||
'items'?: IParameterItems; | ||
}; | ||
@@ -40,0 +42,0 @@ }; |
@@ -110,5 +110,33 @@ "use strict"; | ||
} | ||
let responseType = v.responses['200'] && v.responses['200'].schema && v.responses['200'].schema.$ref | ||
? utils_1.refClassName(v.responses['200'].schema.$ref) | ||
: 'any'; | ||
// 确定响应的类型 | ||
// It does not allow the schema defined directly, but only the primitive type is allowed. | ||
let responseType; | ||
if (!v.responses['200'] || !v.responses['200'].schema) { | ||
responseType = 'any'; | ||
} | ||
else if (v.responses['200'].schema.$ref) { | ||
responseType = utils_1.refClassName(v.responses['200'].schema.$ref); | ||
} | ||
else { | ||
let checkType = v.responses[200].schema.type; | ||
if (!checkType) { | ||
// implicit types | ||
if (v.responses[200].schema.items) { | ||
responseType = 'array'; | ||
} | ||
else { // if (v.responses[200].schema.properties) // actual check | ||
responseType = 'object'; | ||
} | ||
} | ||
else { | ||
responseType = checkType; // string? -> string | ||
} | ||
if (responseType == 'object') { | ||
responseType = 'any'; | ||
} | ||
else if (responseType == 'array') { | ||
responseType = 'any[]'; | ||
} | ||
// else ... JSON primitive types (string, boolean, number) | ||
} | ||
// 模版 | ||
@@ -115,0 +143,0 @@ RequestMethods[className] += ` |
{ | ||
"name": "swagger-axios-codegen", | ||
"version": "0.2.13", | ||
"version": "0.2.14", | ||
"main": "./dist/index", | ||
@@ -5,0 +5,0 @@ "typings": "./dist/", |
36483
607