Releases: stackmasteraliza/laravel-api-response-builder
v1.3.0 - Export API Documentation
What’s New
You can now export API documentation directly from the Swagger UI. With a single click, the API documentation can be downloaded in multiple formats, making it easy to import into your preferred API testing and documentation tools.
New Features
Export Dropdown in Swagger UI Header
A new Export button has been added to the documentation header, providing quick access to all available export options.
Supported Export Formats
OpenAPI Specification
- OpenAPI JSON – Standard JSON format compatible with all OpenAPI 3.0 tools
- OpenAPI YAML – Human-readable format for easier editing and version control
API Client Collections
- Postman Collection (v2.1) – Ready to import with organized folders, pre-configured variables, and auto-generated request bodies
- Insomnia Collection (v4) – Ready to import with workspace setup and environment variables
Highlights
- All exports are generated client-side for instant downloads
- No server load or additional API calls required
- Smart caching for faster repeated exports
- Toast notifications for success and error feedback
- Seamless integration with the existing dark theme UI
Closes
- Closes #6
Full Changelog: v2.9.9...v3.0.0
v2.6.0 – Zero-Config OpenAPI 3.0 Docs with Custom Dark Swagger UI
Release Description
This release introduces a fully automatic OpenAPI 3.0 documentation system with a modern, customizable dark-theme Swagger UI.
API documentation is generated directly from Laravel routes with zero configuration — no PHP attributes, annotations, or manual schema definitions required. Request and response schemas are inferred automatically from FormRequest classes, ensuring the documentation stays in sync with the codebase.
Key Highlights
- Automatic OpenAPI 3.0 spec generation from API routes
- Zero-config setup — works out of the box
- Custom Swagger UI with modern dark theme and configurable accent color
- Application branding support (name, logo, favicon)
- Built-in search, endpoint grouping, and schema explorer
- Authorization modal with Bearer Token and API Key support (persisted via localStorage)
- Raw OpenAPI JSON available for external tooling
New Endpoints
GET /api-docs— Interactive Swagger UIGET /api-docs/openapi.json— Raw OpenAPI specification
Technical Notes
- Built on Swagger UI v5
- Fully responsive UI
- No breaking changes — backward compatible
This release significantly upgrades the package from a response helper to a self-documenting API solution suitable for production use.
Swagger UI

