From 937c09e2b7cd6ec815b9814ed09b91b3b55741ca Mon Sep 17 00:00:00 2001 From: Georg K Date: Wed, 1 Nov 2023 03:55:10 +0300 Subject: [PATCH] feat: add description to parameters; bump: libs and tests; bump: 2.0.3 --- aiohttp_pydantic/oas/view.py | 3 +++ requirements/ci.txt | 10 +++++----- requirements/test.txt | 10 +++++----- setup.cfg | 6 +++--- tests/test_hook_to_custom_response.py | 2 +- tests/test_validation_body.py | 6 +++--- tests/test_validation_header.py | 4 ++-- tests/test_validation_path.py | 2 +- tests/test_validation_query_string.py | 10 +++++----- 9 files changed, 28 insertions(+), 25 deletions(-) diff --git a/aiohttp_pydantic/oas/view.py b/aiohttp_pydantic/oas/view.py index adc0ca0..3999c78 100644 --- a/aiohttp_pydantic/oas/view.py +++ b/aiohttp_pydantic/oas/view.py @@ -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) diff --git a/requirements/ci.txt b/requirements/ci.txt index ceaefd4..b647937 100644 --- a/requirements/ci.txt +++ b/requirements/ci.txt @@ -1,11 +1,11 @@ -aiohttp==3.8.4 -pydantic==2.0.2 +aiohttp==3.8.6 +pydantic==2.4.2 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 \ No newline at end of file diff --git a/requirements/test.txt b/requirements/test.txt index b2285f6..cfa1dc4 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,9 +1,9 @@ -aiohttp==3.8.5 -pydantic==2.3.0 +aiohttp==3.8.6 +pydantic==2.4.2 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==41.0 \ No newline at end of file +readme-renderer==42.0 \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 6dbb243..cce0138 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,15 +31,15 @@ packages = find: python_requires = >=3.10 install_requires = aiohttp - pydantic>=2.0.0 + pydantic>=2.4.2 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 diff --git a/tests/test_hook_to_custom_response.py b/tests/test_hook_to_custom_response.py index abcabd5..49edd7d 100644 --- a/tests/test_hook_to_custom_response.py +++ b/tests/test_hook_to_custom_response.py @@ -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.3/v/int_parsing' + 'url': 'https://errors.pydantic.dev/2.4/v/int_parsing' } ] diff --git a/tests/test_validation_body.py b/tests/test_validation_body.py index ec4d984..d95b994 100644 --- a/tests/test_validation_body.py +++ b/tests/test_validation_body.py @@ -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.3/v/missing' + 'url': 'https://errors.pydantic.dev/2.4/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.3/v/int_parsing' + 'url': 'https://errors.pydantic.dev/2.4/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.3/v/list_type' + 'url': 'https://errors.pydantic.dev/2.4/v/list_type' } ] diff --git a/tests/test_validation_header.py b/tests/test_validation_header.py index 9372d6b..589f4b3 100644 --- a/tests/test_validation_header.py +++ b/tests/test_validation_header.py @@ -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.3/v/missing', + 'url': 'https://errors.pydantic.dev/2.4/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.3/v/datetime_parsing', + 'url': 'https://errors.pydantic.dev/2.4/v/datetime_parsing', 'loc_in': 'headers' } ] diff --git a/tests/test_validation_path.py b/tests/test_validation_path.py index f549d57..55bf41a 100644 --- a/tests/test_validation_path.py +++ b/tests/test_validation_path.py @@ -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.3/v/int_parsing' + 'url': 'https://errors.pydantic.dev/2.4/v/int_parsing' } ] diff --git a/tests/test_validation_query_string.py b/tests/test_validation_query_string.py index ed5b7d8..cb7fd8c 100644 --- a/tests/test_validation_query_string.py +++ b/tests/test_validation_query_string.py @@ -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.3/v/missing' + 'url': 'https://errors.pydantic.dev/2.4/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.3/v/bool_parsing' + 'url': 'https://errors.pydantic.dev/2.4/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.3/v/int_type' + 'url': 'https://errors.pydantic.dev/2.4/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.3/v/missing' + 'url': 'https://errors.pydantic.dev/2.4/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.3/v/int_parsing' + 'url': 'https://errors.pydantic.dev/2.4/v/int_parsing' } ] assert resp.status == 400