added class for schema of relations

This commit is contained in:
Miriam Baglioni 2023-01-26 18:30:46 +01:00
parent 64511dad2c
commit da2e0bb1db
1 changed files with 18 additions and 0 deletions

View File

@ -1,5 +1,6 @@
import java.io.IOException;
import eu.dnetlib.dhp.eosc.model.Relation;
import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.core.JsonProcessingException;
@ -63,6 +64,23 @@ class GenerateJsonSchema {
System.out.println(new ObjectMapper().writeValueAsString(jsonSchema));
}
@Test
void generateSchemaEoscRelation() throws JsonProcessingException {
ObjectMapper objectMapper = new ObjectMapper();
AddonModule module = new AddonModule();
SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(objectMapper,
SchemaVersion.DRAFT_7, OptionPreset.PLAIN_JSON)
.with(module)
.with(Option.SCHEMA_VERSION_INDICATOR)
.without(Option.NONPUBLIC_NONSTATIC_FIELDS_WITHOUT_GETTERS);
SchemaGeneratorConfig config = configBuilder.build();
SchemaGenerator generator = new SchemaGenerator(config);
JsonNode jsonSchema = generator.generateSchema(Relation.class);
System.out.println(new ObjectMapper().writeValueAsString(jsonSchema));
}
@Test
void generateJsonSchema3() throws IOException {