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

Deploy 3.0.6 #183

Merged
merged 32 commits into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
81d219c
GZip note
JEuler Apr 10, 2020
9d230c6
Update faq.md
JEuler Apr 10, 2020
9a153ab
CR fixes
JEuler Apr 11, 2020
40480ac
Moved to the faq.md
JEuler Apr 11, 2020
0942120
HTTP Auth example
JEuler Apr 11, 2020
482e0c0
CR fix
JEuler Apr 14, 2020
aad5b8d
CR fix
JEuler Apr 14, 2020
d48851f
Merge pull request #133 from lejard-h/mock-note
JEuler Apr 14, 2020
5efad0d
Merge branch 'develop' into gzip-note
JEuler Apr 14, 2020
7ff5e35
Merge pull request #134 from lejard-h/http-auth-faq
JEuler Apr 15, 2020
842a8aa
Merge pull request #132 from lejard-h/gzip-note
stewemetal Apr 15, 2020
506d163
Base url note
JEuler Apr 25, 2020
96c17ef
Merge pull request #135 from lejard-h/base-url-note
JEuler May 8, 2020
1dbc947
Packages upgraded (#142)
JEuler Jun 4, 2020
d45807a
Release 3.0.3
lejard-h Jun 13, 2020
c04871f
add develop branch to travis
lejard-h Jun 13, 2020
bb73914
fix travis badge
lejard-h Jun 13, 2020
903e125
Make code quality improvements in generator.dart (#147)
stewemetal Jun 24, 2020
5571ce7
Add optionalBody parameter to suppress warnings (#151)
LouisMT Jul 17, 2020
f9015ab
Fix typo and invalid code sample in documentation (#156)
BaloghTamas Jul 30, 2020
01173b6
Preserve uri current query params in buildUri (#166)
momvart Sep 8, 2020
3f9117b
This allows chopper API methods with generic attributes (#170)
cpthooch Sep 20, 2020
a721a68
Make conversion helpers can be `async` (#175)
Study-Log Sep 20, 2020
77e9651
Dependency update (#178)
JEuler Oct 17, 2020
5f2e117
Re-add Angular example and fix travis (#181)
lejard-h Oct 18, 2020
929ebd5
Publish package from travis (#182)
lejard-h Oct 18, 2020
0741f3a
Merge remote-tracking branch 'origin/master' into develop
lejard-h Oct 18, 2020
49703d6
Merge branch 'develop' of github.com:lejard-h/chopper into develop
lejard-h Oct 18, 2020
59b7a2b
fix
lejard-h Oct 18, 2020
b8fd63a
fix scopes
lejard-h Oct 18, 2020
42092d8
allow_failure
lejard-h Oct 18, 2020
85918f9
comment override
lejard-h Oct 18, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,41 @@ install:
jobs:
include:
- stage: analyze_format_test
name: "SDK: stable - chopper"
name: "SDK: stable - analyze_format_test chopper"
script: ./tool/travis.sh build dartanalyzer dartfmt test
env: PKG="chopper"
dart: stable
- stage: analyze_format_test
name: "SDK: stable - chopper generator"
name: "SDK: stable - analyze_format_test chopper_generator"
script: ./tool/travis.sh dartanalyzer dartfmt
env: PKG="chopper_generator"
dart: stable
- stage: analyze_format_test
name: "SDK: stable - example"
name: "SDK: stable - analyze_format_test example"
script: ./tool/travis.sh build dartanalyzer dartfmt
env: PKG="example"
dart: stable
allow_failures:
- stage: deploy
name: "SDK: stable - deploy chopper"
script: ./tool/publish.sh
env: PKG="chopper"
dart: stable
- stage: deploy
name: "SDK: stable - deploy chopper_generator"
script: ./tool/publish.sh
env: PKG="chopper_generator"
dart: stable
- stage: deploy
name: "SDK: stable - deploy example"
script: ./tool/publish.sh
env: PKG="example"
dart: stable

stages:
- analyze_format_test
- deploy
if: branch = master

# Only building master means that we don't run two builds for each pull request.
branches:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: Chopper is an http client generator using source_gen and inspired b

# Chopper

[![pub package](https://img.shields.io/pub/v/chopper.svg)](https://pub.dartlang.org/packages/chopper) [![Build Status](https://travis-ci.com/lejard-h/chopper.svg?branch=master)](https://travis-ci.org/lejard-h/chopper) [![codecov](https://codecov.io/gh/lejard-h/chopper/branch/master/graph/badge.svg)](https://codecov.io/gh/lejard-h/chopper)
[![pub package](https://img.shields.io/pub/v/chopper.svg)](https://pub.dartlang.org/packages/chopper) [![Build Status](https://travis-ci.com/lejard-h/chopper.svg?branch=master)](https://travis-ci.com/lejard-h/chopper.svg?branch=master) [![codecov](https://codecov.io/gh/lejard-h/chopper/branch/master/graph/badge.svg)](https://codecov.io/gh/lejard-h/chopper)

[Documentations](https://hadrien-lejard.gitbook.io/chopper)

Expand Down
87 changes: 72 additions & 15 deletions chopper/lib/src/annotations.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:async';
import 'package:meta/meta.dart';
import 'request.dart';
import 'response.dart';
Expand Down Expand Up @@ -155,58 +156,114 @@ class Method {
/// Headers [Map] that should be apply to the request
final Map<String, String> headers;

const Method(this.method, {this.path = '', this.headers = const {}});
/// Mark the body as optional to suppress warnings during code generation
final bool optionalBody;

const Method(
this.method, {
this.optionalBody,
this.path = '',
this.headers = const {},
});
}

/// Defines a method as an HTTP GET request.
@immutable
class Get extends Method {
const Get({String path = '', Map<String, String> headers = const {}})
: super(HttpMethod.Get, path: path, headers: headers);
const Get({
bool optionalBody = true,
String path = '',
Map<String, String> headers = const {},
}) : super(
HttpMethod.Get,
optionalBody: optionalBody,
path: path,
headers: headers,
);
}

/// Defines a method as an HTTP POST request.
///
/// Use the [Body] annotation to pass data to send.
@immutable
class Post extends Method {
const Post({String path = '', Map<String, String> headers = const {}})
: super(HttpMethod.Post, path: path, headers: headers);
const Post({
bool optionalBody = false,
String path = '',
Map<String, String> headers = const {},
}) : super(
HttpMethod.Post,
optionalBody: optionalBody,
path: path,
headers: headers,
);
}

/// Defines a method as an HTTP DELETE request.
@immutable
class Delete extends Method {
const Delete({String path = '', Map<String, String> headers = const {}})
: super(HttpMethod.Delete, path: path, headers: headers);
const Delete({
bool optionalBody = true,
String path = '',
Map<String, String> headers = const {},
}) : super(
HttpMethod.Delete,
optionalBody: optionalBody,
path: path,
headers: headers,
);
}

/// Defines a method as an HTTP PUT request.
///
/// Use the [Body] annotation to pass data to send.
@immutable
class Put extends Method {
const Put({String path = '', Map<String, String> headers = const {}})
: super(HttpMethod.Put, path: path, headers: headers);
const Put({
bool optionalBody = false,
String path = '',
Map<String, String> headers = const {},
}) : super(
HttpMethod.Put,
optionalBody: optionalBody,
path: path,
headers: headers,
);
}

/// Defines a method as an HTTP PATCH request.
/// Use the [Body] annotation to pass data to send.
@immutable
class Patch extends Method {
const Patch({String path = '', Map<String, String> headers = const {}})
: super(HttpMethod.Patch, path: path, headers: headers);
const Patch({
bool optionalBody = false,
String path = '',
Map<String, String> headers = const {},
}) : super(
HttpMethod.Patch,
optionalBody: optionalBody,
path: path,
headers: headers,
);
}

/// Defined a method as an HTTP HEAD request.
@immutable
class Head extends Method {
const Head({String path = '', Map<String, String> headers = const {}})
: super(HttpMethod.Head, path: path, headers: headers);
const Head({
bool optionalBody = true,
String path = '',
Map<String, String> headers = const {},
}) : super(
HttpMethod.Head,
optionalBody: optionalBody,
path: path,
headers: headers,
);
}

typedef ConvertRequest = Request Function(Request request);
typedef ConvertResponse<T> = Response Function(Response response);
typedef ConvertRequest = FutureOr<Request> Function(Request request);
typedef ConvertResponse<T> = FutureOr<Response> Function(Response response);

@immutable
class FactoryConverter {
Expand Down
5 changes: 4 additions & 1 deletion chopper/lib/src/request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,11 @@ Uri buildUri(String baseUrl, String url, Map<String, dynamic> parameters) {
}
}

final query = mapToQuery(parameters);
var query = mapToQuery(parameters);
if (query.isNotEmpty) {
if (uri.hasQuery) {
query += '&${uri.query}';
}
return uri.replace(query: query);
}
return uri;
Expand Down
19 changes: 11 additions & 8 deletions chopper/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: chopper
description: Chopper is an http client generator using source_gen and inspired from retrofit
version: 3.0.3
version: 3.0.6
homepage: https://hadrien-lejard.gitbook.io/chopper
repository: https://github.com/lejard-h/chopper
author: Hadrien Lejard <[email protected]>
Expand All @@ -10,16 +10,19 @@ environment:

dependencies:
http: ">=0.11.0 <1.0.0"
meta: ^1.1.8
meta: ^1.2.3
logging: ^0.11.4

dev_dependencies:
test: ^1.14.3
build_runner: ^1.10.0
build_test: ^1.0.0
coverage: ^0.13.9
test_coverage: ^0.4.1
test: ^1.15.4
build_runner: ^1.10.3
build_test: ^1.2.2
coverage: ^0.14.1
test_coverage:
git:
url: https://github.com/JEuler/test-coverage.git
ref: new-coverage
http_parser: ^3.1.4
pedantic: ^1.9.0
pedantic: ^1.9.2
chopper_generator:
path: ../chopper_generator
16 changes: 8 additions & 8 deletions chopper_built_value/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: chopper_built_value
description: Chopper is an http client generator using source_gen and inspired from retrofit
version: 0.0.3
version: 0.0.6
homepage: https://hadrien-lejard.gitbook.io/chopper
repository: https://github.com/lejard-h/chopper
author: Hadrien Lejard <[email protected]>
Expand All @@ -11,18 +11,18 @@ environment:
dependencies:
built_value: ^7.1.0
built_collection: ^4.3.2
chopper: ^3.0.2
http: ^0.12.1
chopper: ^3.0.3
http: ^0.12.2

dev_dependencies:
test: ^1.14.3
build_runner: ^1.10.0
test: ^1.15.4
build_runner: ^1.10.3
build_test:
coverage: ^0.13.9
test_coverage: ^0.4.1
coverage: ^0.14.1
built_value_generator: ^7.1.0
pedantic: ^1.9.0
pedantic: ^1.9.2

dependency_overrides:
analyzer: 0.40.4
chopper:
path: ../chopper
Loading