[Dump Schemas] changed the schema of the dumped result according to the modifications in the bestAccessRight type

This commit is contained in:
Miriam Baglioni 2021-11-12 11:45:38 +01:00
parent 43cae4ad88
commit 6595135a1a
2 changed files with 41 additions and 58 deletions

View File

@ -1,34 +1,7 @@
{ {
"$schema": "http://json-schema.org/draft-07/schema#", "$schema": "http://json-schema.org/draft-07/schema#",
"definitions": { "definitions": {
"AccessRight":{ "ControlledField": {
"type":"object",
"properties":{
"code": {
"type": "string",
"description": "COAR access mode code: http://vocabularies.coar-repositories.org/documentation/access_rights/"
},
"label": {
"type": "string",
"description": "Label for the access mode"
},
"openAccessRoute":{
"type":"string",
"enum":[
"gold",
"green",
"hybrid",
"bronze"
],
"description":"The type of OpenAccess applied to the result"
},
"scheme": {
"type": "string",
"description": "Scheme of reference for access right code. Always set to COAR access rights vocabulary: http://vocabularies.coar-repositories.org/documentation/access_rights/"
}
}
},
"ControlledField": {
"type": "object", "type": "object",
"properties": { "properties": {
"scheme": { "scheme": {
@ -94,14 +67,21 @@
} }
}, },
"bestaccessright":{ "bestaccessright":{
"allOf":[ "type":"object",
{ "properties":{
"$ref":"#/definitions/AccessRight" "code": {
}, "type": "string",
{ "description": "COAR access mode code: http://vocabularies.coar-repositories.org/documentation/access_rights/"
"description":"The openest access right associated to the manifestations of this research results" },
} "label": {
] "type": "string",
"description": "Label for the access mode"
},
"scheme": {
"type": "string",
"description": "Scheme of reference for access right code. Always set to COAR access rights vocabulary: http://vocabularies.coar-repositories.org/documentation/access_rights/"
}
}
}, },
"codeRepositoryUrl": { "codeRepositoryUrl": {
"type": "string", "type": "string",
@ -255,29 +235,32 @@
"type":"object", "type":"object",
"properties":{ "properties":{
"accessright":{ "accessright":{
"allOf":[ "type":"object",
{ "properties":{
"$ref":"#/definitions/AccessRight" "code": {
"type": "string",
"description": "COAR access mode code: http://vocabularies.coar-repositories.org/documentation/access_rights/"
}, },
{ "label": {
"description":"The accessright of this instance. One result may have multiple instances, each with a different accessright" "type": "string",
"description": "Label for the access mode"
},
"openAccessRoute":{
"type":"string",
"enum":[
"gold",
"green",
"hybrid",
"bronze"
],
"description":"The type of OpenAccess applied to the result"
},
"scheme": {
"type": "string",
"description": "Scheme of reference for access right code. Always set to COAR access rights vocabulary: http://vocabularies.coar-repositories.org/documentation/access_rights/"
} }
] }
}, },
"alternateIdentifier":{
"description":"All the identifiers associated to the result other than the authoritative ones",
"type":"array",
"items":{
"allOf":[
{
"$ref":"#/definitions/ControlledField"
},
{
"description":"Description of alternateIdentifier"
}
]
}
},
"articleprocessingcharge":{ "articleprocessingcharge":{
"description": "The money spent to make this book or article available in Open Access. Source for this information is the OpenAPC initiative.", "description": "The money spent to make this book or article available in Open Access. Source for this information is the OpenAPC initiative.",
"type":"object", "type":"object",

View File

@ -9,7 +9,7 @@ import com.github.victools.jsonschema.generator.*;
import eu.dnetlib.dhp.schema.dump.oaf.graph.*; import eu.dnetlib.dhp.schema.dump.oaf.graph.*;
@Disabled //@Disabled
class GenerateJsonSchema { class GenerateJsonSchema {
@Test @Test
@ -21,7 +21,7 @@ class GenerateJsonSchema {
configBuilder.forFields().withDescriptionResolver(field -> "Description of " + field.getDeclaredName()); configBuilder.forFields().withDescriptionResolver(field -> "Description of " + field.getDeclaredName());
SchemaGeneratorConfig config = configBuilder.build(); SchemaGeneratorConfig config = configBuilder.build();
SchemaGenerator generator = new SchemaGenerator(config); SchemaGenerator generator = new SchemaGenerator(config);
JsonNode jsonSchema = generator.generateSchema(Relation.class); JsonNode jsonSchema = generator.generateSchema(GraphResult.class);
System.out.println(jsonSchema.toString()); System.out.println(jsonSchema.toString());
} }