Skip to main content

A library for to transform an openAPI file to a dcat:DataService

Project description

Tests codecov PyPI Read the Docs

oastodcat

A small Python library to transform an openAPI file to a dcat:DataService

At this moment we support all 3.0.x versions of (The OpenAPI specification)[https://github.com/OAI/OpenAPI-Specification]

Usage

Install

% pip install oastodcat

Getting started

import yaml
import requests
from datacatalogtordf import Catalog
from oastodcat import OASDataService

# Create catalog object
catalog = Catalog()
catalog.identifier = "http://example.com/catalogs/1"
catalog.title = {"en": "A dataset catalog"}
catalog.publisher = "https://example.com/publishers/1"

# Create a dataservice based on an openAPI-specification:
url = ("https://raw.githubusercontent.com/"
      "OAI/OpenAPI-Specification/master/examples/v3.0/petstore.yaml"
      )
oas = yaml.safe_load(requests.get(url).text)
dataservice = OASDataService(oas)
dataservice.identifier = "http://example.com/dataservices/1"
dataservice.endpointDescription = url
#
# Add dataservice to catalog:
catalog.services.append(dataservice)

# Get dcat representation in turtle (default)
dcat = catalog.to_rdf()
print(dcat.decode())

Mapping

The following table shows how an openAPI specification is mapped to a dcat:DataService:
(Only dcat:DataService properties are shown.)

dcat:DataService RDF property openAPI v 3.0.x
endpoint description dcat:endpointDescription
endpoint URL dcat:endpointURL servers.url
serves dataset n/a
access rights
conforms to
contact point dcat:contactPoint info.contact
creator
description dct:description info.description
has policy
identifier n/a
is referenced by
keyword/tag
landing page dcat:landingPage externalDocs
license dct:license info.license.url
resource language
relation
rights
qualified relation
publisher
release date
theme/category
title dct:title info.title
type/genre
update/modification date
qualified attribution
media type dcat:mediaType <it's complicated>

Development

Requirements

Install

% git clone https://github.com/Informasjonsforvaltning/oastodcat.git
% cd oastodcat
% pyenv install 3.8.3
% pyenv install 3.7.7
% pyenv local 3.8.3 3.7.7
% poetry install

Run all sessions

% nox

Run all tests with coverage reporting

% nox -rs tests

Debugging

You can enter into Pdb by passing --pdb to pytest:

nox -rs tests -- --pdb

You can set breakpoints directly in code by using the function breakpoint().

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

oastodcat-2.0.0a2.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

oastodcat-2.0.0a2-py3-none-any.whl (9.7 kB view details)

Uploaded Python 3

File details

Details for the file oastodcat-2.0.0a2.tar.gz.

File metadata

  • Download URL: oastodcat-2.0.0a2.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.6 Linux/5.4.0-1026-azure

File hashes

Hashes for oastodcat-2.0.0a2.tar.gz
Algorithm Hash digest
SHA256 3205e1436d8c4bc296c00aad0ea860cdb4f5cc55573029e7be8a523ab17bb676
MD5 a72c5c3017e651c4d827563d766db9c8
BLAKE2b-256 c32b5075630e62f75e93decb1094465932aae24e1d1e02a72d258e563a0297db

See more details on using hashes here.

File details

Details for the file oastodcat-2.0.0a2-py3-none-any.whl.

File metadata

  • Download URL: oastodcat-2.0.0a2-py3-none-any.whl
  • Upload date:
  • Size: 9.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.6 Linux/5.4.0-1026-azure

File hashes

Hashes for oastodcat-2.0.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 78f99f8e7052481548e18ce8571475ee6891b7add026dd831a31b3d18c82e7e1
MD5 6253281d25494d0ce53d23dddc09c2c4
BLAKE2b-256 a169d622428fed33fcebcd283f6baa5596a1a7353d525e23d39bc6adbbcfe028

See more details on using hashes here.

Supported by

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