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

Replace drf-yasg with drf_specatcular and make swagger enable-able in production via environment variable #22478

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

KevinMind
Copy link
Contributor

@KevinMind KevinMind commented Jul 16, 2024

Relates to: mozilla/addons#15019

Description

Replace drf_yasg with drf_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

make up DOCKER_TARGET=development

Open the swagger urls:

These URLs should work, load the appropriate content and there should be no failing asset requests.

Run the generate command

make shell
./manage.py generate_js_swagger_files

Expect files in ./static-build/js/swagger/{version}.js to be created for each supported API version (v3,v4,v5)

Prod

Run the project

make up DOCKER_TARGET=production

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 and site-static directories in prod mode
The files will be served from the nginx server and not the olympia server

Checklist

  • Add #ISSUENUM at the top of your PR to an existing open issue in the mozilla/addons repository.
  • Successfully verified the change locally.
  • The change is covered by automated tests, or otherwise indicated why doing so is unnecessary/impossible.
  • Add before and after screenshots (Only for changes that impact the UI).
  • Add or update relevant docs reflecting the changes made.

@KevinMind KevinMind force-pushed the drf-spectacular branch 2 times, most recently from da8bf38 to 4bb6a48 Compare September 11, 2024 08:37
@KevinMind KevinMind force-pushed the drf-spectacular branch 5 times, most recently from 8e1b2c8 to 8fc7838 Compare September 18, 2024 10:56
@KevinMind KevinMind requested review from a team and diox and removed request for a team September 18, 2024 12:29
@KevinMind KevinMind marked this pull request as ready for review September 18, 2024 12:32
@KevinMind KevinMind force-pushed the drf-spectacular branch 4 times, most recently from bc6f99a to ad351f0 Compare September 20, 2024 08:53
@diox
Copy link
Member

diox commented Sep 20, 2024

Should I wait until #22663 is merged before reviewing this ? Or could you remove that commit (6b9dbdc) ? It makes the diff a lot bigger and harder to follow.

@KevinMind KevinMind marked this pull request as draft October 7, 2024 08:00
@KevinMind KevinMind force-pushed the drf-spectacular branch 2 times, most recently from 58a1972 to 3274418 Compare February 11, 2025 15:15
@KevinMind KevinMind marked this pull request as ready for review February 11, 2025 15:29
@KevinMind
Copy link
Contributor Author

@diox Reviving this since it has been sitting here and there is nothing stopping its merge. It is bottom of the list in priority but enables some of the work I'm doing on the data retention policy since I want to add better documentation of some of the models.

@willdurand willdurand self-requested a review February 13, 2025 13:38
@KevinMind KevinMind force-pushed the drf-spectacular branch 2 times, most recently from dc6256a to 17a800a Compare March 10, 2025 17:46
@KevinMind KevinMind requested a review from diox March 10, 2025 19:54
@KevinMind KevinMind changed the title Drf-spectacular Replace drf-yasg with drf_specatcular and make swagger enable-able in production via environment variable Mar 11, 2025
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.

2 participants