[ENHANCEMENT] Add Comprehensive OpenAPI/Swagger Documentation for REST APIs Fixes #541#550
Open
shivraj1182 wants to merge 4 commits intocertego:developfrom
Open
Conversation
Add drf-spectacular (>=2.0.0) to requirements.txt to enable OpenAPI/Swagger schema generation for BuffaLogs REST APIs. This addresses issue certego#541 by adding the foundation for comprehensive interactive API documentation.
- Add drf_spectacular to INSTALLED_APPS - Configure REST_FRAMEWORK with DEFAULT_SCHEMA_CLASS - Add SPECTACULAR_SETTINGS with API metadata (title, description, version) Part of issue certego#541
- Import drf-spectacular views (SpectacularAPIView, SpectacularSwaggerView, SpectacularRedocView) - Add three URL patterns: - /api/schema/ - OpenAPI schema endpoint - /api/docs/ - Interactive Swagger UI documentation - /api/redoc/ - Alternative ReDoc documentation interface Completes the implementation of issue certego#541
Author
Contributor
|
Then, does it work locally? |
Changed drf-spectacular version from >=2.0.0 to >=0.28.0 as version 2.0.0 does not exist. The latest available version is 0.28.0 (released November 2024).
Author
Hi @Lorygold! I've fixed the issue by updating the drf-spectacular version from The version 2.0.0 doesn't exist on PyPI - the latest available version is 0.28.0 (released November 2024). That's why it didnt work locally! This should resolve the CI failure. |
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
This PR implements comprehensive OpenAPI/Swagger documentation for BuffaLogs REST APIs as requested in #541.
Changes Made
Added drf-spectacular dependency (
requirements.txt)drf-spectacular>=2.0.0for OpenAPI schema generationConfigured settings (
settings.py)drf_spectaculartoINSTALLED_APPSREST_FRAMEWORKwithDEFAULT_SCHEMA_CLASSSPECTACULAR_SETTINGSwith API metadata (title, description, version)Added documentation endpoints (
urls.py)/api/schema/- OpenAPI schema endpoint/api/docs/- Interactive Swagger UI documentation/api/redoc/- Alternative ReDoc documentation interfaceTesting
After deployment, the following endpoints will be available:
/api/docs/- Interactive Swagger UI for API testing/api/redoc/- Alternative ReDoc interface/api/schema/- Raw OpenAPI schema (JSON)Benefits
Related Issue
Closes #541
Happy to make any adjustments based on your feedback!