Convert OpenAPI YAML specifications to RDF vocabularies and SHACL validation shapes for telecom intent-based automation and TMForum standards
Project description
OpenAPI to RDF Converter
Convert OpenAPI YAML schema definitions to RDF vocabularies and SHACL validation shapes for telecom intent-based automation and 3GPP standards. Adheres to W3C standards and best practices.
Note: This tool converts only the components/schemas section of OpenAPI specifications, not endpoints, paths, or operations.
Features
- Dual Output Formats: Generate separate RDF vocabulary + SHACL shapes (default) or traditional RDF/OWL
- Schema Coverage: Converts OpenAPI schemas including objects, arrays, enums, and logical operators
- W3C Standards Compliant: Assigns proper
rdfs:domain,rdfs:rangeto properties, and constraints via SHACL vocabulary - Universality: Should works with any OpenAPI schema specification, althoug only tested with 3GPP input.
Installation
pip install openapi-to-rdf
Quick Start
Get OpenAPI Specifications
First, obtain OpenAPI YAML files from your preferred source:
3GPP Specifications:
# Download from 3GPP Forge
curl -O https://forge.3gpp.org/rep/sa5/MnS/-/raw/Rel-18/OpenAPI/TS28623_ComDefs.yaml
Convert to RDF/SHACL
# Convert single file
openapi-to-rdf openapi-spec.yaml
# Convert multiple files
openapi-to-rdf file1.yaml file2.yaml file3.yaml
# Convert all YAML files in a directory
openapi-to-rdf /path/to/openapi/specs/
# Use custom namespace prefix
openapi-to-rdf openapi-spec.yaml --namespace-prefix "https://myorg.com/models/"
# Convert to OWL format instead of SHACL
openapi-to-rdf openapi-spec.yaml --format owl
Complete Example
# 1. Download 3GPP specifications
mkdir specs && cd specs
curl -O https://forge.3gpp.org/rep/sa5/MnS/-/raw/Rel-18/OpenAPI/TS28623_ComDefs.yaml
curl -O https://forge.3gpp.org/rep/sa5/MnS/-/raw/Rel-18/OpenAPI/TS28623_GenericNrm.yaml
# 2. Convert to RDF/SHACL
openapi-to-rdf *.yaml --namespace-prefix "https://myorg.com/models/3gpp/"
Tested Sources
This tool has been tested and validated with:
- 3GPP SA5 MnS specifications from https://forge.3gpp.org/rep/sa5/MnS/
- Releases: Rel-18, Rel-19
- 38+ different schema files covering various network management domains
Output Formats
SHACL Format (Default)
Generates two separate files:
- RDF Vocabulary (
*_rdf.ttl): Classes and properties with proper domain/range - SHACL Shapes (
*_shacl.ttl): Validation constraints and cardinality rules
Example Output
RDF Vocabulary (*_rdf.ttl)
@prefix TS28623_ComDefs: <http://ericsson.com/models/3gpp/TS28623/ComDefs#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
TS28623_ComDefs:TimeWindow a rdfs:Class ;
rdfs:comment "Note: Uses OpenAPI xone - complex logical constraints partially supported in SHACL" .
TS28623_ComDefs:startTime a rdf:Property ;
rdfs:domain TS28623_ComDefs:TimeWindow ;
rdfs:range TS28623_ComDefs:DateTime .
SHACL Shapes (*_shacl.ttl)
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix TS28623_ComDefs: <http://ericsson.com/models/3gpp/TS28623/ComDefs#> .
[] a sh:NodeShape ;
sh:targetClass TS28623_ComDefs:TimeWindow ;
sh:property [ a sh:PropertyShape ;
sh:path TS28623_ComDefs:startTime ;
sh:class TS28623_ComDefs:DateTime ;
sh:maxCount 1 ] .
📖 For comprehensive conversion examples and detailed explanations of all OpenAPI patterns, see CONVERSION_DOC.md
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file openapi_to_rdf-0.1.0.tar.gz.
File metadata
- Download URL: openapi_to_rdf-0.1.0.tar.gz
- Upload date:
- Size: 16.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.10.12 Linux/6.6.87.2-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
998fdbfb1b44bd7467394bae2165f7f48ece1ddf827ee684f59e14f9517dcaf6
|
|
| MD5 |
cada7c660d1770388e812e1c9ed47630
|
|
| BLAKE2b-256 |
434163cf0cc3a11f1afb77ae45ae03bbbefe93470e8eca927cf3f37065d56045
|
File details
Details for the file openapi_to_rdf-0.1.0-py3-none-any.whl.
File metadata
- Download URL: openapi_to_rdf-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.10.12 Linux/6.6.87.2-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31ff0dc1ddf457805c9d63b5d1ddd4b72a9d025ded7eda2019b3f2a59b67926a
|
|
| MD5 |
44c9612b71b05f65efc703ce6e536f1a
|
|
| BLAKE2b-256 |
e2db5007f6b1713788b061e7f58c29e20f287aac7b95e128306e5fa2b0cc8520
|