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 controller as a demo. I am positive that 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).

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.

In the meantime there are two ways to view current demo:

  1. Copy/paste the YAML contents into https://editor-next.swagger.io/
  2. Screenshot of page rendered locally by https://github.com/Redocly/redoc

    qBittorrent WebAPI

This is simply a 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.

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.

2 participants