Snapshot version

You are browsing the docs for the snapshot version of Nexus, the latest release is available here

Trial

Trial operations contain read-only operations designed to help users compose and validate their resources before effectively saving them in Nexus.

Authorization notes

When performing a request, the caller must have resources/read permission on the project each resource belongs to.

Please visit Authentication & authorization section to learn more about it.

Resource generation

This endpoint allows to create and get the output of a resource, optionally validating with an existing schema or a new one.

It applies the same validation steps than the creation/update of resources, the main difference being that nothing is persisted.

POST /v1/trial/resources/{org_label}/{project_label}

{
  "schema": {schema},
  "resource": {resource}
}

Where:

  • {schema}: String/Json: The schema to validate the provided resource. If a string is provided, it will attempt to resolve it as an existing schema. If a json payload is provided, it will attempt to generate the schema and then use the result to validate the resource. This field is optional and defaults to no SHACL validation.
  • {resource}: Json: The resource payload to test and validate

The Json response will contain:

  • The generated resource in the compacted JSON-LD format if the generation and the validation was successful
  • The generated schema if a new schema payload was provided
  • The error if the one of the steps fails (invalid resource/invalid new schema/existing schema not found/…)

Example

Request
sourcecurl -X POST \
     -H "Content-Type: application/json" \
     "http://localhost:8080/trial/resources/myorg/myproj/" \
     -d \
'{
   "schema": "https://bbp.epfl.ch/nexus/schema/morphology"
   "resource": {
     "@context": [
       "https://neuroshapes.org",
       "https://bluebrain.github.io/nexus/contexts/metadata.json",
       {
         "@vocab": "https://bluebrain.github.io/nexus/vocabulary/"
       }
     ],
     "@id": "https://bbp.epfl.ch/nexus/data/morphology-001",
     "@type": "Morphology",
     "name": "Morphology 001"
   }
 }'
Payload
source{
  "schema": "https://bbp.epfl.ch/nexus/schema/morphology"
  "resource": {
    "@context": [
      "https://neuroshapes.org",
      "https://bluebrain.github.io/nexus/contexts/metadata.json",
      {
        "@vocab": "https://bluebrain.github.io/nexus/vocabulary/"
      }
    ],
    "@id": "https://bbp.epfl.ch/nexus/data/morphology-001",
    "@type": "Morphology",
    "name": "Morphology 001"
  }
}
Response
source{
  "result": {
    "@context": [
      "https://bluebrain.github.io/nexus/contexts/metadata.json",
      {
        "@vocab": "https://bluebrain.github.io/nexus/vocabulary/"
      },
      "https://neuroshapes.org"
    ],
    "@id": "https://bbp.epfl.ch/nexus/data/morphology-001",
    "@type": "Morphology",
    "name": "Morphology 001",
    "_constrainedBy": "https://bbp.epfl.ch/nexus/schema/morphology",
    "_createdAt": "2023-09-18T12:00:00Z",
    "_createdBy": "http://localhost/v1/realms/wonderland/users/alice",
    "_deprecated": false,
    "_incoming": "http://localhost/v1/resources/myorg/myproj/_/https:%2F%2Fbluebrain.github.io%2Fnexus%2Fvocabulary%2FmyId/incoming",
    "_outgoing": "http://localhost/v1/resources/myorg/myproj/_/https:%2F%2Fbluebrain.github.io%2Fnexus%2Fvocabulary%2FmyId/outgoing",
    "_project": "http://localhost/v1/projects/myorg/myproj",
    "_rev": 1,
    "_schemaProject": "http://localhost/v1/projects/myorg/myproj",
    "_self": "http://localhost/v1/resources/myorg/myproj/_/https:%2F%2Fbluebrain.github.io%2Fnexus%2Fvocabulary%2FmyId",
    "_updatedAt": "2023-09-18T12:00:00Z",
    "_updatedBy": "http://localhost/v1/realms/wonderland/users/alice"
  }
}

Validate

This operation runs validation of a resource against a schema. This would be useful to test whether resources would match the shape of a new schema.

GET /v1/resources/{org_label}/{project_label}/{schema_id}/{resource_id}/validate

Example

Request
sourcecurl "http://localhost:8080/v1/resources/myorg/myproj/myschema/base:fd8a2b32-170e-44e8-808f-44a8cbbc49b0/validate"
Response
source{
  "@context" : "https://bluebrain.github.io/nexus/contexts/shacl-20170720.json",
  "@type" : "sh:ValidationReport",
  "conforms" : true,
  "targetedNodes" : 2
}