Skip to content

Align JSON-LD output with DCAT#221

Open
LariDG wants to merge 9 commits into
developfrom
revising-dcat
Open

Align JSON-LD output with DCAT#221
LariDG wants to merge 9 commits into
developfrom
revising-dcat

Conversation

@LariDG

@LariDG LariDG commented May 13, 2026

Copy link
Copy Markdown
Collaborator

In response to issue: #172 and discussions with Alejandra.

The JSON endpoints previously declared DCAT terms in the @context inconsistently, every response was a flat dcat:Dataset regardless of whether it was a catalogue listing, a dataset, or a glossary entry. This PR reshapes the responses to be more inline with DCAT usage.

Example of new structure after snippet put into json-ld playground:

http://localhost:8081/json/shots :

{
  "@type": "http://www.w3.org/ns/dcat#Catalog",
  "http://www.w3.org/ns/dcat#dataset": [
    {
      "@type": "http://www.w3.org/ns/dcat#Dataset",
      "http://purl.org/dc/terms/date": "2004-12-13T11:54:00",
      "http://purl.org/dc/terms/identifier": "219e5d59-b9dc-584f-b83b-018c47e8739d",
      "http://www.w3.org/ns/dcat#distribution": {
        "@type": "http://www.w3.org/ns/dcat#Distribution",
        "http://www.w3.org/ns/dcat#accessURL": "https://s3.echo.stfc.ac.uk/mast/level1/shots/11695.zarr",
        "http://www.w3.org/ns/dcat#downloadURL": "s3://mast/level1/shots/11695.zarr",
        "http://www.w3.org/ns/dcat#mediaType": "application/zarr"
      }
    },
    {
      "@type": "http://www.w3.org/ns/dcat#Dataset",
      "http://purl.org/dc/terms/date": "2004-12-13T12:07:00",
      "http://purl.org/dc/terms/identifier": "9ba69c96-34ac-5cd4-a1b8-8e9d7a44f871",
      "http://www.w3.org/ns/dcat#distribution": {
        "@type": "http://www.w3.org/ns/dcat#Distribution",
        "http://www.w3.org/ns/dcat#accessURL": "https://s3.echo.stfc.ac.uk/mast/level1/shots/11696.zarr",
        "http://www.w3.org/ns/dcat#downloadURL": "s3://mast/level1/shots/11696.zarr",
        "http://www.w3.org/ns/dcat#mediaType": "application/zarr"
      }

Single shot endpoint (http://localhost:8081/json/shots/11695):

{
  "@type": "http://www.w3.org/ns/dcat#Dataset",
  "http://purl.org/dc/terms/date": "2004-12-13T11:54:00",
  "http://purl.org/dc/terms/identifier": "219e5d59-b9dc-584f-b83b-018c47e8739d",
  "http://www.w3.org/ns/dcat#distribution": {
    "@type": "http://www.w3.org/ns/dcat#Distribution",
    "http://www.w3.org/ns/dcat#accessURL": "https://s3.echo.stfc.ac.uk/mast/level1/shots/11695.zarr",
    "http://www.w3.org/ns/dcat#downloadURL": "s3://mast/level1/shots/11695.zarr",
    "http://www.w3.org/ns/dcat#mediaType": "application/zarr"
  }
}

Due to cpf summary not being a dataset, changed the context to more appropriate definition:

{
  "@context": {
    "dct": "http://purl.org/dc/terms/",
    "schema": "https://schema.org/",
    "type": "@type",
    "name": "schema:name",
    "description": "dct:description"
  },
  "type": "schema:DefinedTermSet",
  "schema:hasDefinedTerm": [
    {
      "type": "schema:DefinedTerm",
      "description": "CP3c Set Volts",
      "name": "mcs_cp3c_volt"
    },
    {
      "type": "schema:DefinedTerm",
      "description": "Additive Gas Plenum",
      "name": "mcs_additive_gas_pressure"
    },

@LariDG LariDG changed the base branch from main to develop May 13, 2026 09:22
@LariDG LariDG requested a review from agbeltran May 13, 2026 09:23
@LariDG

LariDG commented May 13, 2026

Copy link
Copy Markdown
Collaborator Author

@agbeltran I have made a start here on what we discussed. Please let me know if this is what you had in mind and if there are any changes you would like.

@agbeltran

Copy link
Copy Markdown
Contributor

@LariDG this is looking really good, thank you! I'm pushing a few changes for create.py using rdflib so that the JSON-LD generated follows the namespaces and can be validated easily

Similar changes can be implemented to main.py

@agbeltran

Copy link
Copy Markdown
Contributor

A few comments on remaining points: i) dcat:servesDataset should point to a dataset, so adding the service endpoints might be ok if they return datasets, ii) for the service URI, we should consider where the service is deployed (I only left localhost), iii) I tested the output in the json-ld playground, but we should test further and make sure everything is correct. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants