onyx
onyx copied to clipboard
Documentation Endpoint /api/docs Fails to Load OpenAPI Definition
Description
Accessing the documentation endpoint at /api/docs
results in a failure to load the OpenAPI definition due to an incorrect fetch path. The UI attempts to retrieve the OpenAPI schema from /openapi.json
, which leads to a Next.js 404 error page. This issue occurs because the actual OpenAPI definition is located at /api/openapi.json
, not at the root path /openapi.json
as the documentation UI expects.
Steps to Reproduce
- Navigate to the documentation endpoint
/api/docs
. - The documentation UI attempts to load.
- A 404 error is displayed, indicating the OpenAPI definition could not be fetched from
/openapi.json
.
Expected Behavior
The documentation UI at /api/docs
should successfully load the OpenAPI definition from /api/openapi.json
, displaying the API documentation without errors.
Additional Information
-
Screenshot:
Possible Solution
A potential solution involves updating the documentation UI configuration to correctly point to the OpenAPI definition at /api/openapi.json
.
Investigations
- In the FastAPI definition located in
backend/danswer/main.py
, adjusting theopenapi_url
parameter to/api/openapi.json
results in the OpenAPI schema being incorrectly served at/api/api/openapi.json
. - There appears to be no direct FastAPI configuration option to alter the fetch URL for the OpenAPI specification as used by the
/api/docs
endpoint. - The discrepancy arises because the fetch operation for the OpenAPI schema by the documentation UI does not align with the actual location where the schema is served, given the current setup.
Proposed Workaround
-
Modify Nginx Configuration: Adjust the Nginx config to route requests for
/openapi.json
directly to the API server without path rewriting. This ensures that the request for the OpenAPI schema from the documentation UI at/api/docs
is correctly directed to the actual location of the schema.
Additional Information
Conclusion
To resolve the issue without altering the FastAPI application code, a modification to the Nginx configuration is recommended. This approach ensures that the documentation UI can successfully fetch the OpenAPI definition from the intended URL.