当前位置: 首页>>代码示例>>Java>>正文


Java MediaType类代码示例

本文整理汇总了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();
}
 
开发者ID:quen2404,项目名称:openapi-diff,代码行数:21,代码来源:ContentDiff.java

示例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))));
                }
            });
}
 
开发者ID:anton-tregubov,项目名称:javaee-design-patterns,代码行数:34,代码来源:OpenApiUpdater.java

示例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));
}
 
开发者ID:quen2404,项目名称:openapi-diff,代码行数:4,代码来源:HtmlRender.java

示例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));
}
 
开发者ID:quen2404,项目名称:openapi-diff,代码行数:4,代码来源:HtmlRender.java

示例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();
}
 
开发者ID:quen2404,项目名称:openapi-diff,代码行数:6,代码来源:MarkdownRender.java

示例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();
}
 
开发者ID:quen2404,项目名称:openapi-diff,代码行数:6,代码来源:MarkdownRender.java

示例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());
}
 
开发者ID:vert-x3,项目名称:vertx-web,代码行数:7,代码来源:OpenApi3Utils.java


注:本文中的io.swagger.v3.oas.models.media.MediaType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。