Generating the server¶
OBA uses OpenAPI Generator to generate a server instance.
OpenAPI Generator¶
Given an OpenAPI Specification, the OpenAPI Generator generates automatically API client libraries (SDK generation), server stubs, documentation and configuration files. The OpenAPI Generator website maintains a list of the languages/frameworks that are supported.
RDF Integration¶
The OpenAPI Generator provides an API backend based on the OpenAPI Specification. However, it does not provide the logic of the server, like the connection to the target knowledge graph.
OBA modifies the server generated by the OpenAPI Generator using templates. As a result, the server can:
- Connect and query resources from a target SPARQL endpoint.
- Convert RDF triples under a given namespace(s) to JSON (using JSON/LD).
- Connect and insert resources into the SPARQL endpoint.
- Convert JSON into RDF triples (using JSON/LD and frames).
Generating the Server¶
Currently, OBA supports Python/Flask for the server implementation. In order to generate the server, you should follow the instructions below:
Execute Server Generation Scripts¶
Warning
You must have Docker installed.
Access to the directory with the server implementation:
$ cd python
Run the OpenAPI generator script to generate the server. If you are in Unix, you may have to change the permission of the file with chmod +x generate-server.sh
:
$ bash generate-server.sh
...
...
SUCCESS
Structure of the server¶
The generated server directory should contain the following files and directories:
$ ls server/
Dockerfile: A Dockerfile used to build the server Docker image
README.md: A README.md with the instructions to run the server
contexts: Directory with the JSON/LD contexts generated from the ontology
openapi_server: The server implemenation
queries: Directory with the SPARQL queries
requirements.txt: Python requirements of the server
test-requirements.txt: Python requirements for testing the server