Skip to content

Commit

Permalink
NPE for request bodies with content that has media type MULTIPART_FOR…
Browse files Browse the repository at this point in the history
…M_DATA_VALUE. Fixes #1804
  • Loading branch information
bnasslahsen committed Aug 20, 2022
1 parent 7ad1bb7 commit aaf92ab
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ protected AbstractRequestService(GenericParameterService parameterBuilder, Reque
this.localSpringDocParameterNameDiscoverer = localSpringDocParameterNameDiscoverer;
this.defaultFlatParamObject = parameterBuilder.getPropertyResolverUtils().getSpringDocConfigProperties().isDefaultFlatParamObject();
this.defaultSupportFormData = parameterBuilder.getPropertyResolverUtils().getSpringDocConfigProperties().isDefaultSupportFormData();

}

/**
Expand Down Expand Up @@ -330,19 +329,18 @@ else if (!RequestMethod.GET.equals(requestMethod)) {
if (defaultSupportFormData && requestBody != null
&& requestBody.getContent() != null
&& requestBody.getContent().containsKey(org.springframework.http.MediaType.MULTIPART_FORM_DATA_VALUE)) {
io.swagger.v3.oas.models.media.Schema<?> mergedSchema = requestBodyInfo.getMergedSchema();
Iterator<Entry<String, Parameter>> it = map.entrySet().iterator();
while (it.hasNext()) {
Entry<String, Parameter> entry = it.next();
Parameter parameter = entry.getValue();
if (!ParameterIn.PATH.toString().equals(parameter.getIn())) {
io.swagger.v3.oas.models.media.Schema<?> itemSchema = new io.swagger.v3.oas.models.media.Schema() ;
io.swagger.v3.oas.models.media.Schema<?> itemSchema = new io.swagger.v3.oas.models.media.Schema<>() ;
itemSchema.setName(entry.getKey());
itemSchema.setDescription(parameter.getDescription());
itemSchema.setDeprecated(parameter.getDeprecated());
if (parameter.getExample() != null)
itemSchema.setExample(parameter.getExample());
mergedSchema.addProperty(entry.getKey(), itemSchema);
requestBodyInfo.addProperties(entry.getKey(), itemSchema);
it.remove();
}
}
Expand Down

0 comments on commit aaf92ab

Please sign in to comment.