This commit is contained in:
Claudio Atzori 2021-12-01 09:29:01 +01:00
commit 923c0ff803
3 changed files with 37 additions and 4 deletions

View File

@ -360,7 +360,12 @@
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
</dependency>
<dependency>
<groupId>com.github.victools</groupId>
<artifactId>jsonschema-generator</artifactId>
<version>${jsonschemagenerator.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
@ -377,6 +382,7 @@
<scala.version>2.11.12</scala.version>
<junit-jupiter.version>5.6.1</junit-jupiter.version>
<mockito-core.version>3.3.3</mockito-core.version>
<jsonschemagenerator.version>4.13.0</jsonschemagenerator.version>
</properties>

View File

@ -93,7 +93,7 @@ public class Datasource implements Serializable {
private String certificates; // string
private List<Object> policies; //
private List<String> policies; //
private Container journal; // issn etc del Journal
@ -297,11 +297,11 @@ public class Datasource implements Serializable {
this.certificates = certificates;
}
public List<Object> getPolicies() {
public List<String> getPolicies() {
return policies;
}
public void setPolicies(List<Object> policiesr3) {
public void setPolicies(List<String> policiesr3) {
this.policies = policiesr3;
}

View File

@ -0,0 +1,27 @@
package eu.dnetlib.dhp.schema.oaf.dump;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.github.victools.jsonschema.generator.*;
import eu.dnetlib.dhp.schema.dump.oaf.graph.*;
@Disabled
class GenerateJsonSchema {
@Test
void generateSchema() {
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);
System.out.println(jsonSchema.toString());
}
}