-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🔖 release chopper_generator v7.0.6 (#521)
- Loading branch information
Showing
7 changed files
with
291 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import 'dart:async'; | ||
import 'dart:convert'; | ||
|
||
import 'package:chopper/chopper.dart'; | ||
|
||
part 'test_service_base_url.chopper.dart'; | ||
|
||
@ChopperApi(baseUrl: 'https://localhost:4000/test') | ||
abstract class HttpTestServiceBaseUrl extends ChopperService { | ||
static HttpTestServiceBaseUrl create([ChopperClient? client]) => | ||
_$HttpTestServiceBaseUrl(client); | ||
|
||
@Get(path: '') | ||
Future<Response> getAll(); | ||
|
||
@Get(path: '/') | ||
Future<Response> getAllWithTrailingSlash(); | ||
|
||
@Get(path: '/list/string') | ||
Future<Response<List<String>>> listString(); | ||
|
||
@Get(path: '/query_param_include_null_query_vars', includeNullQueryVars: true) | ||
Future<Response<String>> getUsingQueryParamIncludeNullQueryVars({ | ||
@Query('foo') String? foo, | ||
@Query('bar') String? bar, | ||
@Query('baz') String? baz, | ||
}); | ||
|
||
@Get(path: '/list_query_param') | ||
Future<Response<String>> getUsingListQueryParam( | ||
@Query('value') List<String> value, | ||
); | ||
|
||
@Get(path: '/list_query_param_with_brackets', useBrackets: true) | ||
Future<Response<String>> getUsingListQueryParamWithBrackets( | ||
@Query('value') List<String> value, | ||
); | ||
|
||
@Get(path: '/map_query_param') | ||
Future<Response<String>> getUsingMapQueryParam( | ||
@Query('value') Map<String, dynamic> value, | ||
); | ||
|
||
@Get( | ||
path: '/map_query_param_include_null_query_vars', | ||
includeNullQueryVars: true, | ||
) | ||
Future<Response<String>> getUsingMapQueryParamIncludeNullQueryVars( | ||
@Query('value') Map<String, dynamic> value, | ||
); | ||
|
||
@Get(path: '/map_query_param_with_brackets', useBrackets: true) | ||
Future<Response<String>> getUsingMapQueryParamWithBrackets( | ||
@Query('value') Map<String, dynamic> value, | ||
); | ||
} | ||
|
||
Request customConvertRequest(Request req) { | ||
final r = JsonConverter().convertRequest(req); | ||
|
||
return applyHeader(r, 'customConverter', 'true'); | ||
} | ||
|
||
Response<T> customConvertResponse<T>(Response res) => | ||
res.copyWith(body: json.decode(res.body)); | ||
|
||
Request convertForm(Request req) { | ||
req = applyHeader(req, contentTypeKey, formEncodedHeaders); | ||
|
||
if (req.body is Map) { | ||
final body = <String, String>{}; | ||
|
||
req.body.forEach((key, val) { | ||
if (val != null) { | ||
body[key.toString()] = val.toString(); | ||
} | ||
}); | ||
|
||
req = req.copyWith(body: body); | ||
} | ||
|
||
return req; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters