apispec icon indicating copy to clipboard operation
apispec copied to clipboard

How could I automate the docstring?

Open RonanFelipe opened this issue 3 years ago • 1 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.

RonanFelipe avatar May 11 '22 23:05 RonanFelipe

(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.

lafrech avatar May 12 '22 06:05 lafrech