|
28 | 28 | import io.swagger.v3.core.util.AnnotationsUtils;
|
29 | 29 | import io.swagger.v3.oas.models.Components;
|
30 | 30 | import io.swagger.v3.oas.models.media.Content;
|
| 31 | +import io.swagger.v3.oas.models.media.MediaType; |
31 | 32 | import io.swagger.v3.oas.models.media.Schema;
|
32 | 33 | import io.swagger.v3.oas.models.parameters.RequestBody;
|
33 | 34 | import org.apache.commons.lang3.StringUtils;
|
@@ -125,7 +126,7 @@ public Optional<RequestBody> buildRequestBodyFromDoc(
|
125 | 126 | */
|
126 | 127 | private void buildResquestBodyContent(io.swagger.v3.oas.annotations.parameters.RequestBody requestBody, RequestBody requestBodyOp, MethodAttributes methodAttributes, Components components, JsonView jsonViewAnnotation, String[] classConsumes, String[] methodConsumes, RequestBody requestBodyObject) {
|
127 | 128 | Optional<Content> optionalContent = SpringDocAnnotationsUtils
|
128 |
| - .getContent(requestBody.content(),getConsumes(classConsumes), |
| 129 | + .getContent(requestBody.content(), getConsumes(classConsumes), |
129 | 130 | getConsumes(methodConsumes), null, components, jsonViewAnnotation);
|
130 | 131 | if (requestBodyOp == null) {
|
131 | 132 | if (optionalContent.isPresent()) {
|
@@ -237,7 +238,7 @@ public void calculateRequestBodyInfo(Components components, MethodAttributes met
|
237 | 238 |
|
238 | 239 | RequestPart requestPart = methodParameter.getParameterAnnotation(RequestPart.class);
|
239 | 240 | String paramName = null;
|
240 |
| - if (requestPart != null){ |
| 241 | + if (requestPart != null) { |
241 | 242 | paramName = StringUtils.defaultIfEmpty(requestPart.value(), requestPart.name());
|
242 | 243 | parameterInfo.setRequired(requestPart.required());
|
243 | 244 | parameterInfo.setRequestPart(true);
|
@@ -317,10 +318,14 @@ private void buildContent(RequestBody requestBody, MethodAttributes methodAttrib
|
317 | 318 | for (String value : methodAttributes.getMethodConsumes()) {
|
318 | 319 | io.swagger.v3.oas.models.media.MediaType mediaTypeObject = new io.swagger.v3.oas.models.media.MediaType();
|
319 | 320 | mediaTypeObject.setSchema(schema);
|
320 |
| - if (content.get(value) != null) { |
321 |
| - mediaTypeObject.setExample(content.get(value).getExample()); |
322 |
| - mediaTypeObject.setExamples(content.get(value).getExamples()); |
323 |
| - mediaTypeObject.setEncoding(content.get(value).getEncoding()); |
| 321 | + MediaType mediaType = content.get(value); |
| 322 | + if (mediaType != null) { |
| 323 | + if (mediaType.getExample() != null) |
| 324 | + mediaTypeObject.setExample(mediaType.getExample()); |
| 325 | + if (mediaType.getExamples() != null) |
| 326 | + mediaTypeObject.setExamples(mediaType.getExamples()); |
| 327 | + if (mediaType.getEncoding() != null) |
| 328 | + mediaTypeObject.setEncoding(mediaType.getEncoding()); |
324 | 329 | }
|
325 | 330 | content.addMediaType(value, mediaTypeObject);
|
326 | 331 | }
|
|
0 commit comments