forked from D-Net/dnet-hadoop
Merge branch 'dump' of code-repo.d4science.org:miriam.baglioni/dnet-hadoop into dump
This commit is contained in:
commit
f9ad6f3255
|
@ -76,6 +76,12 @@
|
||||||
<artifactId>okhttp</artifactId>
|
<artifactId>okhttp</artifactId>
|
||||||
<version>4.7.2</version>
|
<version>4.7.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.victools</groupId>
|
||||||
|
<artifactId>jsonschema-generator</artifactId>
|
||||||
|
<version>4.13.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,22 @@
|
||||||
|
package eu.dnetlib.dhp.oa.graph.dump;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
|
import com.github.victools.jsonschema.generator.*;
|
||||||
|
import eu.dnetlib.dhp.schema.dump.oaf.Result;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class GenerateJsonSchema {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public 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(Result.class);
|
||||||
|
|
||||||
|
System.out.println(jsonSchema.toString());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue