diff options
author | 2018-06-14 22:18:50 +0000 | |
---|---|---|
committer | 2018-06-14 22:18:50 +0000 | |
commit | 1e9419224b335b8f2354578b442c6aa235786fee (patch) | |
tree | ba8b4a0c0ffe549e58a39e383c2e9d7f14efa600 /pysite/views/tests/index.py | |
parent | Remove debug print from production (diff) |
Allow schemas to not use a list when applicable
Diffstat (limited to 'pysite/views/tests/index.py')
-rw-r--r-- | pysite/views/tests/index.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/pysite/views/tests/index.py b/pysite/views/tests/index.py index b96590c0..f99e3f3c 100644 --- a/pysite/views/tests/index.py +++ b/pysite/views/tests/index.py @@ -1,20 +1,23 @@ from flask import jsonify from schema import Schema -from pysite.base_route import RouteView +from pysite.base_route import APIView from pysite.constants import ValidationTypes from pysite.decorators import api_params -SCHEMA = Schema([{"test": str}]) +LIST_SCHEMA = Schema([{"test": str}]) +DICT_SCHEMA = Schema({"segfault": str}) -REQUIRED_KEYS = ["test"] - -class TestParamsView(RouteView): +class TestParamsView(APIView): path = "/testparams" name = "testparams" - @api_params(schema=SCHEMA, validation_type=ValidationTypes.params) + @api_params(schema=DICT_SCHEMA, validation_type=ValidationTypes.params) + def get(self, data): + return jsonify(data) + + @api_params(schema=LIST_SCHEMA, validation_type=ValidationTypes.params) def post(self, data): jsonified = jsonify(data) return jsonified |