Skip to content

[ENHANCEMENT] Add Comprehensive OpenAPI/Swagger Documentation for REST APIs Fixes #541#550

Open
shivraj1182 wants to merge 4 commits intocertego:developfrom
shivraj1182:feat/add-openapi-swagger-documentation
Open

[ENHANCEMENT] Add Comprehensive OpenAPI/Swagger Documentation for REST APIs Fixes #541#550
shivraj1182 wants to merge 4 commits intocertego:developfrom
shivraj1182:feat/add-openapi-swagger-documentation

Conversation

@shivraj1182
Copy link

Summary

This PR implements comprehensive OpenAPI/Swagger documentation for BuffaLogs REST APIs as requested in #541.

Changes Made

  1. Added drf-spectacular dependency (requirements.txt)

    • Added drf-spectacular>=2.0.0 for OpenAPI schema generation
  2. Configured settings (settings.py)

    • Added drf_spectacular to INSTALLED_APPS
    • Configured REST_FRAMEWORK with DEFAULT_SCHEMA_CLASS
    • Added SPECTACULAR_SETTINGS with API metadata (title, description, version)
  3. Added documentation endpoints (urls.py)

    • /api/schema/ - OpenAPI schema endpoint
    • /api/docs/ - Interactive Swagger UI documentation
    • /api/redoc/ - Alternative ReDoc documentation interface

Testing

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

  • Improved Developer Experience: Interactive API documentation for testing without reading source code
  • Better Integration: External tools can use the OpenAPI spec for integration
  • Self-Documenting: Reduces support burden with comprehensive API documentation
  • Industry Standard: Follows OpenAPI specification standards

Related Issue

Closes #541

Happy to make any adjustments based on your feedback!

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
@shivraj1182 shivraj1182 changed the title [ENHANCEMENT] Add Comprehensive OpenAPI/Swagger Documentation for REST APIs [ENHANCEMENT] Add Comprehensive OpenAPI/Swagger Documentation for REST APIs Fixes #541 Jan 27, 2026
@shivraj1182
Copy link
Author

Hey @Lorygold! I've implemented the required changes that issue #541 addresses. If anything looks off, I'd be happy to make suitable adjustments. Looking forward to your review!
Thanks for maintaining such a wonderful project.

@Lorygold
Copy link
Contributor

ERROR: No matching distribution found for drf-spectacular>=2.0.0

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).
@shivraj1182
Copy link
Author

shivraj1182 commented Feb 1, 2026

ERROR: No matching distribution found for drf-spectacular>=2.0.0

Then, does it work locally?

Hi @Lorygold! I've fixed the issue by updating the drf-spectacular version from >=2.0.0 to >=0.28.0 in the requirements.txt file.

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.

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.

[ENHANCEMENT] Add Comprehensive OpenAPI/Swagger Documentation for REST APIs

2 participants