Skip to content

Commit

Permalink
add postProcessParamter for body, form parameter (#263)
Browse files Browse the repository at this point in the history
  • Loading branch information
wing328 authored Apr 29, 2018
1 parent 2ce721d commit 80c8b92
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -3195,9 +3200,9 @@ private static Map<String, String> getAllAliases(Map<String, Schema> schemas) {
for (Map.Entry<String, Schema> 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);
}
}

Expand Down

0 comments on commit 80c8b92

Please # to comment.