Compare commits
13 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ad2c111fa1 | ||
|
5058b58991 | ||
|
23f08ad5a5 | ||
|
77cef551a1 | ||
|
5c5a701daa | ||
|
5ead48ec92 | ||
|
1f2ac30106 | ||
|
483b457b14 | ||
|
3126c2fd2e | ||
|
a45101637c | ||
|
937c09e2b7 | ||
|
82c638c1e0 | ||
|
7ce5e5d0d4 |
24
.gitea/workflows/release.yml
Normal file
24
.gitea/workflows/release.yml
Normal file
@@ -0,0 +1,24 @@
|
||||
name: Release
|
||||
run-name: ${{ gitea.actor }} is runs ci pipeline
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*.*.*'
|
||||
|
||||
jobs:
|
||||
packaging:
|
||||
name: Distribution
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up Python 3.11
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.11'
|
||||
- name: Update version
|
||||
run: VSN=${{ gitea.ref_name }} && sed -i -e "s/1.12.1/${VSN:1}/g" aiohttp_pydantic/__init__.py
|
||||
- name: Install invoke
|
||||
run: python -m pip install setuptools wheel invoke
|
||||
- name: Push to PyPi
|
||||
run: invoke upload --pypi-user ${{ secrets.REPO_USER }} --pypi-password ${{ secrets.REPO_PASS }} --pypi-url https://git.ahax86.ru/api/packages/pub/pypi
|
@@ -3,7 +3,7 @@ stages:
|
||||
|
||||
publish-pypi:
|
||||
stage: package
|
||||
image: python:3.10
|
||||
image: python:3.11
|
||||
script:
|
||||
- sed -i -e "s/1.12.1/${CI_COMMIT_TAG:1}/g" aiohttp_pydantic/__init__.py
|
||||
- pip install -U setuptools wheel pip; pip install invoke
|
||||
|
@@ -56,7 +56,7 @@ class MatchInfoGetter(AbstractInjector):
|
||||
self.model = type("PathModel", (BaseModel,), attrs)
|
||||
|
||||
def inject(self, request: BaseRequest, args_view: list, kwargs_view: dict):
|
||||
args_view.extend(self.model(**request.match_info).dict().values())
|
||||
args_view.extend(self.model(**request.match_info).model_dump().values())
|
||||
|
||||
|
||||
class BodyGetter(AbstractInjector):
|
||||
@@ -68,7 +68,7 @@ class BodyGetter(AbstractInjector):
|
||||
|
||||
def __init__(self, args_spec: dict, default_values: dict):
|
||||
self.arg_name, self.model = next(iter(args_spec.items()))
|
||||
schema = self.model.schema()
|
||||
schema = self.model.model_json_schema()
|
||||
if "type" not in schema:
|
||||
schema["type"] = "object"
|
||||
self._expect_object = schema["type"] == "object"
|
||||
@@ -120,7 +120,7 @@ class QueryGetter(AbstractInjector):
|
||||
|
||||
def inject(self, request: BaseRequest, args_view: list, kwargs_view: dict):
|
||||
data = self._query_to_dict(request.query)
|
||||
cleaned = self.model(**data).dict()
|
||||
cleaned = self.model(**data).model_dump()
|
||||
for group_name, (group_cls, group_attrs) in self._groups.items():
|
||||
group = group_cls()
|
||||
for attr_name in group_attrs:
|
||||
@@ -166,7 +166,7 @@ class HeadersGetter(AbstractInjector):
|
||||
|
||||
def inject(self, request: BaseRequest, args_view: list, kwargs_view: dict):
|
||||
header = {k.lower().replace("-", "_"): v for k, v in request.headers.items()}
|
||||
cleaned = self.model(**header).dict()
|
||||
cleaned = self.model(**header).model_dump()
|
||||
for group_name, (group_cls, group_attrs) in self._groups.items():
|
||||
group = group_cls()
|
||||
for attr_name in group_attrs:
|
||||
|
@@ -128,6 +128,9 @@ def _add_http_method_to_oas(
|
||||
ref_template="#/components/schemas/{model}"
|
||||
)
|
||||
|
||||
if 'description' in oas_operation.parameters[i].schema:
|
||||
oas_operation.parameters[i].description = oas_operation.parameters[i].schema['description']
|
||||
|
||||
# move definitions
|
||||
if def_sub_schemas := oas_operation.parameters[i].schema.pop("$defs", None):
|
||||
oas.components.schemas.update(def_sub_schemas)
|
||||
|
@@ -1,11 +1,12 @@
|
||||
aiohttp==3.8.4
|
||||
pydantic==2.0.2
|
||||
aiohttp==3.8.6
|
||||
pydantic==2.5.1
|
||||
jinja2==3.1.2
|
||||
swagger-4-ui-bundle==0.0.4
|
||||
pytest==7.4.0
|
||||
pytest-aiohttp==1.0.4
|
||||
pytest==7.4.3
|
||||
pytest-aiohttp==1.0.5
|
||||
pytest-asyncio==0.21.1
|
||||
pytest-cov==4.1.0
|
||||
readme-renderer==40.0
|
||||
readme-renderer==42.0
|
||||
codecov==2.1.13
|
||||
twine==4.0.2
|
||||
importlib-metadata==7.1.0
|
@@ -1,9 +1,9 @@
|
||||
aiohttp==3.8.4
|
||||
pydantic==2.0.2
|
||||
aiohttp==3.8.6
|
||||
pydantic==2.5.1
|
||||
jinja2==3.1.2
|
||||
swagger-4-ui-bundle==0.0.4
|
||||
pytest==7.4.0
|
||||
pytest-aiohttp==1.0.4
|
||||
pytest==7.4.3
|
||||
pytest-aiohttp==1.0.5
|
||||
pytest-asyncio==0.21.1
|
||||
pytest-cov==4.1.0
|
||||
readme-renderer==40.0
|
||||
readme-renderer==42.0
|
@@ -31,15 +31,15 @@ packages = find:
|
||||
python_requires = >=3.10
|
||||
install_requires =
|
||||
aiohttp
|
||||
pydantic>=2.0.0
|
||||
pydantic>=2.5.0
|
||||
swagger-4-ui-bundle
|
||||
|
||||
[options.extras_require]
|
||||
test =
|
||||
pytest==7.4.0
|
||||
pytest-aiohttp==1.0.4
|
||||
pytest-aiohttp==1.0.5
|
||||
pytest-cov==4.1.0
|
||||
readme-renderer==40.0
|
||||
readme-renderer==42.0
|
||||
ci =
|
||||
%(test)s
|
||||
codecov==2.1.13
|
||||
|
@@ -54,6 +54,6 @@ async def test_post_an_article_with_wrong_type_field_should_return_an_error_mess
|
||||
'loc': ['nb_page'],
|
||||
'msg': 'Input should be a valid integer, unable to parse string as an integer',
|
||||
'type': 'int_parsing',
|
||||
'url': 'https://errors.pydantic.dev/2.1.2/v/int_parsing'
|
||||
'url': 'https://errors.pydantic.dev/2.5/v/int_parsing'
|
||||
}
|
||||
]
|
||||
|
@@ -55,7 +55,8 @@ class Dog(BaseModel):
|
||||
barks: float
|
||||
|
||||
|
||||
Animal = RootModel[Annotated[Union[Cat, Dog], Field(discriminator='pet_type')]]
|
||||
class Animal(RootModel):
|
||||
root: Annotated[Union[Cat, Dog], Field(discriminator='pet_type')]
|
||||
|
||||
|
||||
class PetCollectionView(PydanticView):
|
||||
|
@@ -46,7 +46,7 @@ async def test_post_an_article_without_required_field_should_return_an_error_mes
|
||||
'loc_in': 'body',
|
||||
'msg': 'Field required',
|
||||
'type': 'missing',
|
||||
'url': 'https://errors.pydantic.dev/2.1.2/v/missing'
|
||||
'url': 'https://errors.pydantic.dev/2.5/v/missing'
|
||||
}
|
||||
]
|
||||
|
||||
@@ -68,7 +68,7 @@ async def test_post_an_article_with_wrong_type_field_should_return_an_error_mess
|
||||
'loc_in': 'body',
|
||||
'msg': 'Input should be a valid integer, unable to parse string as an integer',
|
||||
'type': 'int_parsing',
|
||||
'url': 'https://errors.pydantic.dev/2.1.2/v/int_parsing'
|
||||
'url': 'https://errors.pydantic.dev/2.5/v/int_parsing'
|
||||
}
|
||||
]
|
||||
|
||||
@@ -123,7 +123,7 @@ async def test_post_an_object_json_to_a_list_model_should_return_an_error(
|
||||
'loc_in': 'body',
|
||||
'msg': 'Input should be a valid list',
|
||||
'type': 'list_type',
|
||||
'url': 'https://errors.pydantic.dev/2.1.2/v/list_type'
|
||||
'url': 'https://errors.pydantic.dev/2.5/v/list_type'
|
||||
}
|
||||
]
|
||||
|
||||
|
@@ -80,7 +80,7 @@ async def test_get_article_without_required_header_should_return_an_error_messag
|
||||
'type': 'missing',
|
||||
'loc': ['signature_expired'],
|
||||
'msg': 'Field required',
|
||||
'url': 'https://errors.pydantic.dev/2.1.2/v/missing',
|
||||
'url': 'https://errors.pydantic.dev/2.5/v/missing',
|
||||
'loc_in': 'headers'
|
||||
}
|
||||
]
|
||||
@@ -104,7 +104,7 @@ async def test_get_article_with_wrong_header_type_should_return_an_error_message
|
||||
'msg': 'Input should be a valid datetime, input is too short',
|
||||
'input': 'foo',
|
||||
'ctx': {'error': 'input is too short'},
|
||||
'url': 'https://errors.pydantic.dev/2.1.2/v/datetime_parsing',
|
||||
'url': 'https://errors.pydantic.dev/2.5/v/datetime_parsing',
|
||||
'loc_in': 'headers'
|
||||
}
|
||||
]
|
||||
|
@@ -41,6 +41,6 @@ async def test_get_article_with_wrong_path_parameters_should_return_error(
|
||||
'loc_in': 'path',
|
||||
'msg': 'Input should be a valid integer, unable to parse string as an integer',
|
||||
'type': 'int_parsing',
|
||||
'url': 'https://errors.pydantic.dev/2.1.2/v/int_parsing'
|
||||
'url': 'https://errors.pydantic.dev/2.5/v/int_parsing'
|
||||
}
|
||||
]
|
||||
|
@@ -87,7 +87,7 @@ async def test_get_article_without_required_qs_should_return_an_error_message(
|
||||
'loc_in': 'query string',
|
||||
'msg': 'Field required',
|
||||
'type': 'missing',
|
||||
'url': 'https://errors.pydantic.dev/2.1.2/v/missing'
|
||||
'url': 'https://errors.pydantic.dev/2.5/v/missing'
|
||||
}
|
||||
]
|
||||
|
||||
@@ -109,7 +109,7 @@ async def test_get_article_with_wrong_qs_type_should_return_an_error_message(
|
||||
'loc_in': 'query string',
|
||||
'msg': 'Input should be a valid boolean, unable to interpret input',
|
||||
'type': 'bool_parsing',
|
||||
'url': 'https://errors.pydantic.dev/2.1.2/v/bool_parsing'
|
||||
'url': 'https://errors.pydantic.dev/2.5/v/bool_parsing'
|
||||
}
|
||||
]
|
||||
|
||||
@@ -168,7 +168,7 @@ async def test_get_article_with_multiple_value_for_qs_age_must_failed(
|
||||
'loc_in': 'query string',
|
||||
'msg': 'Input should be a valid integer',
|
||||
'type': 'int_type',
|
||||
'url': 'https://errors.pydantic.dev/2.1.2/v/int_type'
|
||||
'url': 'https://errors.pydantic.dev/2.5/v/int_type'
|
||||
}
|
||||
]
|
||||
assert resp.status == 400
|
||||
@@ -227,7 +227,7 @@ async def test_get_article_without_required_field_page(aiohttp_client, event_loo
|
||||
'loc_in': 'query string',
|
||||
'msg': 'Field required',
|
||||
'type': 'missing',
|
||||
'url': 'https://errors.pydantic.dev/2.1.2/v/missing'
|
||||
'url': 'https://errors.pydantic.dev/2.5/v/missing'
|
||||
}
|
||||
]
|
||||
assert resp.status == 400
|
||||
@@ -291,7 +291,7 @@ async def test_get_article_with_page_and_wrong_page_size(aiohttp_client, event_l
|
||||
'msg': 'Input should be a valid integer, unable to parse string as an '
|
||||
'integer',
|
||||
'type': 'int_parsing',
|
||||
'url': 'https://errors.pydantic.dev/2.1.2/v/int_parsing'
|
||||
'url': 'https://errors.pydantic.dev/2.5/v/int_parsing'
|
||||
}
|
||||
]
|
||||
assert resp.status == 400
|
||||
|
Reference in New Issue
Block a user