http_sandbox_viewer library
A Flutter package for debugging HTTP requests and responses with Swagger-like API definitions for Retrofit + Dio.
This package provides a comprehensive HTTP debugging solution for Flutter applications, including request/response logging, API documentation, and a visual dashboard interface.
Features
- HTTP Request Logging: Intercepts and logs all HTTP requests and responses
- API Definitions: Define and document your APIs with Swagger-like definitions
- Visual Dashboard: Built-in UI to view requests, responses, and API documentation
- Retrofit Integration: Seamlessly integrates with Dio and Retrofit
- OpenAPI Support: Load API definitions from OpenAPI/Swagger specifications
- Request Execution: Execute API requests directly from the dashboard
Getting Started
- Add the interceptor to your Dio instance:
final dio = Dio();
dio.interceptors.add(HttpSandboxInterceptor());
- Show the dashboard in your app:
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => HttpSandboxDashboard(
apiDefinitions: [/* your API definitions */],
),
),
);
- Define your APIs using the builder pattern:
final apiDef = SimpleApiBuilder(
title: 'My API',
baseUrl: 'https://api.example.com',
)
.get('/users', name: 'Get Users')
.post('/users', name: 'Create User')
.build();
Classes
- ApiDefinition
- ApiDefinitionBuilder
- ApiDefinitionsDashboard
- ApiDefinitionsService
- ApiEndpoint
- ApiEndpointExecutionForm
- ApiParameter
- ApiService
- DefaultValue
- Annotation to specify default values for parameters
- EndpointSpec
- Internal class to hold endpoint specification during building.
- EnumValues
- Annotation to specify enum values for parameters
- HttpRecordsService
- HttpRequestRecord
- HttpResponseRecord
- HttpSandboxDashboard
- The main dashboard widget for viewing HTTP requests and API definitions.
- HttpSandboxInterceptor
- A Dio interceptor that captures and logs HTTP requests and responses.
- OpenApiLoader
- Loader for OpenAPI/Swagger specifications.
- ParamDescription
- Annotation to provide parameter descriptions
- RequestDetailView
- RequestExecutionForm
- ResponseType
- Annotation to specify the response type for documentation
- RetrofitInspector
- Inspector that analyzes Retrofit service classes to extract API definitions.
- SampleApiDefinitions
- Pre-built API definitions for common testing scenarios.
- SimpleApiBuilder
- Simplified builder for creating API definitions with minimal code.
- Summary
- Annotation to provide additional metadata for API endpoints.
- Tags
- Annotation to specify tags for categorizing endpoints