]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
📝 Fix docstring of `servers` parameter (#14405)
authorMotov Yurii <109919500+YuriiMotov@users.noreply.github.com>
Tue, 2 Dec 2025 09:11:29 +0000 (10:11 +0100)
committerGitHub <noreply@github.com>
Tue, 2 Dec 2025 09:11:29 +0000 (09:11 +0000)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
docs/en/docs/advanced/behind-a-proxy.md
fastapi/applications.py

index f692a28e889491047a8d2aebb12a451135e9618c..f4dbd45607b0f236b287caeae69abe17d4ecf255 100644 (file)
@@ -443,6 +443,14 @@ The docs UI will interact with the server that you select.
 
 ///
 
+/// note | Technical Details
+
+The `servers` property in the OpenAPI specification is optional.
+
+If you don't specify the `servers` parameter and `root_path` is equal to `/`, the `servers` property in the generated OpenAPI schema will be omitted entirely by default, which is the equivalent of a single server with a `url` value of `/`.
+
+///
+
 ### Disable automatic server from `root_path` { #disable-automatic-server-from-root-path }
 
 If you don't want **FastAPI** to include an automatic server using the `root_path`, you can use the parameter `root_path_in_servers=False`:
index 0a47699aefc982c46c2fe7c07c43cefb13ef2b01..02193312b9e682da3087d40f90d3507c3af336db 100644 (file)
@@ -301,7 +301,12 @@ class FastAPI(Starlette):
                 browser tabs open). Or if you want to leave fixed the possible URLs.
 
                 If the servers `list` is not provided, or is an empty `list`, the
-                default value would be a `dict` with a `url` value of `/`.
+                `servers` property in the generated OpenAPI will be:
+
+                * a `dict` with a `url` value of the application's mounting point
+                (`root_path`) if it's different from `/`.
+                * otherwise, the `servers` property will be omitted from the OpenAPI
+                schema.
 
                 Each item in the `list` is a `dict` containing: