This is my FastAPI main.py
file.
from fastapi import FastAPI
from project.config.settings import base as settings
app = FastAPI(docs_url=f"{settings.URL_ROOT}/{settings.DOCS_URL}", redoc_url=None)
app.openapi_version = "3.0.0"
# some functions here
And I deployed this project to a server. But when I go to address of docs in my server, 1.2.3.4/url_root/docs_url
, it shows me following message:
Unable to render this definition
The provided definition does not specify a valid version field.
Please indicate a valid Swagger or OpenAPI version field.
Supported version fields are swagger: "2.0" and those that match openapi: 3.0.n (for example, openapi: 3.0.0).
What's the problem and how can I solve it?
UPDATE:
FastAPI is behind Nginx. All of my endpoints are working correctly, but I cannot see docs.
You should check this page for proxy settings.
but as far as i understand, you can fix this by just adding root_path to openapi_url:
app = FastAPI(
docs_url=f"/url_root/docs_url",
openapi_url="/url_root/openapi.json",
redoc_url=None)