Skip to content

Implement api swagger documentation with OpenAPI/SwaggerUI#15

Merged
Pvsaint merged 1 commit intoMetroLogic:mainfrom
GideonBature:api-doc
Jul 30, 2025
Merged

Implement api swagger documentation with OpenAPI/SwaggerUI#15
Pvsaint merged 1 commit intoMetroLogic:mainfrom
GideonBature:api-doc

Conversation

@GideonBature
Copy link
Copy Markdown
Contributor

This PR implements comprehensive API documentation using OpenAPI 3.0 specification and SwaggerUI for the ChainRemit backend API. This enhancement improves developer experience by providing interactive API documentation that can be used for testing and integration.

Changes Made

📚 Documentation Structure

  • Enhanced Swagger Configuration (src/swagger.ts)
    • Updated to OpenAPI 3.0 specification
    • Added comprehensive API metadata including contact info and license
    • Configured both development and production server endpoints
    • Implemented JWT Bearer authentication scheme
    • Added JSON export endpoint at /api-docs.json

🔐 Authentication Routes Documentation (src/router/auth.router.ts)

Added complete OpenAPI documentation for all authentication endpoints:

  • POST /auth/register - User registration with email/password validation
  • POST /auth/login - User authentication
  • POST /auth/logout - Secure logout (requires authentication)
  • POST /auth/verify/otp - OTP verification for email confirmation
  • POST /auth/resend-otp - Resend verification OTP
  • POST /auth/forgot-password - Password reset request
  • POST /auth/reset-password - Password reset with token
  • POST /auth/verify-email - Email verification
  • POST /auth/google-login - Google OAuth integration

📋 Data Models (src/model/user.model.ts)

  • Added comprehensive User schema definition with OpenAPI annotations
  • Documented all user properties including:
    • Core fields (id, email, password)
    • Verification status (isEmailVerified)
    • Social authentication (socialId, socialProvider)
    • Blockchain integration (walletAddress)
    • Timestamps (createdAt, updatedAt)

Features Added

  • ✅ Interactive API documentation at /api-docs
  • ✅ JSON schema export at /api-docs.json
  • ✅ Request/response examples for all endpoints
  • ✅ JWT authentication documentation
  • ✅ Comprehensive error response codes
  • ✅ Tagged endpoint organization
  • ✅ Development and production server configurations

Testing

  • Documentation is accessible at http://localhost:3000/api-docs
  • All endpoints include example requests and expected responses
  • Interactive testing available through SwaggerUI interface

Benefits

  • Developer Experience: Clear, interactive API documentation
  • Integration: Easier third-party integration with comprehensive examples
  • Maintenance: Self-documenting code with inline OpenAPI annotations
  • Testing: Built-in API testing capabilities through SwaggerUI
  • Standards Compliance: Following OpenAPI 3.0 specification

Files Modified

  • src/swagger.ts - Enhanced configuration and setup
  • src/router/auth.router.ts - Added comprehensive endpoint documentation
  • src/model/user.model.ts - Added User schema documentation

Screenshots/Demo

Access the documentation at: http://localhost:3000/api-docs

Screenshot 2025-07-29 at 3 54 30 AM Screenshot 2025-07-29 at 3 54 59 AM

Closes #12

@Pvsaint Pvsaint self-requested a review July 30, 2025 19:54
Copy link
Copy Markdown
Contributor

@Pvsaint Pvsaint left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@Pvsaint Pvsaint merged commit 2e0ee90 into MetroLogic:main Jul 30, 2025
3 checks passed
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.

BE: Implement API Documentation with OpenAPI/Swagger

2 participants