diff --git a/example/fake_api/schema_serpyco.py b/example/fake_api/schema_serpyco.py index 13769d7..e568f72 100644 --- a/example/fake_api/schema_serpyco.py +++ b/example/fake_api/schema_serpyco.py @@ -34,7 +34,7 @@ class UserSchema(object): company: str username: str = string_field(pattern='[\w-]+') email_address: str = string_field(format_=StringFormat.EMAIL) - id: int = None # Note: must be optional to be unused in POST user + id: typing.Optional[int] = None # Note: must be optional to be unused in POST user @dataclasses.dataclass diff --git a/setup.py b/setup.py index 775ec42..3a447ab 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ here = path.abspath(path.dirname(__file__)) install_requires = [ - 'apispec>=1.0.0b5', + 'apispec>=1.1.0', 'multidict', 'pyyaml', ] @@ -27,7 +27,7 @@ 'apispec_marshmallow_advanced>=0.3', ] serpyco_require = [ - 'apispec_serpyco>=0.9', + 'apispec_serpyco>=0.15', 'serpyco', ] tests_base_require = [ diff --git a/tests/func/fake_api/common.py b/tests/func/fake_api/common.py index 0ef3039..ac9788a 100644 --- a/tests/func/fake_api/common.py +++ b/tests/func/fake_api/common.py @@ -46,7 +46,7 @@ "first_name": {"type": "string"}, "id": {"format": "int32", "type": "integer"}, "last_name": {"type": "string"}, - "username": {"type": "string"}, + "username": {"type": "string", 'pattern': '[\\w-]+'}, }, "required": [ "company", @@ -61,7 +61,7 @@ }, "UserSchema_without_id": { "properties": { - "username": {"type": "string"}, + "username": {"type": "string", 'pattern': '[\\w-]+'}, "display_name": {"type": "string"}, "company": {"type": "string"}, "last_name": {"type": "string"}, @@ -80,7 +80,7 @@ }, "UserSchema_without_email_address_first_name_last_name": { "properties": { - "username": {"type": "string"}, + "username": {"type": "string", 'pattern': '[\\w-]+'}, "id": {"format": "int32", "type": "integer"}, "company": {"type": "string"}, "display_name": {"type": "string"}, diff --git a/tests/func/fake_api/common_serpyco.py b/tests/func/fake_api/common_serpyco.py index a2212e1..848b7d7 100644 --- a/tests/func/fake_api/common_serpyco.py +++ b/tests/func/fake_api/common_serpyco.py @@ -131,6 +131,7 @@ ] ), "tags": [], + 'securityDefinitions': {}, "swagger": "2.0", "parameters": {}, "responses": {}, @@ -151,9 +152,9 @@ "display_name": {"type": "string"}, "company": {"type": "string"}, "username": {"type": "string", "pattern": "[\\w-]+"}, - "id": {"type": "integer", "default": None}, + "id": {"type": "integer"}, }, - "required": ["display_name", "company", "username"], + "required": ["company", "display_name", "username"], "description": "A docstring to prevent auto generated docstring", }, "ListsUserSchema": { @@ -168,7 +169,7 @@ }, }, }, - "required": ["pagination", "item_nb", "items"], + "required": ["item_nb", "items", "pagination"], "description": "A docstring to prevent auto generated docstring", }, "UserSchema_exclude_id": { @@ -185,12 +186,12 @@ }, }, "required": [ + "company", + "display_name", + "email_address", "first_name", "last_name", - "display_name", - "company", "username", - "email_address", ], "description": "A docstring to prevent auto generated docstring", }, @@ -211,15 +212,15 @@ "type": "string", "format": StringFormat.EMAIL, }, - "id": {"type": "integer", "default": None}, + "id" : {'type': 'integer'}, }, "required": [ + "company", + "display_name", + "email_address", "first_name", "last_name", - "display_name", - "company", "username", - "email_address", ], "description": "A docstring to prevent auto generated docstring", }, @@ -229,7 +230,7 @@ "version": {"type": "string"}, "datetime": {"type": "string", "format": "date-time"}, }, - "required": ["version", "datetime"], + "required": ["datetime", "version"], "description": "A docstring to prevent auto generated docstring", }, "UserPathSchema": { diff --git a/tests/func/fake_api/test_fake_api_aiohttp_serpyco.py b/tests/func/fake_api/test_fake_api_aiohttp_serpyco.py index 49d82ff..8c6b341 100644 --- a/tests/func/fake_api/test_fake_api_aiohttp_serpyco.py +++ b/tests/func/fake_api/test_fake_api_aiohttp_serpyco.py @@ -1,4 +1,5 @@ # coding: utf-8 +import pytest from aiohttp import web from example.fake_api.aiohttp_serpyco import AiohttpSerpycoController @@ -125,7 +126,10 @@ async def test_func__test_fake_api_endpoints_ok__aiohttp(test_client,): resp = await app.delete("/users/1") assert resp.status == 204 - +@pytest.mark.xfail( + reason="unconsistent test. " + "see issue #147(https://github.com/algoo/hapic/issues/147)" +) async def test_func__test_fake_api_doc_ok__aiohttp_serpyco(test_client): app = web.Application() controllers = AiohttpSerpycoController() @@ -134,6 +138,5 @@ async def test_func__test_fake_api_doc_ok__aiohttp_serpyco(test_client): doc = hapic.generate_doc( title="Fake API", description="just an example of hapic API" ) - # FIXME BS 2018-11-26: Test produced doc atomic assert serpyco_SWAGGER_DOC_API == doc