Updating a Metadata Schema Document

A Research Data Repository Service for Managing Metadata Documents based on JSON or XML.

Updating a Metadata Schema Document

NOTE
Updating a metadata schema document will not break old metadata documents. As every update results in a new version ‘old’ metadata schema documents are still available.

For updating an existing metadata schema (record) a valid ETag is needed. The actual ETag is available via the HTTP GET call of the metadata schema record. (see above) Just send an HTTP POST with the updated metadata schema document and/or metadata schema record.

schema-v2.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",
        "date"
    ],
    "properties": {
        "title": {
            "$id": "#/properties/string",
            "type": "string",
            "title": "Title",
            "description": "Title of object."
        },                                                                                                                                                                      
        "date": {
            "$id": "#/properties/string",
            "type": "string",
            "format": "date",
            "title": "Date",
            "description": "Date of object"
        }
    },
    "additionalProperties": false
} 
$ curl 'http://localhost:8040/api/v1/schemas/my_first_json' -i -X PUT \
    -H 'Content-Type: multipart/form-data' \
    -H 'If-Match: "1855465506"' \
    -F 'schema=@schema-v2.json;type=application/json'

HTTP-wise the call looks as follows:

PUT /api/v1/schemas/my_first_json HTTP/1.1
Content-Type: multipart/form-data; boundary=6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
If-Match: "1855465506"
Host: localhost:8040

--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm
Content-Disposition: form-data; name=schema; filename=schema-v2.json
Content-Type: application/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",
        "date"
    ],
    "properties": {
        "title": {
            "$id": "#/properties/string",
            "type": "string",
            "title": "Title",
            "description": "Title of object."
        },
        "date": {
            "$id": "#/properties/string",
            "type": "string",
            "format": "date",
            "title": "Date",
            "description": "Date of object"
        }
    },
    "additionalProperties": false
}
--6o2knFse3p53ty9dmcQvWAIx1zInP11uCfbm--

As a result, you receive the updated schema record and in the HTTP response header the new location URL and the ETag.

HTTP/1.1 200 OK
Location: http://localhost:8040/api/v1/schemas/my_first_json?version=2
ETag: "-688555972"
Content-Type: application/json
Content-Length: 461

{
  "schemaId" : "my_first_json",
  "schemaVersion" : 2,
  "mimeType" : "application/json",
  "type" : "JSON",
  "createdAt" : "2022-05-20T09:54:01Z",
  "lastUpdate" : "2022-05-20T09:54:02.753Z",
  "acl" : [ {
    "id" : 1,
    "sid" : "SELF",
    "permission" : "ADMINISTRATE"
  } ],
  "schemaDocumentUri" : "http://localhost:8040/api/v1/schemas/my_first_json?version=2",
  "schemaHash" : "sha1:68c72ab169770015f9b68645d0a50ac33a98f46c",
  "doNotSync" : true
}
« PREVIOUS NEXT »