Replace drf-yasg with drf_specatcular and make swagger enable-able in production via environment variable #22478
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.
Relates to: mozilla/addons#15019
Description
Replace
drf_yasg
withdrf_spectacular
as the more maintained and v3 supporting library. The new lib has better control over documenting serializers and supports the openapi spec v3 which natively has better type support.https://drf-spectacular.readthedocs.io/en/latest/drf_yasg.html
Testing
Dev
Run the project
Open the swagger urls:
These URLs should work, load the appropriate content and there should be no failing asset requests.
Run the generate command
Expect files in
./static-build/js/swagger/{version}.js
to be created for each supported API version (v3,v4,v5)Prod
Run the project
Expect the same as dev but the files should already exist without running the generate command as it is run during the build.
Note
Expect the files in both
static-build
andsite-static
directories in prod modeThe files will be served from the nginx server and not the olympia server
Checklist
#ISSUENUM
at the top of your PR to an existing open issue in the mozilla/addons repository.