miguelgrinberg / APIFairy

A minimalistic API framework built on top of Flask, Marshmallow and friends.
MIT License
323 stars 30 forks source link

Adding addtional documentation to `Query Parameters` for endpoints #51

Closed lewis-morris closed 2 years ago

lewis-morris commented 2 years ago

Is this possible at all?

I want to add a comment with explicit instructions for the query params, along with, possibly, extra information for each individual parameter.

Thoughts:

OpenAPI 3 specs have:

A verbose explanation of the operation behavior. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.

as i'm sure you know - I found this information all here.

lewis-morris commented 2 years ago

I've sifted through the code and found that you are already nearly doing this although its not in the repos docs.

A multi line docstring produces an "description" that can be markdown which will be very helpful.

Looking to see if I can work out why I can't make the description show on the query params.

miguelgrinberg commented 2 years ago

I think the documentation can benefit from having a detailed list of all the places in which documentation can be inserted. You would not only need to read the code of this package, but also of apispec which is the dependency that generates the OpenAPI code for Marshmallow schemas.

But in any case, as you already noticed, the docstrings from endpoints get their first line assigned to the operation summary, and the remaining lines to the description.

You can also add a description argument to any schema field, and apispec will copy that to the corresponding parameter object.

lewis-morris commented 2 years ago

I've just been through apispec's code, and found the part where they add the description, came here to mention it, but you've already beat me to it.

miguelgrinberg commented 2 years ago

This has been added in release 1.0 using annotations.