From 72ddf180562339dde56c00a140e06814de87eb3f Mon Sep 17 00:00:00 2001 From: "Alexander B. Ustinov" Date: Fri, 9 Dec 2022 13:33:21 +0300 Subject: [PATCH 1/2] document api.doc parameter description via dict --- doc/swagger.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/doc/swagger.rst b/doc/swagger.rst index d63d7dfd..9bbb00f5 100644 --- a/doc/swagger.rst +++ b/doc/swagger.rst @@ -28,6 +28,16 @@ You can document a class or a method: def post(self, id): api.abort(403) +If you want a finer control, nested dicts could also be used: + +.. code-block:: python + + @api.route('/my-resource/', endpoint='my-resource') + @api.doc(params={'id': {'description': 'An ID', 'required': 'true', 'default': ''}}) + class MyResource(Resource): + def get(self, id): + return {} + Automatically documented models ------------------------------- From da634c2eeb803ab1fd6d5dce25dddcdda74e8d20 Mon Sep 17 00:00:00 2001 From: "Alexander B. Ustinov" Date: Fri, 1 Mar 2024 19:12:45 +0300 Subject: [PATCH 2/2] required should be bool for correct evaluation --- doc/swagger.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/swagger.rst b/doc/swagger.rst index 9bbb00f5..55837ad6 100644 --- a/doc/swagger.rst +++ b/doc/swagger.rst @@ -33,7 +33,7 @@ If you want a finer control, nested dicts could also be used: .. code-block:: python @api.route('/my-resource/', endpoint='my-resource') - @api.doc(params={'id': {'description': 'An ID', 'required': 'true', 'default': ''}}) + @api.doc(params={'id': {'description': 'An ID', 'required': False, 'default': ''}}) class MyResource(Resource): def get(self, id): return {}