A Research Data Repository Service for Managing Metadata Documents based on JSON or XML.
The following example shows the creation of the first json schema only providing mandatory fields mentioned above:
schema-record4json.json:
{
"id": "my_first_json",
"titles": [
{
"value": "Title for my_first_json",
}
]
}
schema.json:
{
"$schema": "http://json-schema.org/draft/2019-09/schema#",
"$id": "http://www.example.org/schema/json",
"type": "object",
"title": "Json schema for tests",
"default": {},
"required": [
"title"
],
"properties": {
"title": {
"$id": "#/properties/string",
"type": "string",
"title": "Title",
"description": "Title of object."
}
},
"additionalProperties": false
}
$$ curl 'http://localhost:8040/metastore/api/v2/schemas/' -i -X POST \
-H 'Content-Type: multipart/form-data' \
-F 'schema=@schema.json;type=application/json' \
-F 'record=@schema-record4json.json;type=application/json'
You can see, that most of the sent metadata schema record is empty. Only schemaId, mimeType and type are provided by the user. HTTP-wise the call looks as follows:
POST /metastore/api/v2/schemas/ HTTP/1.1
Content-Type: multipart/form-data; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Host: localhost:8040
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=schema; filename=schema.json
Content-Type: application/json
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "http://www.example.org/schema/json",
"type": "object",
"title": "Json schema for tests",
"default": {},
"required": [
"title"
],
"properties": {
"title": {
"type": "string",
"title": "Title",
"description": "Title of object."
}
},
"additionalProperties": false
}
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=record; filename=schema-record4json.json
Content-Type: application/json
{"id":"my_first_json","identifier":null,"creators":[],"titles":[{"id":null,"value":"Title for my_first_json","titleType":null,"lang":null}],"publisher":null,"publicationYear":null,"resourceType":null,"subjects":[],"contributors":[],"dates":[],"relatedIdentifiers":[],"descriptions":[],"geoLocations":[],"language":null,"alternateIdentifiers":[],"sizes":[],"formats":[],"version":null,"rights":[],"fundingReferences":[],"lastUpdate":null,"state":null,"embargoDate":null,"acls":[]}
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--
As Content-Type only ‘application/json’ is supported and should be provided. The other headers are typically set by the HTTP client. After validating the provided document, adding missing information where possible and persisting the created resource, the result is sent back to the user and will look that way:
HTTP/1.1 201 Created
Location: http://localhost:8040/metastore/api/v2/schemas/my_first_json?version=1
ETag: "855670887"
Content-Type: application/json
Content-Length: 806
{
"id" : "my_first_json",
"identifier" : {
"id" : 1,
"value" : "(:tba)",
"identifierType" : "DOI"
},
"creators" : [ {
"id" : 1,
"givenName" : "SELF"
} ],
"titles" : [ {
"id" : 1,
"value" : "Title for my_first_json"
} ],
"publisher" : "SELF",
"publicationYear" : "2024",
"resourceType" : {
"id" : 1,
"value" : "JSON_Schema",
"typeGeneral" : "MODEL"
},
"dates" : [ {
"id" : 1,
"value" : "2024-11-25T13:50:05Z",
"type" : "CREATED"
} ],
"alternateIdentifiers" : [ {
"id" : 1,
"value" : "my_first_json",
"identifierType" : "INTERNAL"
} ],
"version" : "1",
"lastUpdate" : "2024-11-25T13:50:05.753Z",
"state" : "VOLATILE",
"acls" : [ {
"id" : 1,
"sid" : "SELF",
"permission" : "ADMINISTRATE"
} ]
}
What you see is, that the datacite record looks different from the original document. Some of the elements received a value by the server. Furthermore, you’ll find an ETag header with the current ETag of the resource. This value is returned by POST, GET and PUT calls and must be provided for all calls modifying the resource, e.g. POST, PUT and DELETE, in order to avoid conflicts.
There are two possible values for DataResource: ‘XML_Schema’ and ‘JSON_Schema’ which depends on the format of the given schema document. (JSON in our case.) As the schema document has a defined structure “MODEL” is used as ‘typeGeneral’.
« PREVIOUS | NEXT » |
---|---|