marshmallow-code / apispec

A pluggable API specification generator. Currently supports the OpenAPI Specification (f.k.a. the Swagger specification)..

Home Page:https://apispec.readthedocs.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How could I automate the docstring?

RonanFelipe opened this issue · comments

I have a file with 5 methods, each method have their own docstring, but there is too much duplication in the docstring, the parameters are almost the same for those 5 methods and I have to repeat the docstring on each method, and this application is going to get bigger which will cause the maintenance of all the docstring a problem.

I'm new to the apispec and would like to ask here how can I automate the docstring generation, if there is any? I have read the documentation about plugins and how to write my own, I have seen the path_helper() but not sure how to implement something here, checking each view method I can see the parameters with view.__code__.co_varnames , maybe I would have to perform an update on the operation object? I'm looking for some guidance how to proceed here, maybe there is something that already deal with this problem and I don't know about it.

(Assuming you're using marshmallow)

The marshmallow plugin does a good job of automatizing the process, already. A flask helper may help (see apispec-webframeworks).

You may also consider a full-featured framework such as flask-smorest or APIFlask.