dnet-hadoop/dhp-workflows/dhp-graph-mapper/src/test/java/eu/dnetlib/dhp/oa/graph/dump/GenerateJsonSchema.java

29 lines
916 B
Java
Raw Normal View History

2020-07-29 17:06:53 +02:00
2020-07-08 12:52:00 +02:00
package eu.dnetlib.dhp.oa.graph.dump;
2020-08-13 12:18:13 +02:00
import org.junit.jupiter.api.Disabled;
2020-07-29 17:06:53 +02:00
import org.junit.jupiter.api.Test;
2020-07-08 12:52:00 +02:00
import com.fasterxml.jackson.databind.JsonNode;
import com.github.victools.jsonschema.generator.*;
2020-07-29 17:06:53 +02:00
2020-08-13 12:18:13 +02:00
import eu.dnetlib.dhp.schema.dump.oaf.graph.*;
2020-07-08 12:52:00 +02:00
//@Disabled
2021-08-11 12:13:22 +02:00
class GenerateJsonSchema {
2020-07-08 12:52:00 +02:00
2020-07-29 17:06:53 +02:00
@Test
2021-08-11 12:13:22 +02:00
void generateSchema() {
2020-07-29 17:06:53 +02:00
SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_7,
OptionPreset.PLAIN_JSON)
.with(Option.SCHEMA_VERSION_INDICATOR)
.without(Option.NONPUBLIC_NONSTATIC_FIELDS_WITHOUT_GETTERS);
configBuilder.forFields().withDescriptionResolver(field -> "Description of " + field.getDeclaredName());
SchemaGeneratorConfig config = configBuilder.build();
SchemaGenerator generator = new SchemaGenerator(config);
JsonNode jsonSchema = generator.generateSchema(GraphResult.class);
2020-07-08 12:52:00 +02:00
2020-07-29 17:06:53 +02:00
System.out.println(jsonSchema.toString());
}
2020-07-08 12:52:00 +02:00
}