Skip to main content

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:range to properties, and constraints via SHACL vocabulary
  • Universality: Should works with any OpenAPI schema specification, althoug only tested with 3GPP input.
  • 3GPP SA5 RDF/SHACL: We provide pre-generated RDF/SHACL output for 3GPP SA5 Release-19 OpenAPI schemas (downloaded from https://forge.3gpp.org/rep/sa5/MnS/ into assets/)

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:

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openapi_to_rdf-0.1.1.tar.gz (18.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

openapi_to_rdf-0.1.1-py3-none-any.whl (19.8 kB view details)

Uploaded Python 3

File details

Details for the file openapi_to_rdf-0.1.1.tar.gz.

File metadata

  • Download URL: openapi_to_rdf-0.1.1.tar.gz
  • Upload date:
  • Size: 18.2 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

Hashes for openapi_to_rdf-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b4e26a1fe4fa4bbd9a92a43a04d82a2db106412fda3b131cc93a18dfc798855a
MD5 8c294a9b534ef7f22616f07abe902f62
BLAKE2b-256 1eddf9dcfe955e61cf9b19bad5a0f931d1d19ad85182c6669aa9491b62551085

See more details on using hashes here.

File details

Details for the file openapi_to_rdf-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: openapi_to_rdf-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 19.8 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

Hashes for openapi_to_rdf-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d23ec055f2b5c113021fc1ae20a58af3eb27111764079304dc4fd8a14231bd05
MD5 28eb11f6e15d3c9028bc5c28ce5f9b33
BLAKE2b-256 a93696062d6b7b0b7242ef5b871d2e0e96832c115f28481b8cf8895d82ae7a3d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page