use of io.vertx.ext.web.openapi.RouterBuilderException in project vertx-web by vert-x3.
the class ContractEndpointHandler method create.
public static ContractEndpointHandler create(OpenAPIHolder holder) {
JsonObject openapi = holder.getOpenAPI();
ObjectMapper jsonMapper = new JsonMapper();
try {
JsonNode node = jsonMapper.readTree(openapi.toString());
ObjectMapper yamlMapper = new YAMLMapper();
byte[] yamlBytes = yamlMapper.writeValueAsBytes(node);
return new ContractEndpointHandler(openapi.toBuffer(), Buffer.buffer(yamlBytes));
} catch (JsonProcessingException e) {
e.printStackTrace();
throw new RouterBuilderException("Cannot generate yaml contract", ErrorType.UNSUPPORTED_SPEC, e);
}
}
Aggregations