Search in sources :

Example 1 with RouterBuilderException

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);
    }
}
Also used : JsonMapper(com.fasterxml.jackson.databind.json.JsonMapper) RouterBuilderException(io.vertx.ext.web.openapi.RouterBuilderException) YAMLMapper(com.fasterxml.jackson.dataformat.yaml.YAMLMapper) JsonObject(io.vertx.core.json.JsonObject) JsonNode(com.fasterxml.jackson.databind.JsonNode) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 JsonMapper (com.fasterxml.jackson.databind.json.JsonMapper)1 YAMLMapper (com.fasterxml.jackson.dataformat.yaml.YAMLMapper)1 JsonObject (io.vertx.core.json.JsonObject)1 RouterBuilderException (io.vertx.ext.web.openapi.RouterBuilderException)1