From 52f0972aea62c5b74c93ace47d16b7ad5634a7a2 Mon Sep 17 00:00:00 2001 From: Keming Date: Wed, 24 Aug 2022 13:47:51 +0800 Subject: [PATCH] fix: __root__ properties (#255) * fix: __root__ properties Signed-off-by: Keming * add test for __root__ Signed-off-by: Keming * release 1.0.0a1 Signed-off-by: Keming Signed-off-by: Keming --- setup.py | 2 +- spectree/utils.py | 3 ++- tests/test_plugin_falcon.py | 2 +- tests/test_plugin_falcon_asgi.py | 2 +- tests/test_plugin_flask.py | 2 +- tests/test_plugin_flask_blueprint.py | 2 +- tests/test_plugin_flask_view.py | 2 +- tests/test_plugin_starlette.py | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/setup.py b/setup.py index d7d82b31..e18bd69a 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ setup( name="spectree", - version="1.0.0a0", + version="1.0.0a1", license="Apache-2.0", author="Keming Yang", author_email="kemingy94@gmail.com", diff --git a/spectree/utils.py b/spectree/utils.py index 46dbe5a9..d1925bef 100644 --- a/spectree/utils.py +++ b/spectree/utils.py @@ -111,7 +111,8 @@ def parse_params( for attr in attr_to_spec_key: if hasattr(func, attr): model = models[getattr(func, attr)] - for name, schema in model["properties"].items(): + properties = model.get("properties", {model.get("title"): model}) + for name, schema in properties.items(): # Route parameters keywords taken out of schema level extra = { kw: schema.pop(kw) for kw in route_param_keywords if kw in schema diff --git a/tests/test_plugin_falcon.py b/tests/test_plugin_falcon.py index 147e6392..9cdcd94c 100644 --- a/tests/test_plugin_falcon.py +++ b/tests/test_plugin_falcon.py @@ -168,7 +168,7 @@ def on_get(self, req, resp): pass @api.validate( - json=JSON, # resp is missing completely + json=StrDict, # resp is missing completely ) def on_post(self, req, resp, json: JSON): pass diff --git a/tests/test_plugin_falcon_asgi.py b/tests/test_plugin_falcon_asgi.py index 5e5e10c9..92e3f819 100644 --- a/tests/test_plugin_falcon_asgi.py +++ b/tests/test_plugin_falcon_asgi.py @@ -104,7 +104,7 @@ async def on_get(self, req, resp): pass @api.validate( - json=JSON, # resp is missing completely + json=StrDict, # resp is missing completely ) async def on_post(self, req, resp, json: JSON): pass diff --git a/tests/test_plugin_flask.py b/tests/test_plugin_flask.py index 006dc980..8a034fe5 100644 --- a/tests/test_plugin_flask.py +++ b/tests/test_plugin_flask.py @@ -153,7 +153,7 @@ def user_address(name, address_id): @app.route("/api/no_response", methods=["GET", "POST"]) @api.validate( - json=JSON, + json=StrDict, ) def no_response(): return {} diff --git a/tests/test_plugin_flask_blueprint.py b/tests/test_plugin_flask_blueprint.py index 5c69fb66..a02c5922 100644 --- a/tests/test_plugin_flask_blueprint.py +++ b/tests/test_plugin_flask_blueprint.py @@ -142,7 +142,7 @@ def user_address(name, address_id): @app.route("/api/no_response", methods=["GET", "POST"]) @api.validate( - json=JSON, + json=StrDict, ) def no_response(): return {} diff --git a/tests/test_plugin_flask_view.py b/tests/test_plugin_flask_view.py index 8b415e28..90545aab 100644 --- a/tests/test_plugin_flask_view.py +++ b/tests/test_plugin_flask_view.py @@ -153,7 +153,7 @@ def get(self): return {} @api.validate( - json=JSON, # resp is missing completely + json=StrDict, # resp is missing completely ) def post(self, json: JSON): return {} diff --git a/tests/test_plugin_starlette.py b/tests/test_plugin_starlette.py index 2322eb39..aa1eddbc 100644 --- a/tests/test_plugin_starlette.py +++ b/tests/test_plugin_starlette.py @@ -127,7 +127,7 @@ async def user_score_model(request): @api.validate( - json=JSON, + json=StrDict, resp=Response(HTTP_200=None), ) async def no_response(request):