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

OpenAPI Metadata for API Endpoints #1941

Merged
merged 7 commits into from
Jul 18, 2024
Merged

OpenAPI Metadata for API Endpoints #1941

merged 7 commits into from
Jul 18, 2024

Conversation

ikreymer
Copy link
Member

Updates the /docs and /redoc API endpoints to have better metadata, including our custom favicon and our logo for the /redoc endpoint.

Screenshot 2024-07-17 at 9 12 19 AM Screenshot 2024-07-17 at 9 12 50 AM

Based on info at:
https://fastapi.tiangolo.com/how-to/extending-openapi/
https://fastapi.tiangolo.com/tutorial/metadata/

Comment on lines +266 to +272
def get_api_schema():
if not app_root.openapi_schema:
app_root.openapi_schema = make_schema()

return app_root.openapi_schema

app_root.openapi = get_api_schema # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need to be defined before the docs and redoc endpoints? In local testing, /api/docs and /api/redoc are failing to load with messages like: Not Found: /api/openapi.json.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, doesn't seem to be the order, but I'm still seeing:

http://localhost:30870/api/docs

Screenshot 2024-07-17 at 12 49 49 PM

http://localhost:30870/api/redoc

Screenshot 2024-07-17 at 12 53 47 PM

@ikreymer
Copy link
Member Author

Should be fixed now, got confused and removed the /openapi.json route as I thought it was unused, but it is.

@ikreymer
Copy link
Member Author

I guess it wouldn't hurt to add these routes to tests as well..

Copy link
Contributor

@tw4l tw4l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Tests would be good, otherwise this looks great

@Shrinks99
Copy link
Member

Could we add some padding around the logo? I assume this would have to be done within the file, yeah?

@ikreymer
Copy link
Member Author

Could we add some padding around the logo? I assume this would have to be done within the file, yeah?

yep, it doesn't appear that the template supports any padding, so up to us to tweak in the file unfortunately. if you want to add a different file, go ahead!

@ikreymer
Copy link
Member Author

Added simple API tests in test_api.py

@ikreymer ikreymer merged commit b1ccdc4 into main Jul 18, 2024
5 of 6 checks passed
@ikreymer ikreymer deleted the api-metadata branch July 18, 2024 18:11
ikreymer added a commit that referenced this pull request Jul 22, 2024
- readd webhooks (regression from #1941)
- set order of tags in docs
- add missing tag to route
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 this pull request may close these issues.

3 participants