mayr_fake_api 2.0.0
mayr_fake_api: ^2.0.0 copied to clipboard
A pure Dart package that intercepts API calls and returns fake JSON responses from local files during development.
2.0.0 #
π Major Release - V2.0.0
π Breaking Changes #
-
Flat JSON Structure: New dot-notation file naming system (e.g.,
user.profile.get.json
instead ofuser/profile/get.json
)- Simplifies asset management - only need to add
assets/api/
once inpubspec.yaml
- No more multiple directory listings required
- Backwards compatible with v1.x nested structure for seamless migration
- Simplifies asset management - only need to add
-
JSON Structure Update: Changed from
data
tobody
for claritybody
represents the actual HTTP response bodystatusCode
represents the HTTP status code- V1.x Compatibility: Files using
data
are still supported for backward compatibility
β¨ New Features #
-
Debug Mode: Added
debug
parameter toMayrFakeApi.init()
for console logging- Logs request interception, file loading attempts, and response status
- Helps developers debug API simulation issues
- Example:
await MayrFakeApi.init(debug: true, ...)
-
Headers and Cookies Support: Added optional
headers
andcookies
fields to JSON responses- Simulate response headers (e.g.,
Content-Type
, custom headers) - Simulate response cookies (e.g.,
session_id
,refresh_token
) - Both fields are optional and can be omitted if not needed
- Simulate response headers (e.g.,
π’ Organizational Changes #
- Repository transferred to MayR-Labs organization
- Updated LICENSE to reflect MayR Labs (https://mayrlabs.com)
- Added company motto: "Building the future, one line at a time..."
- Updated all URLs to
https://github.com/MayR-Labs/mayr_dart_fake_api
π¦ Migration Guide from v1.x to v2.0 #
Option 1: Use Flat Structure (Recommended)
-
Convert your nested JSON files to flat structure:
assets/api/user/profile/get.json
βassets/api/user.profile.get.json
assets/api/products/details/get.json
βassets/api/products.details.get.json
assets/api/user/-/profile/get.json
βassets/api/user.-.profile.get.json
-
Update JSON structure from
data
tobody
:{ "statusCode": 200, "body": { ... }, "headers": { ... }, // Optional "cookies": { ... } // Optional }
-
Update your
pubspec.yaml
:flutter: assets: - assets/api/ # Just one line!
Option 2: Keep Nested Structure
- No changes required! V2.0 maintains full backwards compatibility with v1.x nested structure
- Files using
data
instead ofbody
continue to work - The package automatically tries flat structure first, then falls back to nested structure
π§ Technical Changes #
- Added flat file resolution with wildcard support
- Enhanced interceptor with debug logging throughout request lifecycle
- Improved error messages and debugging capabilities
1.0.0 #
- π Initial stable release
- β¨ Intercepts Dio HTTP requests and returns fake JSON responses from local assets
- π Supports flexible directory structure for organizing fake API responses
- π Supports all HTTP methods (GET, POST, PUT, DELETE, etc.)
- π Dynamic path support with wildcards (e.g.,
/user/-/profile
) - π§ Placeholder replacement in JSON responses (
$1
,$2
,$timestamp
) - π² Built-in placeholder support:
$uuid
and$ulid
- π§ Custom placeholder functionality for user-defined dynamic values
- π Automatic 204 No Content response for empty JSON files
- β οΈ Error simulation with
error.json
files - π« Customizable 404 not found responses
- β±οΈ Configurable network delay simulation
- ποΈ Enable/disable toggle for development/production
- π Comprehensive documentation and examples
- β Full test coverage
- π Fixed test suite bugs (corrected URL paths and data access patterns)
- π¦ Added
uuid
andfaker
package dependencies
0.0.1 #
- Initial release