swagger-axios-codegen
Advanced tools
Comparing version 0.1.9 to 0.2.0
{ | ||
"editor.formatOnSave": true | ||
} |
@@ -7,3 +7,3 @@ "use strict"; | ||
const utils_1 = require("./utils"); | ||
const camelcase_1 = __importDefault(require("camelcase")); | ||
const pascalcase_1 = __importDefault(require("pascalcase")); | ||
function propTrueType(v, isGenericType) { | ||
@@ -35,4 +35,4 @@ let propType = ''; | ||
propType = v.type === 'string' ? | ||
v.enum.map(item => `${item}='${item}'`).join(',') : | ||
v.enum.map(item => `${item}=${item}`).join(','); | ||
v.enum.map(item => `'${item}'='${item}'`).join(',') : | ||
v.enum.map(item => `'${item}'=${item}`).join(','); | ||
} | ||
@@ -61,3 +61,3 @@ // 基本类型 | ||
if (isEnum) { | ||
let enumName = `Enum${className}${camelcase_1.default(k, { pascalCase: true })}`; | ||
let enumName = `Enum${className}${pascalcase_1.default(k)}`; | ||
enums.push({ | ||
@@ -72,3 +72,3 @@ name: enumName, text: `export enum ${enumName}{ | ||
/** ${v.description || ''} */ | ||
${k}:${propType};\n | ||
${k}:${propType};\n· | ||
`; | ||
@@ -75,0 +75,0 @@ constructorStr += `this['${k}'] = data['${k}'];\n`; |
@@ -89,10 +89,9 @@ "use strict"; | ||
}`); | ||
parameters = `params: ${methodParamsName},`; | ||
parameters = `params: ${methodParamsName}={},`; | ||
formData = parsedParameters.requestFormData ? 'data = new FormData();\n' + parsedParameters.requestFormData : ''; | ||
pathReplace = parsedParameters.requestPathReplace; | ||
} | ||
let responseType = v.responses['200'] && | ||
v.responses['200'].schema && | ||
v.responses['200'].schema.$ref ? | ||
utils_1.refClassName(v.responses['200'].schema.$ref) : 'any'; | ||
let responseType = v.responses['200'] && v.responses['200'].schema && v.responses['200'].schema.$ref | ||
? utils_1.refClassName(v.responses['200'].schema.$ref) | ||
: 'any'; | ||
// 模版 | ||
@@ -117,6 +116,10 @@ RequestMethods[className] += ` | ||
${parsedParameters && parsedParameters.queryParameters.length > 0 ? "configs.params = {" + parsedParameters.queryParameters.join(',') + "}" : ''}; | ||
${parsedParameters && parsedParameters.queryParameters.length > 0 | ||
? 'configs.params = {' + parsedParameters.queryParameters.join(',') + '}' | ||
: ''}; | ||
let data = null; | ||
${parsedParameters && parsedParameters.bodyParameters.length > 0 ? "data = {" + parsedParameters.bodyParameters.join(',') + "}" : ''}; | ||
${parsedParameters && parsedParameters.bodyParameters.length > 0 | ||
? 'data = {' + parsedParameters.bodyParameters.join(',') + '}' | ||
: ''}; | ||
@@ -123,0 +126,0 @@ ${contentType === 'multipart/form-data' ? formData : ''} |
{ | ||
"name": "swagger-axios-codegen", | ||
"version": "0.1.9", | ||
"version": "0.2.0", | ||
"main": "./dist/index", | ||
@@ -21,2 +21,3 @@ "typings": "./dist/", | ||
"camelcase": "^5.0.0", | ||
"pascalcase": "^0.1.1", | ||
"prettier": "^1.12.1" | ||
@@ -28,4 +29,4 @@ }, | ||
"@types/prettier": "^1.12.2", | ||
"typescript": "^2.8.1" | ||
"typescript": "^2.8.3" | ||
} | ||
} |
1135321
28
28634
4
+ Addedpascalcase@^0.1.1
+ Addedpascalcase@0.1.1(transitive)