v1.4.0 - Auto-Generated OpenAPI/Swagger Documentation
v1.4.0 – Automatic OpenAPI / Swagger Documentation
This release introduces automatic OpenAPI 3.0 documentation generation with zero configuration. All API routes are scanned automatically, and interactive Swagger documentation is available instantly — no manual annotations or setup required.
Simply visit /api-docs to explore and test your API using the built-in Swagger UI.
📘 Auto-Generated API Documentation
- Automatically generates OpenAPI 3.0 specifications from registered API routes
- No additional code required to get started
- Always stays in sync with your application routes
✨ Key Features
-
Zero-config documentation
Instantly generate API docs without writing schemas or YAML files -
Interactive Swagger UI
Built-in Swagger interface available at/api-docsfor exploring and testing endpoints -
CLI support
Generate a static OpenAPI JSON file using:php artisan api:docs
-
PHP 8 Attributes (optional)
Enhance endpoints with summaries, descriptions, tags, parameters, request bodies, and responses -
Built-in response schemas
Includes standard schemas such as:SuccessResponseErrorResponsePaginatedResponseValidationErrorResponse
-
Fully configurable
Customize documentation title, version, routes, UI theme, servers, and security schemes via configuration
⚡ Quick Start
composer require stackmasteraliza/laravel-api-responseOpen documentation:
http://your-app.com/api-docs
Generate static documentation:
php artisan api:docs🧩 Enhanced Documentation with Attributes (Optional)
Developers may optionally enhance documentation using PHP 8 attributes:
#[ApiEndpoint(
summary: 'List all users',
description: 'Retrieve a paginated list of users',
tags: ['Users']
)]
#[ApiResponse(status: 200, description: 'Success', ref: 'PaginatedResponse')]
public function index(): JsonResponse
{
return ApiResponse::success(User::paginate(15));
}Available Attributes
#[ApiEndpoint]– Summary, description, tags, deprecation#[ApiRequest]– Query and path parameters#[ApiRequestBody]– Request body schema#[ApiResponse]– Response status, description, examples
⚙️ Configuration
// config/api-response.php
'openapi' => [
'enabled' => true,
'title' => 'API Documentation',
'version' => '1.0.0',
'docs_route' => 'api-docs',
'theme_color' => '#3b82f6',
],🗂 New Files Added
src/Attributes/— PHP 8 attributes for API documentationsrc/OpenApi/OpenApiGenerator.php— OpenAPI spec generatorsrc/Console/GenerateApiDocsCommand.php— Artisan commandsrc/Http/Controllers/SwaggerController.php— Swagger UI controller
🔄 Full Changelog
v1.3.0 - Response Macros, Cursor Pagination & Testing Helpers
What's New
This release adds three powerful features to enhance extensibility, modern pagination support, and developer testing experience.
🔌 Response Macros
Define reusable custom response types using Laravel's Macroable trait:
// In AppServiceProvider boot()
ApiResponse::macro('banned', function ($reason = 'Account suspended') {
return $this->error($reason, 403);
});
// Usage
return ApiResponse::banned('Your account has been suspended');📄 Cursor Pagination Support
This release introduces full support for Laravel’s cursor-based pagination, providing significantly better performance for large datasets.
Usage
$users = User::cursorPaginate(15);
return ApiResponse::success($users);Response Structure
{
"status_code": 200,
"success": true,
"message": "Success",
"data": [],
"meta": {
"per_page": 15,
"next_cursor": "eyJpZCI6MTUuLi4",
"prev_cursor": null,
"path": "http://example.com/api/users",
"links": {
"next": "http://example.com/api/users?cursor=eyJpZCI6MTUuLi4",
"prev": null
}
}
}Cursor pagination enables efficient navigation without offset-based performance degradation.
🧪 Testing Helpers
New testing assertion macros have been added to simplify API response testing and improve test readability.
Example
$response = $this->getJson('/api/users');
$response->assertApiSuccess()
->assertApiStatusCode(200)
->assertApiMessage('Users retrieved successfully')
->assertApiHasData()
->assertApiPaginated();Available Assertions
assertApiSuccess()– Assertsuccess === trueassertApiError($statusCode = null)– Assertsuccess === falsewith optional statusassertApiStatusCode($code)– Assert status code in response bodyassertApiMessage($message)– Assert response messageassertApiHasData($key = null)– Assert data existsassertApiDataCount($count)– Assert number of data itemsassertApiData($expected)– Assert full data matchassertApiDataContains($expected)– Assert partial data matchassertApiPaginated()– Assert pagination metadata existsassertApiCursorPaginated()– Assert cursor pagination metadata existsassertApiHasErrors($key = null)– Assert error keys exist
🗂 Files Changed
src/ApiResponse.php— AddedMacroabletrait and cursor pagination supportsrc/ApiResponseServiceProvider.php— Registered testing macrossrc/Facades/ApiResponse.php— Added PHPDoc for macro methodssrc/Testing/ApiResponseAssertions.php— New testing assertions (11 methods)README.md— Updated documentation
🔄 Full Changelog
v1.2.0 - Status Code in Response Body
What's New
This release adds the HTTP status code directly in the JSON response body, making it easier for API clients to access response metadata.
New Response Format
{
"status_code": 200,
"success": true,
"message": "Success",
"data": {...}
}V.1.0.0
Laravel API Response Builder
A clean, fluent, and consistent API response builder for Laravel 10/11/12.
Features
- Standardized JSON Responses - Consistent response structure across your entire API
- Automatic Pagination Metadata - Built-in support for Laravel pagination
- Exception Handling - Automatic exception-to-response conversion
- Validation Error Formatting - Clean formatting for validation errors
- Controller Trait - Convenient trait for quick integration
Requirements
- PHP 8.1+
- Laravel 10.x or 11.x
Installation
composer require stackmasteraliza/laravel-api-response
Quick Start
use Stackmasteraliza\ApiResponse\Facades\ApiResponse;
// Success response
return ApiResponse::success($data, 'Operation successful');
// Error response
return ApiResponse::error('Something went wrong', 400);
License
MIT