[ENHANCEMENT] Add Comprehensive OpenAPI/Swagger Documentation for REST APIs Fixes #541#550
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
|
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).
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. |
|
@lucaCigarini please run the CI |
|
I'm afraid I cannot run CI manually. The author needs to push another commit (even an empty one like this |
Hey @lucaCigarini Hello! and thanks for pointing out! Let me know if something else is needed. |
|
@shivraj1182 run linters ( |
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!