Skip to content

Commit e54a9c0

Browse files
authored
Introduce versioning: All models moved from maloident ➡️ maloident.v1 (#25)
1 parent 1ff4037 commit e54a9c0

File tree

9 files changed

+16
-10
lines changed

9 files changed

+16
-10
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ pip install maloident
2525
Then use it:
2626

2727
```python
28-
from maloident.models import ResultNegative
28+
from maloident.v1.models import ResultNegative
29+
2930
my_json = {
3031
"decisionTree": "E_0594",
3132
"responseCode": "A10",
@@ -42,10 +43,10 @@ See the [tests](unittests/test_models.py) for more examples.
4243
## Project Structure
4344

4445
This project is based on [`datamodel-code-generator`](https://github.com/koxudaxi/datamodel-code-generator/).
45-
Most of the classes are autogenerated from the [`openapi.yml`](openapi/openapi.yml) which can be found on [SwaggerHub](https://app.swaggerhub.com/apis/edi-energy/MaLoIdent_2024-07-03/v1.0.0).
46+
Most of the classes are autogenerated from the [`openapi.yml`](openapi/v1/openapi.yml) which can be found on [SwaggerHub](https://app.swaggerhub.com/apis/edi-energy/MaLoIdent_2024-07-03/v1.0.0).
4647

4748
Note that we fixed some errors in the official OpenAPI spec.
48-
Our changes are mentioned at the beginning of the [`openapi.yml`](openapi/openapi.yml) file.
49+
Our changes are mentioned at the beginning of the [`openapi.yml`](openapi/v1/openapi.yml) file.
4950

5051
https://github.com/Hochfrequenz/malo-ident-python-models/blob/3cfe0aea3cff051303ef5e513d06ab6c5741f21a/openapi/openapi.yml#L4-L10
5152

File renamed without changes.

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ truethy-bool = true
7575
disable_error_code = []
7676

7777
[[tool.mypy.overrides]]
78-
module = "maloident._autogenerated"
78+
module = "maloident.v1._autogenerated"
7979
ignore_errors = true
8080

8181

src/maloident/v1/__init__.py

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""
2+
v1 contains the models of the v1 API.
3+
This allows us to maintain different versions of the models (for different API versions)
4+
in the same python/pip package/repository.
5+
"""

src/maloident/_autogenerated.py src/maloident/v1/_autogenerated.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# generated by datamodel-codegen:
22
# filename: openapi.yml
3-
# timestamp: 2024-10-02T11:57:20+00:00
3+
# timestamp: 2024-10-02T12:07:18+00:00
44

55
from __future__ import annotations
66

File renamed without changes.

tox.ini

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ deps =
7575
.[formatting]
7676
.[codegen]
7777
commands =
78-
datamodel-codegen --encoding utf-8 --input openapi/openapi.yml --output src/maloident/_autogenerated.py --input-file-type openapi --output-model-type pydantic_v2.BaseModel
79-
black src/maloident/_autogenerated.py
80-
isort src/maloident/_autogenerated.py
78+
datamodel-codegen --encoding utf-8 --input openapi/v1/openapi.yml --output src/maloident/v1/_autogenerated.py --input-file-type openapi --output-model-type pydantic_v2.BaseModel
79+
black src/maloident/v1/_autogenerated.py
80+
isort src/maloident/v1/_autogenerated.py
8181

8282
[testenv:dev]
8383
# the dev environment contains everything you need to start developing on your local machine.
File renamed without changes.

unittests/test_models.py unittests/test_models_v1.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import pytest
44

5-
from maloident.models import IdentificationParameter, ResultNegative, ResultPositive
5+
from maloident.v1.models import IdentificationParameter, ResultNegative, ResultPositive
66

7-
from .example_jsons import negative_response_body, positive_response_body, request_body
7+
from .example_jsons_v1 import negative_response_body, positive_response_body, request_body
88

99

1010
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)