Skip to content

Commit 6323931

Browse files
committed
Add new HTTP REST API service
Update readme bump version Signed-off-by: Ashley Sommer <ashleysommer@gmail.com>
1 parent e799188 commit 6323931

File tree

10 files changed

+1155
-155
lines changed

10 files changed

+1155
-155
lines changed

CHANGELOG.md

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Python PEP 440 Versioning](https://www.python.org/dev/peps/pep-0440/).
66

77
## [Unreleased]
8-
### Nothing yet
98

10-
## [0.20.0] - 2022-09-08
9+
## [0.21.0] - 2023-03-31
10+
### In this release:
11+
12+
### Added
13+
- New HTTP Server functionality
14+
- run PySHACL as a persistent service, exposing an OpenAPI3.0-compatible REST interface
15+
- Detection of filename when downloading web attachments is added
16+
- Better detection of invalid integer values for sh:minLength and sh:maxLength string constraints.
1117

12-
### Note, while this is a normal 0.x release, it also acts as the v1.0 release candidate.
13-
That means, if no glaring bugs or issues are found in this release after two weeks, this version will be re-released as
14-
PySHACL v1.0.
18+
### Fixed
19+
- Opening a http link that has chunked encoding, or content-disposition attachment will now work correctly.
20+
21+
22+
## [0.20.0] - 2022-09-08
1523

1624
### In this release:
1725

@@ -980,7 +988,8 @@ just leaves the files open. Now it is up to the command-line client to close the
980988

981989
- Initial version, limited functionality
982990

983-
[Unreleased]: https://github.com/RDFLib/pySHACL/compare/v0.20.0...HEAD
991+
[Unreleased]: https://github.com/RDFLib/pySHACL/compare/v0.21.0...HEAD
992+
[0.21.0]: https://github.com/RDFLib/pySHACL/compare/v0.20.0...v0.21.0
984993
[0.20.0]: https://github.com/RDFLib/pySHACL/compare/v0.19.1...v0.20.0
985994
[0.19.1]: https://github.com/RDFLib/pySHACL/compare/v0.19.0...v0.19.1
986995
[0.19.0]: https://github.com/RDFLib/pySHACL/compare/v0.18.1...v0.19.0

CITATION.cff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ authors:
88
given-names: "Nicholas"
99
orcid: "http://orcid.org/0000-0002-8742-7730"
1010
title: "pySHACL"
11-
version: 0.20.0
11+
version: 0.21.0
1212
doi: 10.5281/zenodo.4750840
1313
license: Apache-2.0
1414
date-released: 2022-01-13

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ WORKDIR /home/pyshacl
99
RUN addgroup -g 1000 -S pyshacl &&\
1010
adduser --disabled-password --gecos "" --home "$(pwd)" --ingroup "pyshacl" --no-create-home --uid 1000 pyshacl
1111
WORKDIR /app
12-
LABEL org.opencontainers.image.version="0.19.1"
12+
LABEL org.opencontainers.image.version="0.21.0"
1313
COPY . .
1414
RUN chown -R pyshacl:pyshacl /home/pyshacl /app && chmod -R 775 /home/pyshacl /app
1515
USER pyshacl
1616
ENV PATH="/home/pyshacl/.local/bin:$PATH"
17-
RUN pip3 install poetry
18-
RUN poetry install --no-dev --extras "js"
17+
RUN pip3 install "poetry>=1.2.0,<2.0"
18+
RUN poetry install --no-dev --extras "js http"
1919
USER root
2020
RUN apk del build-dependencies
2121
USER pyshacl

README.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ The SHACL community has a discord server for discussion of topics around SHACL a
1717

1818
[Use this invitation link: https://discord.gg/RTbGfJqdKB to join the server](https://discord.gg/RTbGfJqdKB)
1919

20-
There is a \#pyshacl channel in which discussion around this python library can held, and you can ask for general pyshacl help too.
20+
There is a \#pyshacl channel for discussion of this python library, and you can ask for general SHACL help too.
2121

2222
## Installation
2323
Install with PIP (Using the Python3 pip installer `pip3`)
@@ -70,12 +70,13 @@ usage: pyshacl [-h] [-s [SHACL]] [-e [ONT]] [-i {none,rdfs,owlrl,both}] [-m]
7070
[-ef {auto,turtle,xml,json-ld,nt,n3}] [-V] [-o [OUTPUT]]
7171
DataGraph
7272

73-
PySHACL 0.20.0 command line tool.
73+
PySHACL 0.21.0 command line tool.
7474

7575
positional arguments:
7676
DataGraph The file containing the Target Data Graph.
7777

7878
optional arguments:
79+
--server Ignore all the rest of the options, start the HTTP Server.
7980
-h, --help show this help message and exit
8081
-s [SHACL], --shacl [SHACL]
8182
A file containing the SHACL Shapes Graph.
@@ -155,7 +156,7 @@ Some other optional keyword variables available on the `validate` function:
155156
* `data_graph_format`: Override the format detection for the given data graph source file.
156157
* `shacl_graph_format`: Override the format detection for the given shacl graph source file.
157158
* `ont_graph_format`: Override the format detection for the given extra ontology graph source file.
158-
* `iterate_rules`: Interate SHACL Rules until steady state is found (only works with advanced mode).
159+
* `iterate_rules`: Iterate SHACL Rules until steady state is found (only works with advanced mode).
159160
* `do_owl_imports`: Enable the feature to allow the import of subgraphs using `owl:imports` for the shapes graph and the ontology graph. Note, you explicitly cannot use this on the target data graph.
160161
* `serialize_report_graph`: Convert the report results_graph into a serialised representation (for example, 'turtle')
161162
* `check_dash_result`: Check the validation result against the given expected DASH test suite result.
@@ -176,6 +177,42 @@ You can get an equivalent of the Command Line Tool using the Python3 executable
176177
$ python3 -m pyshacl
177178
```
178179

180+
## Integrated OpenAPI3.0-compatible HTTP REST Service
181+
182+
PySHACL now has a built-in validation service, exposed via an OpenAPI3.0-compatible REST API.
183+
184+
Due to the additional dependencies required to run, this feature is an optional extra.
185+
186+
You must first install PySHACL with the `http` extra option enabled:
187+
188+
```bash
189+
$ pip3 install -U pyshacl[http]
190+
```
191+
192+
When that is installed, you can start the service using the by executing the CLI entrypoint:
193+
194+
```bash
195+
$ pyshacl --server
196+
# or
197+
$ pyshacl_server
198+
# or
199+
$ python3 -m pyshacl server
200+
```
201+
202+
By default, this will run the service on localhost address `127.0.0.1` on port `8099`.
203+
204+
To view the SwaggerUI documentation for the service, navigate to `http://127.0.0.1:8099/docs/swagger` and for the ReDoc version, go to `http://127.0.0.1:8099/docs/redoc`.
205+
206+
To view the OpenAPI3 schema see `http://127.0.0.1:8099/docs/openapi.json`
207+
208+
### Configuring the HTTP REST Service
209+
210+
- You can force PySHACL CLI to start up in HTTP Server mode by passing environment variable `PYSHACL_SERVER=TRUE`. This is useful in a containerised service, where you will _only_ be running PySHACL in this mode.
211+
- `PYSHACL_SERVER_LISTEN=1.2.3.4` listen on a different IP Address or hostname
212+
- `PYSHACL_SERVER_PORT=8080` listen on given different TCP PORT
213+
- `PYSHACL_SERVER_HOSTNAME=example.org` when you are hosting the server behind a reverse-proxy or in a containerised environment, use this so PySHACL server knows what your externally facing hostname is
214+
215+
179216

180217
## Errors
181218
Under certain circumstances pySHACL can produce a `Validation Failure`. This is a formal error defined by the SHACL specification and is required to be produced as a result of specific conditions within the SHACL graph.

0 commit comments

Comments
 (0)