gpt4 book ai didi

io.swagger.util.Yaml.pretty()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 00:48:40 28 4
gpt4 key购买 nike

本文整理了Java中io.swagger.util.Yaml.pretty()方法的一些代码示例,展示了Yaml.pretty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Yaml.pretty()方法的具体详情如下:
包路径:io.swagger.util.Yaml
类名称:Yaml
方法名:pretty

Yaml.pretty介绍

暂无

代码示例

代码示例来源:origin: blox/blox

@TaskAction
public void generateSpec() throws IOException, GenerateException {
 ClassLoader loader = projectClassLoader();
 Set<Class<?>> classes = new HashSet<>();
 for (String pkg : apiPackages) {
  Reflections reflections =
    new Reflections(
      new ConfigurationBuilder()
        .addClassLoaders(loader)
        .addUrls(ClasspathHelper.forPackage(pkg, loader))
        .setExpandSuperTypes(false)
        .filterInputsBy(new FilterBuilder().includePackage(pkg)));
  Set<Class<?>> springMVCClasses =
    reflections.getTypesAnnotatedWith(
      org.springframework.web.bind.annotation.RestController.class);
  classes.addAll(springMVCClasses);
 }
 SpringMvcApiReader reader = new SpringMvcApiReader(new Swagger(), log);
 Swagger swagger = reader.read(classes);
 for (SwaggerFilter filter : filters) {
  filter.apply(swagger);
 }
 Yaml.pretty().writeValue(swaggerFile, swagger);
}

代码示例来源:origin: kongchen/swagger-maven-plugin

break;
case yaml:
  FileUtils.write(new File(dir, fileName + ".yaml"), Yaml.pretty().writeValueAsString(swagger), encoding);
  break;

代码示例来源:origin: com.github.phillip-kruger/apiee-core

private String generateYaml(int hash,final Set<Class<?>> classes,URL url){
  log.log(Level.FINEST, "Generating {0} response for context", url);
  Swagger swagger = createSwagger(classes,url);
  try {
    String swaggerYaml = Yaml.pretty().writeValueAsString(swagger);
    swaggerMap.put(hash, new CachedDocument(hash,url,swaggerYaml));
    return swaggerYaml;
  } catch (JsonProcessingException ex) {
    log.log(Level.WARNING, "Could not generate {0} - {1}", new Object[]{url.toString(), ex.getMessage()});
  }
  log.log(Level.WARNING, "Could not generate {0} - null", new Object[]{url.toString()});
  return null;
}

代码示例来源:origin: com.holon-platform.jaxrs/holon-jaxrs-swagger-v2

/**
 * Convert given API definition in YAML format.
 * @param api The API model to serialize
 * @param pretty Whether to pretty format the output
 * @return The API definition as YAML
 */
static String asYaml(Swagger api, boolean pretty) {
  try {
    return pretty ? Yaml.pretty().writeValueAsString(api) : Yaml.mapper().writeValueAsString(api);
  } catch (Exception e) {
    throw new ApiConfigurationException(e);
  }
}

代码示例来源:origin: com.holon-platform.jaxrs/holon-jaxrs-swagger-v2

@Override
protected String getApiOutput(OutputType outputType, Swagger api, boolean pretty) throws Exception {
  switch (outputType) {
  case YAML:
    return pretty ? Yaml.pretty().writeValueAsString(api) : Yaml.mapper().writeValueAsString(api);
  case JSON:
  default:
    return pretty ? Json.pretty(api) : Json.mapper().writeValueAsString(api);
  }
}

代码示例来源:origin: apache/cxf

writer.write(jsonWriter.writeValueAsString(swagger));
} else if ("yaml".equals(this.payload)) {
  writer.write(Yaml.pretty().writeValueAsString(swagger));

代码示例来源:origin: gitblit/fathom

if (settings.isDev()) {
  yaml = Yaml.pretty().writeValueAsString(swagger);
} else {
  yaml = Yaml.mapper().writeValueAsString(swagger);

代码示例来源:origin: com.gitblit.fathom/fathom-rest-swagger

if (settings.isDev()) {
  yaml = Yaml.pretty().writeValueAsString(swagger);
} else {
  yaml = Yaml.mapper().writeValueAsString(swagger);

代码示例来源:origin: io.swagger/swagger-jaxrs

headers.add("Content-Type", "application/yaml");
if (prettyPrint) {
  out.write(Yaml.pretty().writeValueAsBytes(data));
} else {
  out.write(Yaml.mapper().writeValueAsBytes(data));

代码示例来源:origin: com.vmware.xenon/xenon-swagger

this.get.addResponseHeader(Operation.CONTENT_TYPE_HEADER,
      Operation.MEDIA_TYPE_TEXT_YAML);
  writer = Yaml.pretty();
} else {
  this.get.addResponseHeader(Operation.CONTENT_TYPE_HEADER,

代码示例来源:origin: gravitee-io/gravitee-management-rest-api

page.setContent(Yaml.pretty().writeValueAsString(swagger));
} catch (JsonProcessingException e) {
  logger.error("Unexpected error", e);

代码示例来源:origin: io.gravitee.management/gravitee-management-api-service

page.setContent(Yaml.pretty().writeValueAsString(swagger));
} catch (JsonProcessingException e) {
  logger.error("Unexpected error", e);

代码示例来源:origin: org.jooby/jooby-swagger

/**
 * Publish application routes as Swagger spec.
 *
 * @param app An application.
 */
public void install(final Jooby app) {
 requireNonNull(app, "Application is required.");
 ObjectMapper mapper = Json.mapper();
 ObjectWriter yaml = Yaml.pretty();
 app.use(new SwaggerModule(mapper));
 app.get(path + "/swagger.json", path + "/:tag/swagger.json", req -> {
  SwaggerBuilder sb = req.require(SwaggerBuilder.class);
  Swagger swagger = sb.build(req.param("tag").toOptional(), predicate, tag, Swagger.class);
  byte[] json = mapper.writer().withDefaultPrettyPrinter().writeValueAsBytes(swagger);
  return Results.json(json);
 }).name("swagger(json)");
 app.get(path + "/swagger.yml", path + "/:tag/swagger.yml", req -> {
  SwaggerBuilder sb = req.require(SwaggerBuilder.class);
  Swagger swagger = sb.build(req.param("tag").toOptional(), predicate, tag, SwaggerYml.class);
  byte[] yml = yaml.writeValueAsBytes(swagger);
  return Results.ok(yml).type("application/yaml");
 }).name("swagger(yml)");
 if (ui) {
  app.assets(path + "/ui/**",
    "/META-INF/resources/webjars/swagger-ui/" + wjversion(app.getClass()) + "/{0}");
  app.get(path, path + "/:tag", new SwaggerHandler(path))
    .name("swagger(html)")
    .produces(MediaType.html);
 }
}

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com