From 80c8b92cb544bc08a18e7e15bca1d1b0487c4095 Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 29 Apr 2018 15:58:12 +0800 Subject: [PATCH] add postProcessParamter for body, form parameter (#263) --- .../org/openapitools/codegen/DefaultCodegen.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index 868dac56a47f..17eae742c6b6 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -1150,7 +1150,7 @@ public String getSchemaType(Schema schema) { if (StringUtils.isNotEmpty(schemaName)) { return getAlias(schemaName); } else { - LOGGER.warn("Error obtaining the datatype from ref:" + schema.get$ref()+ ". Default to 'object'"); + LOGGER.warn("Error obtaining the datatype from ref:" + schema.get$ref() + ". Default to 'object'"); return "object"; } } else { // primitive type (non-model) @@ -2212,6 +2212,9 @@ public CodegenOperation fromOperation(String path, "multipart/form-data".equalsIgnoreCase(getContentType(requestBody))) { // process form parameters formParams = fromRequestBodyToFormParameters(requestBody, schemas, imports); + for (CodegenParameter cp : formParams) { + postProcessParameter(cp); + } // add form parameters to the beginning of all parameter list if (prependFormOrBodyParameters) { for (CodegenParameter cp : formParams) { @@ -2225,6 +2228,8 @@ public CodegenOperation fromOperation(String path, } bodyParam = fromRequestBody(requestBody, schemas, imports); bodyParam.description = requestBody.getDescription(); + postProcessParameter(bodyParam); + bodyParams.add(bodyParam); if (prependFormOrBodyParameters) { @@ -3195,9 +3200,9 @@ private static Map getAllAliases(Map schemas) { for (Map.Entry entry : schemas.entrySet()) { String oasName = entry.getKey(); Schema schema = entry.getValue(); - String typeType = getPrimitiveType(schema); - if (typeType != null && !typeType.equals("object") && !typeType.equals("array") && schema.getEnum() == null) { - aliases.put(oasName, typeType); + String schemaType = getPrimitiveType(schema); + if (schemaType != null && !schemaType.equals("object") && !schemaType.equals("array") && schema.getEnum() == null) { + aliases.put(oasName, schemaType); } }