From abd7084bb2cdda140c3ef7224343454bfc375b63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=B5=84=E2=B5=8E=E2=B5=89=E2=B5=94=E2=B5=93=E2=B5=9B?= Date: Wed, 13 Dec 2023 09:57:52 +0100 Subject: [PATCH] doc(api): how to enable api openapi (formely swagger) frontend (#1773) --- api/NOTES.md | 20 +++++++++++++++++++- api/env.dev | 1 - 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/api/NOTES.md b/api/NOTES.md index a91c0a8ac..e075c029c 100644 --- a/api/NOTES.md +++ b/api/NOTES.md @@ -1,3 +1,21 @@ +#### autogenerated api frontend + +API can autogenerate a frontend that documents, and allows to play +with, in a limited way, its interface. Make sure you have the +following variables inside the current `.env`: + +``` +docs_url=/docs +root_path='' +``` + +If the `.env` that is in-use is based on `env.default` then it is +already the case. Start, or restart the http server, then go to +`https://127.0.0.1:8000/docs`. That is autogenerated documentation +based on pydantic schema, fastapi routes, and docstrings :wink:. + +Happy experiments, and then documentation! + #### psycopg3 API I mis-remember the psycopg v2 vs. v3 API. @@ -13,7 +31,7 @@ following pseudo code: return row["exists"] ``` -Minding the following: +Mind the following: - Where `app.state.postgresql` is the postgresql connection pooler. - Wrap explicit transaction with `async with cnx.transaction(): diff --git a/api/env.dev b/api/env.dev index 45650fd8a..ab74f5c0b 100644 --- a/api/env.dev +++ b/api/env.dev @@ -11,7 +11,6 @@ captcha_server= change_password_link=/changepassword?invitation=%s&&pass=%s DEVTOOLS_MOB_PATTERN=%(sessionId)s/devtools.mobs docs_url=/docs -docs_url=/docs EFS_DEVTOOLS_MOB_PATTERN=%(sessionId)s/devtools.mob EFS_SESSION_MOB_PATTERN=%(sessionId)s/dom.mob EMAIL_FROM=Openreplay-dev