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

Documentation Endpoint /api/docs Fails to Load OpenAPI Definition #1134

Closed
ThomasRitaine opened this issue Feb 26, 2024 · 1 comment · Fixed by #1138
Closed

Documentation Endpoint /api/docs Fails to Load OpenAPI Definition #1134

ThomasRitaine opened this issue Feb 26, 2024 · 1 comment · Fixed by #1138

Comments

@ThomasRitaine
Copy link

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

  1. Navigate to the documentation endpoint /api/docs.
  2. The documentation UI attempts to load.
  3. 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:
    openapi_404

Possible Solution

A potential solution involves updating the documentation UI configuration to correctly point to the OpenAPI definition at /api/openapi.json.

@ThomasRitaine
Copy link
Author

Investigations

  • In the FastAPI definition located in backend/danswer/main.py, adjusting the openapi_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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant