Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebAPI: Document API using OpenAPI #21817

Draft
wants to merge 1 commit into
base: v5_0_x
Choose a base branch
from

Conversation

sledgehammer999
Copy link
Member

@sledgehammer999 sledgehammer999 commented Nov 10, 2024

This is simply a demo to foster input from the community.

The process of documenting the WebAPI leaves a lot to be desired. Both in terms of actually writing down the specs and rendering them in a visually pleasing way to the end user.

The OpenAPI spec was developed for this and seems to be industry standard.
A quick guide is here.

Since it is standardized there are loads of tools that help with exploring the API, writing clients, validating, rendering documentation etc.

I am interested mainly in a) providing an easy way for others to validate their clients and b) generating helpful documentation.

I have documented the APIs of the transfer and auth controllers as a demo. As you can see each controller can be documented in its own YAML and be referenced by the main YAML. This will help with incrementally implementing OpenAPI if we decide to go that route.

If we decide to use OpenAPI, then for each controller that is documented we will require that each PR that affects its API to also make necessary changes to the OpenAPI yaml.

The generated docs can be hooked up to be served by the mainsite (CI integration should help here).
You can preview it here: https://www.qbittorrent.org/openapi-demo/

@sledgehammer999 sledgehammer999 added Documentation WebAPI WebAPI-related issues/changes labels Nov 10, 2024
@Chocobo1 Chocobo1 requested review from a team November 11, 2024 11:26
@Piccirello
Copy link
Member

There are many tools that generate the docs, each with its own shortfalls. Others don't explicitly show the enum values of the request, others the enum of the response, others the const value of a response. Final decision on the rendering tool will be made at later stage.

Just to confirm, was this PR generated manually? It would be incredible to have the docs generated automatically, even if the docs weren't perfect.

@sledgehammer999
Copy link
Member Author

The YAML file was created manually. Supposedly there are openapi code scanners -> yaml, but I very much doubt they will work correctly with our custom C++ server.

@rmartin16
Copy link
Contributor

👍🏼 I definitely support this. My process has depended on reading the code to understand the API signatures. This should also help make finding differences among versions much easier. This obviously all depends on keeping the spec up-to-date; fortunately, I am able to automatically create one for the Python interface.

This is simply a demo.
@sledgehammer999
Copy link
Member Author

You can now preview the OpenAPI spec in the browser: https://www.qbittorrent.org/openapi-demo/
I have pushed some yaml restructuring to give more helpful hints to anyone who wants to edit the spec.
Now each API "controller" is documented in its yaml file which is referenced by the main yaml file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation WebAPI WebAPI-related issues/changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants