本文整理汇总了Java中io.swagger.v3.oas.models.media.MediaType类的典型用法代码示例。如果您正苦于以下问题:Java MediaType类的具体用法?Java MediaType怎么用?Java MediaType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MediaType类属于io.swagger.v3.oas.models.media包,在下文中一共展示了MediaType类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: diff
import io.swagger.v3.oas.models.media.MediaType; //导入依赖的package包/类
public Optional<ChangedContent> diff(Content left, Content right) {
ChangedContent changedContent = new ChangedContent(left, right);
MapKeyDiff<String, MediaType> mediaTypeDiff = MapKeyDiff.diff(left, right);
changedContent.setIncreased(mediaTypeDiff.getIncreased());
changedContent.setMissing(mediaTypeDiff.getMissing());
List<String> sharedMediaTypes = mediaTypeDiff.getSharedKey();
Map<String, ChangedMediaType> changedMediaTypes = new HashMap<>();
for (String mediaTypeKey : sharedMediaTypes) {
MediaType oldMediaType = left.get(mediaTypeKey);
MediaType newMediaType = right.get(mediaTypeKey);
ChangedMediaType changedMediaType = new ChangedMediaType(oldMediaType.getSchema(), newMediaType.getSchema());
openApiDiff.getSchemaDiff().diff(oldMediaType.getSchema(), newMediaType.getSchema()).ifPresent(changedMediaType::setChangedSchema);
if (changedMediaType.isDiff()) {
changedMediaTypes.put(mediaTypeKey, changedMediaType);
}
}
changedContent.setChanged(changedMediaTypes);
return changedContent.isDiff() ? Optional.of(changedContent) : Optional.empty();
}
示例2: afterScan
import io.swagger.v3.oas.models.media.MediaType; //导入依赖的package包/类
@Override
public void afterScan(Reader reader, OpenAPI openAPI) {
openAPI.info(
new Info()
.title("Simple Project Api")
.version(getClass().getPackage().getImplementationVersion())
);
openAPI.servers(Collections.singletonList(new Server().description("Current Server").url(CDI.current().select(ServletContext.class).get().getContextPath())));
//error
Schema errorObject = ModelConverters.getInstance().readAllAsResolvedSchema(ErrorValueObject.class).schema;
openAPI.getComponents().addSchemas("Error", errorObject);
openAPI.getPaths()
.values()
.stream()
.flatMap(pathItem -> pathItem.readOperations().stream())
.forEach(operation -> {
ApiResponses responses = operation.getResponses();
responses
.addApiResponse(String.valueOf(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()),
new ApiResponse().description("Unexpected exception. Error code = 1")
.content(
new Content().addMediaType(javax.ws.rs.core.MediaType.APPLICATION_JSON, new MediaType()
.schema(errorObject))));
if (operation.getParameters() != null && !operation.getParameters().isEmpty()) {
responses
.addApiResponse(String.valueOf(Response.Status.BAD_REQUEST.getStatusCode()),
new ApiResponse().description("Bad request. Error code = 2")
.content(
new Content().addMediaType(javax.ws.rs.core.MediaType.APPLICATION_JSON, new MediaType()
.schema(errorObject))));
}
});
}
示例3: li_addRequest
import io.swagger.v3.oas.models.media.MediaType; //导入依赖的package包/类
private ContainerTag li_addRequest(String name, MediaType request) {
return li().withText(String.format("New body: '%s'", name));
}
示例4: li_missingRequest
import io.swagger.v3.oas.models.media.MediaType; //导入依赖的package包/类
private ContainerTag li_missingRequest(String name, MediaType request) {
return li().withText(String.format("Deleted body: '%s'", name));
}
示例5: listContent
import io.swagger.v3.oas.models.media.MediaType; //导入依赖的package包/类
private String listContent(String prefix, String title, Map<String, MediaType> mediaTypes) {
StringBuilder sb = new StringBuilder();
mediaTypes.entrySet().stream().map(e -> this.itemContent(title, e.getKey(), e.getValue())).forEach(e -> sb.append(prefix).append(e));
return sb.toString();
}
示例6: itemContent
import io.swagger.v3.oas.models.media.MediaType; //导入依赖的package包/类
private String itemContent(String title, String mediaType, MediaType content) {
StringBuilder sb = new StringBuilder("");
sb.append(itemContent(title, mediaType));
return sb.toString();
}
示例7: extractTypesFromMediaTypesMap
import io.swagger.v3.oas.models.media.MediaType; //导入依赖的package包/类
public static List<MediaType> extractTypesFromMediaTypesMap(Map<String, MediaType> types, Predicate<String> matchingFunction) {
return types
.entrySet().stream()
.filter(e -> matchingFunction.test(e.getKey()))
.map(Map.Entry::getValue).collect(Collectors.toList());
}