List of usage examples for com.fasterxml.jackson.module.jsonSchema JsonSchema getId
public String getId()
From source file:io.gravitee.maven.plugins.json.schema.generator.mojo.Output.java
/** * Create the JSON file associated to the JSON Schema * * @param schema the JSON schema to write into file *///from w w w .j a v a 2 s . c o m private void createJsonFile(JsonSchema schema) { try { ObjectMapper mapper = new ObjectMapper(); String json = mapper.writerWithDefaultPrettyPrinter().writeValueAsString(schema); // replace all : with _ this is a reserved character in some file systems Path outputPath = Paths.get( config.getOutputDirectory() + File.separator + schema.getId().replaceAll(":", "_") + ".json"); Files.write(outputPath, json.getBytes(), StandardOpenOption.WRITE, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); config.getLogger().info("Created JSON Schema: " + outputPath.normalize().toAbsolutePath().toString()); } catch (JsonProcessingException e) { config.getLogger().warn("Unable to display schema " + schema.getId(), e); } catch (Exception e) { config.getLogger().warn("Unable to write Json file for schema " + schema.getId(), e); } }