Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SHACL #8

Merged
merged 8 commits into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
on:
push:
branches:
- "*"

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker-practice/[email protected]
- run: make build
- uses: actions/upload-artifact@v2
with:
name: specs
path: "**/index.html"
- name: GitHub Pages
if: ${{ github.ref == 'refs/heads/master' }}
uses: crazy-max/[email protected]
with:
build_dir: .
jekyll: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
index.html
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
watch:
docker-compose run --rm bikeshed watch /extensions/$(spec)/index.bs

define build-target
docker-compose run --rm bikeshed spec /extensions/$1
endef

build:
@for f in $(shell find . -name "*.bs"); do \
echo "Building $${f}"; \
$(call build-target,$${f}); \
done

new:
mkdir -p $(spec)
docker-compose run --rm bikeshed template > $(spec)/index.bs
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Hydra extensions

This repository gathers vocabularies which extend [Hydra Core](http://www.hydra-cg.com/spec/latest/core/) to allow implementors to create richer hypermedia in their Hydra APIs.

## Adding extensions

Simply run `make new spec=my-extension` and commit the created `index.bs` file.
alien-mcl marked this conversation as resolved.
Show resolved Hide resolved

## Run locally

Run `make watch spec=my-extension` to start bikeshed in observing mode. It will generate an adjacent `index.html` when the source changes.

Run `make build` to generate all specification files.
alien-mcl marked this conversation as resolved.
Show resolved Hide resolved
7 changes: 7 additions & 0 deletions bs.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM python:buster

RUN pip install bikeshed
RUN bikeshed update

ENTRYPOINT ["bikeshed"]
CMD ["--help"]
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3"
services:
bikeshed:
build:
context: .
dockerfile: bs.Dockerfile
volumes:
- .:/extensions
83 changes: 83 additions & 0 deletions shacl/index.bs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<pre class='metadata'>
Title: Hydra-SHACL Interoperability
Shortname: hashi
Level: 1
Status: LD
Group: HydraCG
URL: https://hydracg.github.io/extensions/shacl
Editor: Tomasz Pluskiewicz, Zazuko GmbH https://zazuko.com/, https://t-code.pl
Abstract: This document provides additional terms and examples of using SHACL together with Hydra to describe API's hyperemedia
Markup Shorthands: markdown yes
</pre>

<pre class=biblio>
{
"hydra": {
"authors": [
"Markus Lanthaler"
],
"href": "http://www.hydra-cg.com/spec/latest/core/",
"title": "Hydra Core Vocabulary",
"status": "UD",
"publisher": "W3C"
}
}
</pre>

# Introduction # {#intro}

[[!Hydra|Hydra Core]] vocabulary does define a handful of data modeling terms such as `hydra:Class` and `hydra:supportedProperty` which can be used to build basic APIs. However, it was never a goal of Hydra Core to become a full-blown modeling language, given available alternatives.

One such alternative is [[!SHACL]], which is defined by its authors as "a language for validating RDF graphs against a set of conditions", yet its usefulness goes way beyond just data validation. See the [[shacl-ucr|SHACL Use Cases and Requirements]] note for various ideas for employing [[SHACL]].

In this document we propose various ways in which [[SHACL]] can be used by both Hydra API publishers and consumers to facilitate client-server interaction.

# Conventions # {#conventions}

The base namespace of this extension and its unique identifier is `http://www.w3.org/ns/hydra/shacl#`.

The preferred prefix is `hashi:`.

# Announcing the extension # {#announcing}

Conforming with the [[Hydra#extensions|Extensions]] section of [[Hydra]], an API MUST announce the use of an extension by adding it to its `hydra:ApiDocumentation`:

<div class='example'>
alien-mcl marked this conversation as resolved.
Show resolved Hide resolved
<p>
Adding SHACL extension to an API
</p>

<pre highlight="json" line-highlight="4">
{
"@context": "http://www.w3.org/ns/hydra/context.jsonld",
"@id": "http://api.example.com/doc/",
"extension": "http://www.w3.org/ns/shacl#"
}
</pre>
</div
tpluscode marked this conversation as resolved.
Show resolved Hide resolved

# Extending a Hydra API # {#usage}

## Using Node Shapes to describe request payloads ## {#expects}

Issue(9): Node Shapes used as objects of `hydra:expects`

## Discovering shapes ## {#discovery}

Issue(10): Add a specialized property to link to a collection of shapes

## Providing choices to properties ## {#linking}

Provide choices for properties rendered in a form as `dash:EnumSelectEditor` and `dash:InstancesSelectEditor`.

### Using `hydra:collection` ### {#property-collection}

Issue(11): Static choices

### Using `hydra:search` ### {#property-search}

Issue(11): Filtered choices

# SHACL Shapes for Hydra Core terms # {#shapes}

Issue(12): Model the Hydra Core vocabulary as node shapes