From aaf92abed34ddf978c6f058fbfb3d263d0541e66 Mon Sep 17 00:00:00 2001 From: "Badr.NassLahsen" Date: Sat, 20 Aug 2022 22:18:03 +0200 Subject: [PATCH] NPE for request bodies with content that has media type MULTIPART_FORM_DATA_VALUE. Fixes #1804 --- .../java/org/springdoc/core/AbstractRequestService.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestService.java b/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestService.java index 2b3a7d49e..87469e4ab 100644 --- a/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestService.java +++ b/springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractRequestService.java @@ -198,7 +198,6 @@ protected AbstractRequestService(GenericParameterService parameterBuilder, Reque this.localSpringDocParameterNameDiscoverer = localSpringDocParameterNameDiscoverer; this.defaultFlatParamObject = parameterBuilder.getPropertyResolverUtils().getSpringDocConfigProperties().isDefaultFlatParamObject(); this.defaultSupportFormData = parameterBuilder.getPropertyResolverUtils().getSpringDocConfigProperties().isDefaultSupportFormData(); - } /** @@ -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> it = map.entrySet().iterator(); while (it.hasNext()) { Entry 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(); } }