Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ahyangnb/generate_api_path
https://github.com/ahyangnb/generate_api_path
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/ahyangnb/generate_api_path
- Owner: ahyangnb
- License: mit
- Created: 2024-05-08T02:18:40.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-10-09T10:27:18.000Z (3 months ago)
- Last Synced: 2024-10-16T14:13:08.412Z (3 months ago)
- Language: Dart
- Size: 290 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Generate api path.
The generate_api_path can be generated different api path file for encode api request.
## Generate result.
debug mode:
```dart
class UrlGenerator {
static const String userInfo = '/user/info';
static const String systemHiNotice = '/system/hi/notice';
static const String flowerHiGood = '/flower/hi/good';
}
```release mode:
```dart
class UrlGenerator {
static const String userInfo = '00000000-00000000-00000-000000000000';
static const String systemHiNotice = '00000000-00000000-00000-000000000001';
static const String flowerHiGood = '00000000-00000000-00000-000000000002';
}
```## Usage
import the `generate_api_path` and `analyzer` plugin in `pubspec.yaml` file.
```yaml
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.6
# This one.
generate_api_path: ^0.0.1dev_dependencies:
flutter_test:
sdk: flutter
# This one.
analyzer: ^6.2.0
```make a file `origin.txt` on `material` directory, and write the api path in it.
the key is code and the value is the path.
```txt
00000000-00000000-00000-000000000000 -> /user/info
00000000-00000000-00000-000000000001 -> /system/hi/notice
00000000-00000000-00000-000000000002 -> /flower/hi/good
```then run the command:
```shell
dart run generate_api_path:create --origin_file_path material/origin.txt --target_file_path lib/gen/http/api_mapping_generate.dart --mode debug
```or
```shell
dart run generate_api_path:create --origin_file_path material/origin.txt --target_file_path lib/gen/http/api_mapping_generate.dart --mode release
```it will generate a file `api_mapping_generate.dart` in `lib/gen` directory and the content is:
```dart
class UrlGenerator {
static const String userInfo = '/user/info';
static const String systemHiNotice = '/system/hi/notice';
static const String flowerHiGood = '/flower/hi/good';
}
```or
```dart
class UrlGenerator {
static const String userInfo = '00000000-00000000-00000-000000000000';
static const String systemHiNotice = '00000000-00000000-00000-000000000001';
static const String flowerHiGood = '00000000-00000000-00000-000000000002';
}
```more detail see the [example](example) directory.