From edf9fedd6eb123b764d8cb3530fa5cf1a079e54f Mon Sep 17 00:00:00 2001 From: Adam Hopkins Date: Wed, 19 Jan 2022 15:33:57 +0200 Subject: [PATCH] Allow for docstring in path params (#51) --- sanic_ext/extensions/openapi/blueprint.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sanic_ext/extensions/openapi/blueprint.py b/sanic_ext/extensions/openapi/blueprint.py index 7a0997b..1b1b8c4 100644 --- a/sanic_ext/extensions/openapi/blueprint.py +++ b/sanic_ext/extensions/openapi/blueprint.py @@ -121,8 +121,21 @@ def build_spec(app, loop): ) ): continue + + kwargs = {} + if operation._autodoc and ( + parameters := operation._autodoc.get("parameters") + ): + description = None + for param in parameters: + if param["name"] == _parameter.name: + description = param["description"] + break + if description: + kwargs["description"] = description + operation.parameter( - _parameter.name, _parameter.cast, "path" + _parameter.name, _parameter.cast, "path", **kwargs ) specification.operation(uri, method, operation)