Skip to content

Commit

Permalink
Merge pull request #149 from algoo/fix/148_apispec_1.1_compatibility
Browse files Browse the repository at this point in the history
Fix/148 apispec 1.1 compatibility
  • Loading branch information
buxx authored Mar 21, 2019
2 parents d851263 + 534eb19 commit e3dee6c
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
2 changes: 1 addition & 1 deletion example/fake_api/schema_serpyco.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
here = path.abspath(path.dirname(__file__))

install_requires = [
'apispec>=1.0.0b5',
'apispec>=1.1.0',
'multidict',
'pyyaml',
]
Expand All @@ -27,7 +27,7 @@
'apispec_marshmallow_advanced>=0.3',
]
serpyco_require = [
'apispec_serpyco>=0.9',
'apispec_serpyco>=0.15',
'serpyco',
]
tests_base_require = [
Expand Down
6 changes: 3 additions & 3 deletions tests/func/fake_api/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"},
Expand All @@ -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"},
Expand Down
23 changes: 12 additions & 11 deletions tests/func/fake_api/common_serpyco.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
]
),
"tags": [],
'securityDefinitions': {},
"swagger": "2.0",
"parameters": {},
"responses": {},
Expand All @@ -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": {
Expand All @@ -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": {
Expand All @@ -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",
},
Expand All @@ -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",
},
Expand All @@ -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": {
Expand Down
7 changes: 5 additions & 2 deletions tests/func/fake_api/test_fake_api_aiohttp_serpyco.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# coding: utf-8
import pytest
from aiohttp import web

from example.fake_api.aiohttp_serpyco import AiohttpSerpycoController
Expand Down Expand Up @@ -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()
Expand All @@ -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

0 comments on commit e3dee6c

Please sign in to comment.