Skip to content

Introduce versioning: All models moved from maloident ➡️ maloident.v1 #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ pip install maloident
Then use it:

```python
from maloident.models import ResultNegative
from maloident.v1.models import ResultNegative

my_json = {
"decisionTree": "E_0594",
"responseCode": "A10",
Expand All @@ -42,10 +43,10 @@ See the [tests](unittests/test_models.py) for more examples.
## Project Structure

This project is based on [`datamodel-code-generator`](https://github.com/koxudaxi/datamodel-code-generator/).
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).
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).

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

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

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ truethy-bool = true
disable_error_code = []

[[tool.mypy.overrides]]
module = "maloident._autogenerated"
module = "maloident.v1._autogenerated"
ignore_errors = true


Expand Down
5 changes: 5 additions & 0 deletions src/maloident/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
v1 contains the models of the v1 API.
This allows us to maintain different versions of the models (for different API versions)
in the same python/pip package/repository.
"""
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# generated by datamodel-codegen:
# filename: openapi.yml
# timestamp: 2024-10-02T11:57:20+00:00
# timestamp: 2024-10-02T12:07:18+00:00

from __future__ import annotations

Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ deps =
.[formatting]
.[codegen]
commands =
datamodel-codegen --encoding utf-8 --input openapi/openapi.yml --output src/maloident/_autogenerated.py --input-file-type openapi --output-model-type pydantic_v2.BaseModel
black src/maloident/_autogenerated.py
isort src/maloident/_autogenerated.py
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
black src/maloident/v1/_autogenerated.py
isort src/maloident/v1/_autogenerated.py

[testenv:dev]
# the dev environment contains everything you need to start developing on your local machine.
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions unittests/test_models.py → unittests/test_models_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import pytest

from maloident.models import IdentificationParameter, ResultNegative, ResultPositive
from maloident.v1.models import IdentificationParameter, ResultNegative, ResultPositive

from .example_jsons import negative_response_body, positive_response_body, request_body
from .example_jsons_v1 import negative_response_body, positive_response_body, request_body


@pytest.mark.parametrize(
Expand Down
Loading