flugger 0.0.4 flugger: ^0.0.4 copied to clipboard
Map Swagger models to Flutter/Dart models in your project
Flugger #
Flugger is a powerful command-line interface (CLI) tool designed to streamline the development process in Flutter applications by automatically generating Dart models from Swagger API definitions. It ensures a quick and error-free integration of complex APIs into Flutter projects by parsing Swagger API documents and creating ready-to-use Dart models.
Features #
- Automatic Model Generation: Generate Dart models directly from Swagger API definitions.
- Custom Configuration: Utilize
flugger.yaml
to customize generation processes based on your project needs. - CLI Support: Easy-to-use CLI for generating models on-the-go.
Installation #
To install Flugger, add it as a dev_dependency in your Flutter project's pubspec.yaml
:
dev_dependencies:
flugger: <latest_version>
Then, run the following command to install the package:
flutter pub get
Configuration #
Configure Flugger by creating a flugger.yaml
file in your project root. Below is a sample configuration:
generic_imports:
- 'package:your_package/_all.dart'
swagger:
url: 'https://yourapi.com/swagger.json'
destination_path_prefix: './lib/models/'
extensions_destination_path_prefix: './lib/extensions/'
structure:
type: structured
convention: namespace
request:
name_sufix: 'RequestModel'
name_part_to_remove: 'Request'
parent_folder_name: 'request_models'
copyWith: true
fromJson: false
toJson: true
response:
name_sufix: 'ResponseModel'
name_part_to_remove: 'Response'
parent_folder_name: 'response_models'
copyWith: false
fromJson: true
toJson: false
search:
name_sufix: 'SearchModel'
name_part_to_remove: 'Search'
parent_folder_name: 'search_models'
copyWith: true
fromJson: false
toJson: true
model:
name_sufix: 'Model'
name_part_to_remove: 'Model'
parent_folder_name: 'models'
copyWith: true
fromJson: true
toJson: true
Usage #
To generate models, run the following command in your terminal:
dart run flugger
This will fetch the Swagger API definition from the specified URL and generate Dart models in the specified output directory.
Contribution #
Contributions are welcome! If you'd like to improve Flugger, please fork the repository and submit a pull request.
License #
Flugger is released under the MIT License. See the LICENSE file for more details.