|
30 | 30 | import io.swagger.v3.core.util.AnnotationsUtils;
|
31 | 31 | import io.swagger.v3.oas.models.Components;
|
32 | 32 | import io.swagger.v3.oas.models.media.Content;
|
| 33 | +import io.swagger.v3.oas.models.media.MediaType; |
33 | 34 | import io.swagger.v3.oas.models.media.Schema;
|
34 | 35 | import io.swagger.v3.oas.models.parameters.RequestBody;
|
35 | 36 | import org.apache.commons.lang3.StringUtils;
|
@@ -131,7 +132,7 @@ public Optional<RequestBody> buildRequestBodyFromDoc(
|
131 | 132 | */
|
132 | 133 | 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) {
|
133 | 134 | Optional<Content> optionalContent = SpringDocAnnotationsUtils
|
134 |
| - .getContent(requestBody.content(),getConsumes(classConsumes), |
| 135 | + .getContent(requestBody.content(), getConsumes(classConsumes), |
135 | 136 | getConsumes(methodConsumes), null, components, jsonViewAnnotation);
|
136 | 137 | if (requestBodyOp == null) {
|
137 | 138 | if (optionalContent.isPresent()) {
|
@@ -243,7 +244,7 @@ public void calculateRequestBodyInfo(Components components, MethodAttributes met
|
243 | 244 |
|
244 | 245 | RequestPart requestPart = methodParameter.getParameterAnnotation(RequestPart.class);
|
245 | 246 | String paramName = null;
|
246 |
| - if (requestPart != null){ |
| 247 | + if (requestPart != null) { |
247 | 248 | paramName = StringUtils.defaultIfEmpty(requestPart.value(), requestPart.name());
|
248 | 249 | parameterInfo.setRequired(requestPart.required());
|
249 | 250 | parameterInfo.setRequestPart(true);
|
@@ -323,10 +324,14 @@ private void buildContent(RequestBody requestBody, MethodAttributes methodAttrib
|
323 | 324 | for (String value : methodAttributes.getMethodConsumes()) {
|
324 | 325 | io.swagger.v3.oas.models.media.MediaType mediaTypeObject = new io.swagger.v3.oas.models.media.MediaType();
|
325 | 326 | mediaTypeObject.setSchema(schema);
|
326 |
| - if (content.get(value) != null) { |
327 |
| - mediaTypeObject.setExample(content.get(value).getExample()); |
328 |
| - mediaTypeObject.setExamples(content.get(value).getExamples()); |
329 |
| - mediaTypeObject.setEncoding(content.get(value).getEncoding()); |
| 327 | + MediaType mediaType = content.get(value); |
| 328 | + if (mediaType != null) { |
| 329 | + if (mediaType.getExample() != null) |
| 330 | + mediaTypeObject.setExample(mediaType.getExample()); |
| 331 | + if (mediaType.getExamples() != null) |
| 332 | + mediaTypeObject.setExamples(mediaType.getExamples()); |
| 333 | + if (mediaType.getEncoding() != null) |
| 334 | + mediaTypeObject.setEncoding(mediaType.getEncoding()); |
330 | 335 | }
|
331 | 336 | content.addMediaType(value, mediaTypeObject);
|
332 | 337 | }
|
|
0 commit comments