Skip to content

Commit 116b8f1

Browse files
committed
first commit
0 parents  commit 116b8f1

15 files changed

Lines changed: 2823 additions & 0 deletions

File tree

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
indent_size = 2
7+
indent_style = space
8+
insert_final_newline = false
9+
max_line_length = 100
10+
tab_width = 2
11+
12+
[{*.py,*.pyw}]
13+
indent_size = 4
14+
max_line_length = 120
15+
tab_width = 4

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "pip" # See documentation for possible values
9+
directory: "/" # Location of package manifests
10+
schedule:
11+
interval: "weekly"

.github/workflows/ci.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
on:
2+
push:
3+
branches: [ "main" ]
4+
pull_request:
5+
branches: [ "main" ]
6+
workflow_call:
7+
8+
permissions:
9+
contents: read
10+
11+
name: CI
12+
jobs:
13+
test:
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
matrix:
17+
os:
18+
- 'ubuntu-latest'
19+
python-version:
20+
- '3.10'
21+
- '3.11'
22+
- '3.12'
23+
fail-fast: false
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Install uv
27+
uses: astral-sh/setup-uv@v5
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
- name: Install the project
31+
run: uv sync --all-extras --dev
32+
- name: Check formatting
33+
run: uv run ruff check
34+
- name: Run tests
35+
run: uv run pytest

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.idea/
2+
.venv/
3+
__pycache__/
4+
uv.lock

LICENSE

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
MIT License
2+
3+
Copyright (c) 2023 innoQ Deutschland GmbH
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
22+
23+
24+
Open Source Licenses for Dependencies
25+
26+
This project utilizes the following open-source libraries, each of which has its own respective license:
27+
28+
1. github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
29+
License: MIT License
30+
License URL: https://github.com/pkg/browser/blob/main/LICENSE
31+
32+
2. github.com/qri-io/jsonschema v0.2.1
33+
License: MIT License
34+
License URL: https://github.com/qri-io/jsonschema/blob/main/LICENSE
35+
36+
3. github.com/urfave/cli/v2 v2.25.7
37+
License: MIT License
38+
License URL: https://github.com/urfave/cli/blob/v2.25.7/LICENSE
39+
40+
4. gopkg.in/yaml.v3 v3.0.1
41+
License: Apache License 2.0
42+
License URL: https://gopkg.in/yaml.v3/blob/v3.0.1/LICENSE
43+
44+
Please review and comply with the terms and conditions of each respective license when using this software.
45+
46+
The complete text of each license can be found in the provided License URLs. Ensure that you adhere to the terms and obligations outlined in these licenses when using the dependencies in your project.
47+
48+
It is your responsibility to understand and comply with the licensing terms of these dependencies as specified by the respective licenses.

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include datacontract_specification/schema.json

README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Open Data Contract Standard (Python)
2+
3+
The pip module `open-data-contract-standard` to read and write YAML files using the [Open Data Contract Standard](https://datacontract.com). The pip module was extracted from the [Data Contract CLI](https://github.com/datacontract/datacontract-cli), which is its primary user.
4+
5+
The version number of the pip module corresponds to the version of the Open Data Contract Standard it supports.
6+
7+
## Version Mapping
8+
9+
| Open Data Contract Standard Version | Pip Module Version |
10+
|-------------------------------------|--------------------|
11+
| 3.0.1 | 3.0.1 |
12+
13+
Fixes of a specific version are shipped with post released: `3.0.1.post1`, `3.0.1.post2`, etc.
14+
15+
## Installation
16+
17+
```bash
18+
pip install open-data-contract-standard
19+
```
20+
21+
## Usage
22+
23+
```python
24+
from open_data_contract_standard.model import OpenDataContractStandard
25+
26+
# Load a data contract specification from a file
27+
data_contract = OpenDataContractStandard.from_file('path/to/your/data_contract.yaml')
28+
# Print the data contract specification as a YAML string
29+
print(data_contract.to_yaml())
30+
```
31+
32+
```python
33+
from open_data_contract_standard.model import OpenDataContractStandard
34+
35+
# Load a data contract specification from a string
36+
data_contract_str = """
37+
dataContractSpecification: 1.1.0
38+
id: urn:datacontract:checkout:orders-latest
39+
info:
40+
title: Orders Latest
41+
version: 2.0.0
42+
description: |
43+
Successful customer orders in the webshop.
44+
All orders since 2020-01-01.
45+
Orders with their line items are in their current state (no history included).
46+
owner: Checkout Team
47+
status: active
48+
contact:
49+
name: John Doe (Data Product Owner)
50+
url: https://teams.microsoft.com/l/channel/example/checkout
51+
"""
52+
data_contract = OpenDataContractStandard.from_string(data_contract_str)
53+
# Print the data contract specification as a YAML string
54+
print(data_contract.to_yaml())
55+
```

modelgen

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -ex
4+
5+
uv run datamodel-codegen --input src/open_data_contract_standard/schema.json --output src/open_data_contract_standard/model_gen.py --output-model-type pydantic_v2.BaseModel --input-file-type jsonschema --use-union-operator --use-standard-collections --collapse-root-models
6+
7+
uv run datamodel-codegen --input src/datacontract_specification/schema.json --output src/datacontract_specification/model_gen.py --output-model-type pydantic_v2.BaseModel --input-file-type jsonschema --use-union-operator --use-standard-collections --collapse-root-models

pyproject.toml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
[project]
2+
name = "open-data-contract-standard"
3+
version = "3.0.1" # in sync with spec
4+
description = "The Pydantic Model of the Open Data Contract Standard"
5+
readme = "README.md"
6+
authors = [
7+
{ name = "Jochen Christ", email = "jochen.christ@innoq.com" },
8+
{ name = "Stefan Negele", email = "stefan.negele@innoq.com" },
9+
{ name = "Simon Harrer", email = "simon.harrer@innoq.com" },
10+
]
11+
classifiers = [
12+
"Programming Language :: Python :: 3",
13+
"License :: OSI Approved :: MIT License",
14+
"Operating System :: OS Independent",
15+
]
16+
requires-python = ">=3.10"
17+
dependencies = [
18+
"pydantic>=2.8.2,<2.11.0",
19+
"pyyaml~=6.0.1",
20+
]
21+
22+
[project.optional-dependencies]
23+
dev = [
24+
"pytest",
25+
"ruff",
26+
]
27+
28+
[project.urls]
29+
Homepage = "https://github.com/datacontract/open-data-contract-standard-python"
30+
Issues = "https://github.com/datacontract/open-data-contract-standard-python/issues"
31+
32+
[tool.ruff]
33+
line-length = 120
34+
35+
[tool.ruff.lint]
36+
extend-select = [
37+
"I", # re-order imports in alphabetic order
38+
]
39+
40+
[build-system]
41+
requires = ["hatchling"]
42+
build-backend = "hatchling.build"

src/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)