Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

General improvements #13

Merged
merged 15 commits into from
May 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 34 additions & 2 deletions annotation/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# Changelog

## 0.2.0

* Added `@Extra` to pass extra options to dio requests, response, transformer and interceptors.

Example :

```dart
@http.POST('/path/')
@dio.Extra({'my_key':'my_value'})
Future<Response<String>>> myMethod();
```

* Fixed general dart style and code conventions

* Automatically `null` check with `ArgumentError.checkNotNull` for required parameters

* Now SuperClasses can use forwarding/redirecting constructors instead of static `instance()` method

Example :

```dart
@RestApi(baseUrl: "https://httpbin.org/")
abstract class RestClient {
/// Forwarding constructor
factory RestClient([Dio dio]) = _RestClient;
}
```

## 0.1.0
* fix helth issues

* fix health issues

## 0.0.1
* init

* init
10 changes: 10 additions & 0 deletions annotation/lib/dio.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import 'package:meta/meta.dart';

/// Extra data that will be passed to dio's request, response, transformer and interceptors.
@immutable
class Extra {
final Map<String, Object> data;

/// Extra data that will be passed to dio's request, response, transformer and interceptors.
const Extra(this.data);
}
10 changes: 7 additions & 3 deletions annotation/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: retrofit
version: 0.1.2
author: Trevor Wang <trevor.wang@qq.com>
version: 0.2.0

authors:
- Trevor Wang <trevor.wang@qq.com>
- Dinesh Ahuja <dev@kabiir.me>

homepage: https://mings.in/retrofit.dart/
description: retrofit.dart is an dio client generator using source_gen and inspired by Chopper and Retrofit.

environment:
sdk: ">=2.1.0 <3.0.0"
sdk: '>=2.1.0 <3.0.0'

dependencies:
meta: ^1.1.6
2 changes: 1 addition & 1 deletion example/bin/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ main(List<String> args) {
final dio = Dio();
dio.options.headers["Demo-Header"] = "demo header";
dio.options.headers["Content-Type"] = "application/json";
final client = RestClient.instance(dio);
final client = RestClient(dio);

client.ip("trevor").then((it) => print(it));
}
15 changes: 1 addition & 14 deletions example/lib/demo.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import 'package:retrofit/http.dart';
import 'package:dio/dio.dart';
import 'package:json_annotation/json_annotation.dart';

part 'demo.g.dart';
part 'demo.retrofit.dart';

@RestApi(baseUrl: "https://httpbin.org/")
abstract class RestClient {
static RestClient instance([Dio dio]) => _RestClient(dio);
factory RestClient([Dio dio]) = _RestClient;

@GET("/get")
@Headers({
Expand Down Expand Up @@ -47,14 +45,3 @@ abstract class RestClient {
@Field() int field,
@Field("field-g") String ffff});
}

@JsonSerializable()
class Result {
Map<String, dynamic> args;
Map<String, dynamic> headers;
String origin;
String url;
Result({this.args, this.headers, this.origin, this.url});

factory Result.fromJson(Map<String, dynamic> json) => _$ResultFromJson(json);
}
100 changes: 86 additions & 14 deletions example/lib/demo.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 0 additions & 97 deletions example/lib/demo.retrofit.dart

This file was deleted.

8 changes: 3 additions & 5 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,14 @@ author: Trevor Wang <trevor.wang@qq.com>
homepage:

environment:
sdk: ">=2.1.0 <3.0.0"
sdk: '>=2.1.0 <3.0.0'

dependencies:
retrofit:
json_annotation:


dev_dependencies:
retrofit_generator:
build_runner:
json_serializable:
build_runner: 1.4.0

dependency_overrides:
retrofit:
Expand Down
36 changes: 34 additions & 2 deletions generator/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
# Changelog

## 0.2.0

* Added `@Extra` to pass extra options to dio requests, response, transformer and interceptors.

Example :

```dart
@http.POST('/path/')
@dio.Extra({'my_key':'my_value'})
Future<Response<String>>> myMethod();
```

* Fixed general dart style and code conventions

* Automatically `null` check with `ArgumentError.checkNotNull` for required parameters

* Now SuperClasses can use forwarding/redirecting constructors instead of static `instance()` method

Example :

```dart
@RestApi(baseUrl: "https://httpbin.org/")
abstract class RestClient {
/// Forwarding constructor
factory RestClient([Dio dio]) = _RestClient;
}
```

## 0.1.0
* fix helth issues

* fix health issues

## 0.0.1
* init

* init
14 changes: 7 additions & 7 deletions generator/build.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Read about `build.yaml` at https://pub.dartlang.org/packages/build_config
builders:
retrofit:
target: ":retrofit"
import: "package:retrofit_generator/builder.dart"
builder_factories: ["retrofitBuilder"]
build_extensions: { ".dart": [".retrofit.part"] }
auto_apply: root_package
build_to: source
applies_builders: ["source_gen|combining_builder"]
target: ':retrofit'
import: 'package:retrofit_generator/builder.dart'
builder_factories: ['retrofitBuilder']
build_extensions: { '.dart': ['.retrofit.g.part'] }
auto_apply: dependents
build_to: cache
applies_builders: ['source_gen|combining_builder']