Add Swagger request/response examples for all DTOs and endpoints#92
Open
Menjay7 wants to merge 1 commit into
Open
Add Swagger request/response examples for all DTOs and endpoints#92Menjay7 wants to merge 1 commit into
Menjay7 wants to merge 1 commit into
Conversation
Contributor
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.
Description
This PR enhances the API documentation by adding comprehensive Swagger request and response examples for all DTOs and endpoints. The goal is to make the API easier to understand, test, and integrate by providing consumers with realistic payload examples directly within the Swagger UI.
Motivation
The existing Swagger documentation defines schemas and endpoints but lacks concrete examples, making it difficult for developers to:
Understand the expected request payload structure
Interpret response formats and error scenarios
Quickly test APIs through Swagger UI
Reduce onboarding time and integration mistakes
Adding examples improves the developer experience and serves as living documentation for API consumers.
Changes
Added request examples for all DTOs.
Added success response examples for all endpoints.
Added validation and error response examples where applicable.
Included example values for enums, optional fields, and nested objects.
Standardized example formatting across the API documentation.
Example
Request
{
"email": "johndoe@example.com",
"firstName": "John",
"lastName": "Doe"
}
Success Response
{
"id": "usr_123456",
"email": "johndoe@example.com",
"firstName": "John",
"lastName": "Doe",
"createdAt": "2026-06-20T12:00:00Z"
}
Validation Error Response
{
"statusCode": 400,
"message": [
"email must be an email",
"firstName should not be empty"
],
"error": "Bad Request"
}
Benefits
Improves API discoverability and usability
Reduces integration errors and support requests
Accelerates developer onboarding
Provides self-documenting, executable API examples
Standardizes documentation quality across services
Testing
Verified all endpoints display request examples in Swagger UI
Verified success and error response examples render correctly
Confirmed examples match DTO validation rules and API contracts
Checked nested DTOs and enums for accurate example generation
Obtain team review and approval
Future Considerations
Automatically generate examples from DTO metadata where possible.
Add multiple examples for endpoints with different response scenarios.
Include authentication and authorization examples for protected endpoints.
Introduce documentation checks in CI to ensure Swagger examples remain synchronized with API contracts.closed #60