in oas-generator/oas-generator-core/src/main/java/org/apache/servicecomb/toolkit/generator/util/SwaggerAnnotationUtils.java [35:61]
public static List<Content> getContentFromAnnotation(
io.swagger.v3.oas.annotations.media.Content... contentAnnotations) {
if (contentAnnotations == null || contentAnnotations.length < 1) {
return null;
}
List<Content> contents = new ArrayList<>();
for (io.swagger.v3.oas.annotations.media.Content contentAnnotation : contentAnnotations) {
io.swagger.v3.oas.models.media.Content content = new io.swagger.v3.oas.models.media.Content();
MediaType mediaType = new MediaType();
Encoding[] encodingAnnotations = contentAnnotation.encoding();
Optional.ofNullable(encodingAnnotations).ifPresent(encodings -> {
for (Encoding encodingAnnotation : encodings) {
io.swagger.v3.oas.models.media.Encoding encoding = new io.swagger.v3.oas.models.media.Encoding();
encoding.contentType(encodingAnnotation.contentType());
encoding.allowReserved(encodingAnnotation.allowReserved());
encoding.explode(encodingAnnotation.explode());
mediaType.addEncoding(encodingAnnotation.name(), encoding);
}
});
content.addMediaType(contentAnnotation.mediaType(), mediaType);
contents.add(content);
}
return contents;
}