Skip to content

Commit

Permalink
Required multipart/form-data parameters not reflected in generated …
Browse files Browse the repository at this point in the history
…schema. fixes #1106
  • Loading branch information
bnasslahsen committed Mar 15, 2021
1 parent 5b992a8 commit 5c7f784
Show file tree
Hide file tree
Showing 14 changed files with 969 additions and 912 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,10 @@ else if (schemaN instanceof FileSchema || schemaN instanceof ArraySchema && ((Ar
}
else
requestBodyInfo.addProperties(paramName, schemaN);

if(requestBodyInfo.getMergedSchema() !=null && parameterInfo.isRequired())
requestBodyInfo.getMergedSchema().addRequiredItem(parameterInfo.getpName());

return schemaN;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ public void calculateRequestBodyInfo(Components components, MethodAttributes met

RequestPart requestPart = methodParameter.getParameterAnnotation(RequestPart.class);
String paramName = null;
if (requestPart != null)
if (requestPart != null){
paramName = StringUtils.defaultIfEmpty(requestPart.value(), requestPart.name());
parameterInfo.setRequired(requestPart.required());
}
paramName = StringUtils.defaultIfEmpty(paramName, parameterInfo.getpName());
parameterInfo.setpName(paramName);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"content": {
"multipart/form-data": {
"schema": {
"required": [
"resumeFile"
],
"type": "object",
"properties": {
"resumeFile": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
"content": {
"multipart/form-data": {
"schema": {
"required": [
"files"
],
"type": "object",
"properties": {
"files": {
Expand Down Expand Up @@ -56,4 +59,4 @@
}
},
"components": {}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@
"content": {
"multipart/form-data": {
"schema": {
"required": [
"body",
"file"
],
"type": "object",
"properties": {
"body": {
Expand Down

0 comments on commit 5c7f784

Please sign in to comment.