Fix/openapi drf spectacular v2#420
Merged
Merged
Conversation
Adds drf-spectacular for OpenAPI schema generation and pins cachetools and pytz explicitly in Pipfile to prevent transitive dep drops on clean Docker builds (root cause of the prod outage in #413).
pytz is a hard runtime dep of pandas but was silently dropped by pipenv's resolver — same class of bug that caused the #413 outage. cachetools removed since google-auth 2.49.1 (upgraded transitively via firebase-admin 7.1.0→7.3.0) no longer imports it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Re-applies the changes from #413, which were reverted in #414 after a
ModuleNotFoundError: cachetoolstook down prod.Root cause of the #413 outage
pipenv install drf-spectacularre-resolved the full dependency graph and silently droppedcachetoolsfromPipfile.lock.google-auth 2.41.1hard-importscachetoolsat startup (jwt.py:53: import cachetools), so a clean Docker build (which installs only what's in the lock file) crashed immediately on boot.What's different this time
This re-resolution also upgraded
firebase-admin(7.1.0→7.3.0), which transitively pulledgoogle-authup to 2.49.1. That version no longer usescachetools(removed from source, not just metadata) and madersaan optional extra backed bycryptographyinstead. Both drops are verified against the package source, not justRequires-Dist.pytzwas also silently dropped by the resolver despite being a hard runtime dep ofpandas 2.3.3, which is the same class of bug. Pinned explicitly inPipfileas a guard.Pipfile.lockwas regenerated from scratch and all changes are accounted for:drf-spectacularjsonschema,jsonschema-specifications,referencing,rpds-pypython-discoverypytzcachetoolsrsacryptographyinstead/api/openapi/and/api/documentation/were broken due to a version incompatibility: DRF's built-in schema generation callsget_schema_operation_parameters()on filter backends, butdjango-filterdeprecated this in v23.2 and removed it in v25.1drf-spectacular, the recommended library. It targets OpenAPI 3 (vs the older OpenAPI 2/Swagger spec), hasdjango-filtersupport, and is actively maintained.redoc.htmltemplateDISABLE_ERRORS_AND_WARNINGS: TrueinSPECTACULAR_SETTINGS) to avoid flooding container stderr with pre-existing warnings about undocumented views and unregistered authenticatorsEndpoints
/api/openapi//api/documentation//api/redoc/Tested
pipenv lockregenerated from scratch,pipenv syncapplied cleanlypython manage.py spectacular --validateexits 0 (pre-existing warnings about undocumentedAPIViews and unregisteredPlatformAuthenticationare unrelated to this change)/api/documentation/loads Swagger UI/api/redoc/loads ReDoc UINext steps
--validatereports many views omitted from the schema due to missingserializer_classon plainAPIViews, untyped path parameters, andPlatformAuthenticationnot having a registeredOpenApiAuthenticationExtension. These are pre-existing gaps. Each warning points to the exact file/line to fix/api/and at the root"", seebackend/pennmobile/urls.py:56), so the schema and Swagger UI show every endpoint duplicated. Worth investigating whether the root routes are actually used or can be removed