From 3d17471d29c457b967ea3c150dc28721c57f53cc Mon Sep 17 00:00:00 2001 From: Klemen Tusar Date: Sun, 30 Jun 2024 11:19:55 +0100 Subject: [PATCH] :bookmark: release v8.0.1 (#625) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * :arrow_up: update dependencies and linters (#615) * :memo: update build_runner reference in readme (#616) * :page_facing_up: create symlink to chopper/LICENSE (#617) * :busts_in_silhouette: update/fix contributors (#618) * :lock: add Security Policy (#619) * πŸ› Fix null body converter (#623) * :package: directly export `qs.ListFormat` instead of internal wrapper (#624) --------- Signed-off-by: dependabot[bot] Co-authored-by: Job Guldemeester --- .all-contributorsrc | 57 +++++--- CODE-OF-CONDUCT.md | 133 ++++++++++++++++++ CONTRIBUTING.md | 111 +++++++++++++++ LICENSE | 1 + README.md | 13 +- SECURITY.md | 46 ++++++ chopper/CHANGELOG.md | 6 + chopper/README.md | 4 +- chopper/lib/chopper.dart | 2 +- chopper/lib/src/annotations.dart | 2 +- .../response_converter_interceptor.dart | 10 +- chopper/lib/src/request.dart | 2 +- chopper/lib/src/utils.dart | 10 +- chopper/pubspec.yaml | 12 +- .../response_converter_interceptor_test.dart | 58 ++++++++ chopper/test/ensure_build_test.dart | 2 + chopper/test/utils_test.dart | 2 +- chopper_built_value/CHANGELOG.md | 4 + chopper_built_value/pubspec.yaml | 6 +- chopper_generator/CHANGELOG.md | 5 + chopper_generator/lib/src/generator.dart | 10 +- chopper_generator/lib/src/utils.dart | 4 +- chopper_generator/pubspec.yaml | 9 +- chopper_generator/test/ensure_build_test.dart | 2 + ...son_serializable_squadron_worker_pool.dart | 8 +- example/lib/json_decode_service.dart | 2 +- example/pubspec.yaml | 2 +- 27 files changed, 454 insertions(+), 69 deletions(-) create mode 100644 CODE-OF-CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 120000 LICENSE create mode 100644 SECURITY.md diff --git a/.all-contributorsrc b/.all-contributorsrc index 48790593..eaf8d99a 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -1,44 +1,67 @@ { + "projectName": "chopper", + "projectOwner": "lejard-h", "files": [ "README.md" ], "imageSize": 100, "commit": false, "contributors": [ - "imageSize": 64, - "commit": false, - "contributors": [ - { + { "login": "Vovanella95", - "name": "Uladzimir_Paliukhovich", + "name": "Uladzimir Paliukhovich", "avatar_url": "https://avatars.githubusercontent.com/u/11267533?v=4", "profile": "https://github.com/Vovanella95", "contributions": [ "code" - ] - }, - { + ] + }, + { "login": "fryette", "name": "Eugeny Sampir", "avatar_url": "https://avatars.githubusercontent.com/u/3999503?v=4", "profile": "http://ysampir@gmail.com", "contributions": [ "code" - ] - }, + ] + }, + { + "login": "Guldem", + "name": "Job Guldemeester", + "avatar_url": "https://avatars.githubusercontent.com/u/11982796?v=4", + "profile": "https://github.com/Guldem", + "contributions": [ + "code", + "review", + "test", + "doc" + ] + }, { "login": "JEuler", "name": "Ivan Terekhin", "avatar_url": "https://avatars.githubusercontent.com/u/231950?v=4", "profile": "https://www.upwork.com/freelancers/~01192eefd8a1c267f7", - "contributions": [ + "contributions": [ "code", "review", "test", "doc" ] - }, -{ + }, + { + "login": "techouse", + "name": "Klemen Tusar", + "avatar_url": "https://avatars.githubusercontent.com/u/1174328?v=4", + "profile": "https://github.com/techouse", + "contributions": [ + "code", + "review", + "test", + "doc" + ] + }, + { "login": "stewemetal", "name": "IstvΓ‘n Juhos", "avatar_url": "https://avatars.githubusercontent.com/u/5860632?v=4", @@ -49,8 +72,8 @@ "test", "doc" ] -}, -{ + }, + { "login": "lejard-h", "name": "Hadrien Lejard", "avatar_url": "https://avatars.githubusercontent.com/u/7336262?v=4", @@ -63,10 +86,8 @@ ] } ], - "contributorsPerLine": 7, - "projectName": "chopper", - "projectOwner": "lejard-h", "repoType": "github", + "contributorsPerLine": 7, "repoHost": "https://github.com", "skipCi": true } diff --git a/CODE-OF-CONDUCT.md b/CODE-OF-CONDUCT.md new file mode 100644 index 00000000..0362947b --- /dev/null +++ b/CODE-OF-CONDUCT.md @@ -0,0 +1,133 @@ + +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official email address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +[techouse@gmail.com](mailto:techouse@gmail.com). +All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. + +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000..da70a90b --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,111 @@ +# Contributing + +Thank you for your interest in contributing to this project. This project relies on the help of volunteer developers for +its development and maintenance. + +Before making any changes to this repository, please first discuss the proposed changes with the repository owners +through an issue, email, or any other appropriate method of communication. + +Please note that a [code of conduct](CODE-OF-CONDUCT.md) is in place and should be adhered to during all interactions +related to the project. + +## Dart version support + +Currently, the package supports Dart versions 3.0 and above. Once a new Dart version is released, we will aim to support +it as soon as possible. If you encounter any issues with a new Dart version, please create an issue in the repository. + +## Flutter support + +This package is designed to work with Flutter 3.10 and above. We prioritize and are dedicated to maintaining +compatibility with these versions for a smooth user experience. + +## Testing + +Given the critical nature of correctly generating HTTP requests and handling API responses in the Chopper package, and +the potential for security vulnerabilities if this is not done correctly or consistently across platforms and versions +of Dart and Flutter, thorough testing is of utmost importance. Please remember to write tests for any new code you +create, using the [test](https://pub.dev/packages/test) package for all test cases. + +### Running the test suite + +To run the test suite, follow these commands: + +```bash +git clone https://github.com/lejard-h/chopper.git + +pushd chopper +dart pub get +dart test --platform vm +dart test --platform chrome +popd + +pushd chopper_generator +dart pub get +dart test --platform vm +dart test --platform chrome +popd + +pushd chopper_built_value +dart pub get +dart test --platform vm +dart test --platform chrome +popd +``` + +### Running the test suite with coverage + +```bash +pushd chopper +make show_test_coverage +popd + +pushd chopper_generator +make show_test_coverage +popd + +pushd chopper_built_value +make show_test_coverage +popd +``` + +## Submitting changes + +To contribute to this project, please submit a new pull request and provide a clear list of your changes. For guidance +on creating pull requests, you can refer to this resource. When sending a pull request, we highly appreciate the +inclusion of tests, as we strive to enhance our test coverage. +Following our coding conventions is essential, and it would be ideal if you ensure that each commit focuses on a single +feature. For commits, please write clear log messages. While concise one-line messages are suitable for small changes, +more substantial modifications should follow a format similar to the example below: + +```bash +git commit -m "A brief summary of the commit +> +> A paragraph describing what changed and its impact." +``` + +## Coding standards + +Prioritizing code readability and conciseness is essential. To achieve this, we recommend using `dart format` for code +formatting. Once your work is deemed complete, it is advisable to run the following command: + +```bash +pushd chopper +dart format lib test --output=none --set-exit-if-changed . +dart analyze lib test --fatal-infos +popd + +pushd chopper_generator +dart format lib test --output=none --set-exit-if-changed . +dart analyze lib test --fatal-infos +popd + +pushd chopper_built_value +dart format lib test --output=none --set-exit-if-changed . +dart analyze lib test --fatal-infos +popd +``` + +This command runs the Dart analyzer to identify any potential issues or inconsistencies in your code. By following these +guidelines, you can ensure a high-quality codebase. + +Thanks! diff --git a/LICENSE b/LICENSE new file mode 120000 index 00000000..878a4689 --- /dev/null +++ b/LICENSE @@ -0,0 +1 @@ +chopper/LICENSE \ No newline at end of file diff --git a/README.md b/README.md index a6a0d409..e8482903 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Chopper -[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-7-orange.svg?style=flat-square)](#contributors-) [![pub package](https://img.shields.io/pub/v/chopper.svg)](https://pub.dartlang.org/packages/chopper) [![Dart CI](https://github.com/lejard-h/chopper/workflows/Dart%20CI/badge.svg)](https://github.com/lejard-h/chopper/actions?query=workflow%3A%22Dart+CI%22) @@ -37,12 +37,13 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d - - + + - - - + + + +

Hadrien Lejard

πŸ’» πŸ‘€ ⚠️ πŸ“–

IstvΓ‘n Juhos

πŸ’» πŸ‘€ ⚠️ πŸ“–

Hadrien Lejard

πŸ’» πŸ‘€ ⚠️ πŸ“–

IstvΓ‘n Juhos

πŸ’» πŸ‘€ ⚠️ πŸ“–

Klemen Tusar

πŸ’» πŸ‘€ ⚠️ πŸ“–

Ivan Terekhin

πŸ’» πŸ‘€ ⚠️ πŸ“–

Eugeny Sampir

πŸ’»

Uladzimir_Paliukhovich

πŸ’»

Ivan Terekhin

πŸ’» πŸ‘€ ⚠️ πŸ“–

Job Guldemeester

πŸ’» πŸ‘€ ⚠️ πŸ“–

Eugeny Sampir

πŸ’»

Uladzimir Paliukhovich

πŸ’»
diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..0decb3bb --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,46 @@ +# Security Policy + +## Supported Versions + +| Version | Supported | +|---------|--------------------| +| 8.x.x | :white_check_mark: | +| 7.x.x | :x: | +| 6.x.x | :x: | +| 5.x.x | :x: | +| 4.x.x | :x: | +| 3.x.x | :x: | +| 2.x.x | :x: | +| 1.x.x | :x: | +| 0.x.x | :x: | + + +## Reporting a Vulnerability + +We take the security of our software seriously. If you believe you have found a security vulnerability, please report it +to us as described below. + +**DO NOT CREATE A GITHUB ISSUE** reporting the vulnerability. + +Instead, send an email to either [techouse@gmail.com](mailto:techouse@gmail.com) or +[i.terhin@gmail.com](mailto:i.terhin@gmail.com). + +In the report, please include the following: + +- Your name and affiliation (if any). +- A description of the technical details of the vulnerabilities. It is very important to let us know how we can + reproduce your findings. +- An explanation who can exploit this vulnerability, and what they gain when doing so -- write an attack scenario. This + will help us evaluate your submission quickly, especially if it is a complex or creative vulnerability. +- Whether this vulnerability is public or known to third parties. If it is, please provide details. + +If you don’t get an acknowledgment from us or have heard nothing from us in a week, please contact us again. + +We will send a response indicating the next steps in handling your report. We will keep you informed about the progress +towards a fix and full announcement. + +We will not disclose your identity to the public without your permission. We strive to credit researchers in our +advisories when we release a fix, but only after getting your permission. + +We appreciate your efforts to responsibly disclose your findings, and will make every effort to acknowledge your +contributions. diff --git a/chopper/CHANGELOG.md b/chopper/CHANGELOG.md index 84af67b0..11f5b754 100644 --- a/chopper/CHANGELOG.md +++ b/chopper/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## 8.0.1 + +- Fix null body converter ([#623](https://github.com/lejard-h/chopper/pull/623)) +- Directly export `qs.ListFormat` instead of internal wrapper ([#624](https://github.com/lejard-h/chopper/pull/624)) +- Update dependencies and linters ([#615](https://github.com/lejard-h/chopper/pull/615)) + ## 8.0.0 - Add per-request timeout ([#604](https://github.com/lejard-h/chopper/pull/604)) diff --git a/chopper/README.md b/chopper/README.md index d2419358..cf4d27ce 100644 --- a/chopper/README.md +++ b/chopper/README.md @@ -15,7 +15,7 @@ Chopper is an http client generator for Dart and Flutter using source_gen and in In your project's `pubspec.yaml` file, * Add *chopper*'s latest version to your *dependencies*. -* Add `build_runner: ^1.12.2` to your *dev_dependencies*. +* Add `build_runner: ^2.4.9` to your *dev_dependencies*. * *build_runner* may already be in your *dev_dependencies* depending on your project setup and other dependencies. * Add *chopper_generator*'s latest version to your *dev_dependencies*. @@ -26,7 +26,7 @@ dependencies: chopper: ^ dev_dependencies: - build_runner: ^1.12.2 + build_runner: ^2.4.9 chopper_generator: ^ ``` diff --git a/chopper/lib/chopper.dart b/chopper/lib/chopper.dart index a2b503ab..0096bbbb 100644 --- a/chopper/lib/chopper.dart +++ b/chopper/lib/chopper.dart @@ -3,6 +3,7 @@ /// [Getting Started](https://hadrien-lejard.gitbook.io/chopper) library chopper; +export 'package:qs_dart/qs_dart.dart' show ListFormat; export 'src/annotations.dart'; export 'src/authenticator.dart'; export 'src/base.dart'; @@ -14,7 +15,6 @@ export 'src/extensions.dart'; export 'src/chain/chain.dart'; export 'src/interceptors/interceptor.dart'; export 'src/converters.dart'; -export 'src/list_format.dart'; export 'src/request.dart'; export 'src/response.dart'; export 'src/utils.dart' hide mapToQuery; diff --git a/chopper/lib/src/annotations.dart b/chopper/lib/src/annotations.dart index 7c205346..c850b3b2 100644 --- a/chopper/lib/src/annotations.dart +++ b/chopper/lib/src/annotations.dart @@ -1,11 +1,11 @@ import 'dart:async'; import 'package:chopper/src/constants.dart'; -import 'package:chopper/src/list_format.dart'; import 'package:chopper/src/request.dart'; import 'package:chopper/src/response.dart'; import 'package:meta/meta.dart'; import 'package:meta/meta_meta.dart'; +import 'package:qs_dart/qs_dart.dart' show ListFormat; /// {@template ChopperApi} /// Defines a Chopper API. diff --git a/chopper/lib/src/interceptors/response_converter_interceptor.dart b/chopper/lib/src/interceptors/response_converter_interceptor.dart index 5d2dd188..07d054e4 100644 --- a/chopper/lib/src/interceptors/response_converter_interceptor.dart +++ b/chopper/lib/src/interceptors/response_converter_interceptor.dart @@ -52,17 +52,13 @@ class ResponseConverterInterceptor implements InternalInterceptor { Response response, ConvertResponse? responseConverter, ) async { - Response? newResponse; if (responseConverter != null) { - newResponse = await responseConverter(response); + response = await responseConverter(response); } else if (_converter != null) { - newResponse = await _decodeResponse(response, _converter!); + response = await _decodeResponse(response, _converter!); } - return Response( - newResponse?.base ?? response.base, - newResponse?.body ?? response.body, - ); + return Response(response.base, response.body); } /// Converts the [response] using [_converter]. diff --git a/chopper/lib/src/request.dart b/chopper/lib/src/request.dart index fbf1891b..511fca01 100644 --- a/chopper/lib/src/request.dart +++ b/chopper/lib/src/request.dart @@ -1,11 +1,11 @@ import 'dart:async' show Stream; import 'package:chopper/src/extensions.dart'; -import 'package:chopper/src/list_format.dart'; import 'package:chopper/src/utils.dart'; import 'package:equatable/equatable.dart' show EquatableMixin; import 'package:http/http.dart' as http; import 'package:meta/meta.dart'; +import 'package:qs_dart/qs_dart.dart' show ListFormat; /// {@template request} /// This class represents an HTTP request that can be made with Chopper. diff --git a/chopper/lib/src/utils.dart b/chopper/lib/src/utils.dart index 4906df9b..57643481 100644 --- a/chopper/lib/src/utils.dart +++ b/chopper/lib/src/utils.dart @@ -1,8 +1,8 @@ import 'dart:collection'; -import 'package:chopper/chopper.dart'; +import 'package:chopper/src/request.dart'; import 'package:logging/logging.dart'; -import 'package:qs_dart/qs_dart.dart' as qs; +import 'package:qs_dart/qs_dart.dart' show encode, EncodeOptions, ListFormat; /// Creates a new [Request] by copying [request] and adding a header with the /// provided key [name] and value [value] to the result. @@ -69,10 +69,10 @@ String mapToQuery( }) { listFormat ??= useBrackets == true ? ListFormat.brackets : ListFormat.repeat; - return qs.encode( + return encode( map, - qs.EncodeOptions( - listFormat: listFormat.qsListFormat, + EncodeOptions( + listFormat: listFormat, allowDots: listFormat == ListFormat.repeat, encodeDotInKeys: listFormat == ListFormat.repeat, encodeValuesOnly: listFormat == ListFormat.repeat, diff --git a/chopper/pubspec.yaml b/chopper/pubspec.yaml index f71cfdbb..dcedd18c 100644 --- a/chopper/pubspec.yaml +++ b/chopper/pubspec.yaml @@ -1,6 +1,6 @@ name: chopper description: Chopper is an http client generator using source_gen, inspired by Retrofit -version: 8.0.0 +version: 8.0.1 documentation: https://hadrien-lejard.gitbook.io/chopper repository: https://github.com/lejard-h/chopper @@ -12,21 +12,21 @@ dependencies: http: ^1.1.0 logging: ^1.2.0 meta: ^1.9.1 - qs_dart: ^1.0.10 + qs_dart: ^1.2.0 dev_dependencies: build_runner: ^2.4.9 build_test: ^2.2.2 build_verify: ^3.1.0 collection: ^1.18.0 - coverage: ^1.7.2 + coverage: ^1.8.0 data_fixture_dart: ^2.2.0 faker: ^2.1.0 http_parser: ^4.0.2 - lints: ^3.0.0 - test: ^1.25.4 + lints: ^4.0.0 + test: ^1.25.5 transparent_image: ^2.0.1 - chopper_generator: ">=8.0.0-rc.2 <9.0.0" # will be replaced by ^8.0.0 in the next release + chopper_generator: ^8.0.0 dependency_overrides: chopper_generator: diff --git a/chopper/test/chain/response_converter_interceptor_test.dart b/chopper/test/chain/response_converter_interceptor_test.dart index 1edfe680..41a3a968 100644 --- a/chopper/test/chain/response_converter_interceptor_test.dart +++ b/chopper/test/chain/response_converter_interceptor_test.dart @@ -70,6 +70,44 @@ void main() { expect(converter.called, 0); }); + test( + 'response is successful converter is not null and response converter is null, response is converted with null body', + () async { + final converter = ResponseNullBodyConverter(); + interceptorChain = InterceptorChain( + interceptors: [ + ResponseConverterInterceptor(converter: converter), + ResponseInterceptor(), + ], + request: testRequest, + ); + + final response = await interceptorChain.proceed(testRequest); + + expect(response.body, null); + expect(converter.called, 1); + }); + + test( + 'response is successful converter is not null and response converter is not null, response is converted by response converter with null body', + () async { + final converter = ResponseNullBodyConverter(); + interceptorChain = InterceptorChain( + interceptors: [ + ResponseConverterInterceptor( + converter: converter, + responseConverter: (response) => Response(response.base, null)), + ResponseInterceptor(), + ], + request: testRequest, + ); + + final response = await interceptorChain.proceed(testRequest); + + expect(response.body, null); + expect(converter.called, 0); + }); + test( 'response is unsuccessful converter is not null and response converter is not null, response is not converted', () async { @@ -153,6 +191,8 @@ void main() { expect(converter.called, 0); }); }); + + group('response converter returns converted response tests', () {}); } // ignore mutability warning for test class. @@ -173,6 +213,24 @@ class ResponseConverter implements Converter { } } +// ignore mutability warning for test class. +//ignore: must_be_immutable +class ResponseNullBodyConverter implements Converter { + int called = 0; + + @override + FutureOr convertRequest(Request request) { + return request; + } + + @override + FutureOr> convertResponse( + Response response) { + called++; + return Response(response.base, null as BodyType); + } +} + // ignore mutability warning for test class. //ignore: must_be_immutable class ResponseErrorConverter implements ErrorConverter { diff --git a/chopper/test/ensure_build_test.dart b/chopper/test/ensure_build_test.dart index 77fb9a96..b7cba6fa 100644 --- a/chopper/test/ensure_build_test.dart +++ b/chopper/test/ensure_build_test.dart @@ -1,5 +1,7 @@ @TestOn('vm') @Timeout(Duration(seconds: 120)) +library; + import 'package:build_verify/build_verify.dart'; import 'package:test/test.dart'; diff --git a/chopper/test/utils_test.dart b/chopper/test/utils_test.dart index fc4e6810..9ff140db 100644 --- a/chopper/test/utils_test.dart +++ b/chopper/test/utils_test.dart @@ -1,8 +1,8 @@ // ignore_for_file: deprecated_member_use_from_same_package -import 'package:chopper/src/list_format.dart'; import 'package:chopper/src/request.dart'; import 'package:chopper/src/utils.dart'; +import 'package:qs_dart/qs_dart.dart' show ListFormat; import 'package:test/test.dart'; import 'fixtures/example_enum.dart'; diff --git a/chopper_built_value/CHANGELOG.md b/chopper_built_value/CHANGELOG.md index f0297951..62038eff 100644 --- a/chopper_built_value/CHANGELOG.md +++ b/chopper_built_value/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 3.0.1 + +- Update dependencies and linters ([#615](https://github.com/lejard-h/chopper/pull/615)) + ## 3.0.0 - Require Chopper ^8.0.0 diff --git a/chopper_built_value/pubspec.yaml b/chopper_built_value/pubspec.yaml index d1303271..df350ada 100644 --- a/chopper_built_value/pubspec.yaml +++ b/chopper_built_value/pubspec.yaml @@ -1,6 +1,6 @@ name: chopper_built_value description: A built_value based Converter for Chopper. -version: 3.0.0 +version: 3.0.1 documentation: https://hadrien-lejard.gitbook.io/chopper/converters/built-value-converter repository: https://github.com/lejard-h/chopper @@ -14,11 +14,11 @@ dependencies: http: ^1.1.0 dev_dependencies: - test: ^1.25.4 + test: ^1.25.5 build_runner: ^2.4.9 build_test: ^2.2.2 built_value_generator: ^8.9.2 - lints: ^3.0.0 + lints: ^4.0.0 dependency_overrides: chopper: diff --git a/chopper_generator/CHANGELOG.md b/chopper_generator/CHANGELOG.md index c41e9fe1..23025dac 100644 --- a/chopper_generator/CHANGELOG.md +++ b/chopper_generator/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 8.0.1 + +- Directly export `qs.ListFormat` instead of internal wrapper ([#624](https://github.com/lejard-h/chopper/pull/624)) +- Update dependencies and linters ([#615](https://github.com/lejard-h/chopper/pull/615)) + ## 8.0.0 - Add per-request timeout ([#604](https://github.com/lejard-h/chopper/pull/604)) diff --git a/chopper_generator/lib/src/generator.dart b/chopper_generator/lib/src/generator.dart index 774d8f13..ce3efadf 100644 --- a/chopper_generator/lib/src/generator.dart +++ b/chopper_generator/lib/src/generator.dart @@ -1,3 +1,5 @@ +// ignore_for_file: deprecated_member_use + import 'dart:async' show FutureOr; import 'package:analyzer/dart/constant/value.dart'; @@ -12,7 +14,6 @@ import 'package:chopper_generator/src/vars.dart'; import 'package:code_builder/code_builder.dart'; import 'package:dart_style/dart_style.dart'; import 'package:logging/logging.dart'; -import 'package:qs_dart/qs_dart.dart' show ListFormat; import 'package:source_gen/source_gen.dart'; /// Code generator for [chopper.ChopperApi] annotated classes. @@ -404,7 +405,7 @@ final class ChopperGenerator final bool hasTag = tag.isNotEmpty; - final ListFormat? listFormat = Utils.getListFormat(method); + final chopper.ListFormat? listFormat = Utils.getListFormat(method); final bool? useBrackets = Utils.getUseBrackets(method); @@ -518,9 +519,7 @@ final class ChopperGenerator } static String _factoryForFunction(FunctionTypedElement function) => - // ignore: deprecated_member_use function.enclosingElement is ClassElement - // ignore: deprecated_member_use ? '${function.enclosingElement!.name}.${function.name}' : function.name!; @@ -640,7 +639,6 @@ final class ChopperGenerator _typeChecker(Map).isExactlyType(type) || _typeChecker(BuiltMap).isExactlyType(type)) return type; - // ignore: deprecated_member_use if (generic.isDynamic) return null; if (_typeChecker(List).isExactlyType(type) || @@ -717,7 +715,7 @@ final class ChopperGenerator bool hasParts = false, bool useQueries = false, bool useHeaders = false, - ListFormat? listFormat, + chopper.ListFormat? listFormat, @Deprecated('Use listFormat instead') bool? useBrackets, bool? includeNullQueryVars, Reference? tagRefer, diff --git a/chopper_generator/lib/src/utils.dart b/chopper_generator/lib/src/utils.dart index f04ba058..cb26cfc6 100644 --- a/chopper_generator/lib/src/utils.dart +++ b/chopper_generator/lib/src/utils.dart @@ -1,10 +1,12 @@ +// ignore_for_file: deprecated_member_use + import 'dart:math' show max; import 'package:analyzer/dart/element/element.dart'; +import 'package:chopper/chopper.dart' show ListFormat; import 'package:chopper_generator/src/extensions.dart'; import 'package:code_builder/code_builder.dart'; import 'package:collection/collection.dart'; -import 'package:qs_dart/qs_dart.dart' show ListFormat; import 'package:source_gen/source_gen.dart'; final class Utils { diff --git a/chopper_generator/pubspec.yaml b/chopper_generator/pubspec.yaml index 92e14816..dc582979 100644 --- a/chopper_generator/pubspec.yaml +++ b/chopper_generator/pubspec.yaml @@ -1,6 +1,6 @@ name: chopper_generator description: Chopper is an http client generator using source_gen, inspired by Retrofit -version: 8.0.0 +version: 8.0.1 documentation: https://hadrien-lejard.gitbook.io/chopper repository: https://github.com/lejard-h/chopper @@ -11,22 +11,21 @@ dependencies: analyzer: ^6.4.1 build: ^2.4.1 built_collection: ^5.1.1 - chopper: ^8.0.0 + chopper: ^8.0.1 code_builder: ^4.10.0 dart_style: ^2.3.6 logging: ^1.2.0 meta: ^1.9.1 source_gen: ^1.5.0 yaml: ^3.1.2 - qs_dart: ^1.0.10 collection: ^1.18.0 dev_dependencies: build_runner: ^2.4.9 build_verify: ^3.1.0 http: ^1.1.0 - lints: ^3.0.0 - test: ^1.25.4 + lints: ^4.0.0 + test: ^1.25.5 dependency_overrides: chopper: diff --git a/chopper_generator/test/ensure_build_test.dart b/chopper_generator/test/ensure_build_test.dart index 84c677fc..2133b15c 100644 --- a/chopper_generator/test/ensure_build_test.dart +++ b/chopper_generator/test/ensure_build_test.dart @@ -1,5 +1,7 @@ @TestOn('vm') @Timeout(Duration(seconds: 120)) +library; + import 'package:build_verify/build_verify.dart'; import 'package:test/test.dart'; diff --git a/example/bin/main_json_serializable_squadron_worker_pool.dart b/example/bin/main_json_serializable_squadron_worker_pool.dart index f2e268cd..1ea09a4f 100644 --- a/example/bin/main_json_serializable_squadron_worker_pool.dart +++ b/example/bin/main_json_serializable_squadron_worker_pool.dart @@ -1,7 +1,7 @@ -/// This example uses -/// - https://github.com/google/json_serializable.dart -/// - https://github.com/d-markey/squadron -/// - https://github.com/d-markey/squadron_builder +// This example uses +// - https://github.com/google/json_serializable.dart +// - https://github.com/d-markey/squadron +// - https://github.com/d-markey/squadron_builder import 'dart:async' show FutureOr; import 'dart:convert' show jsonDecode; diff --git a/example/lib/json_decode_service.dart b/example/lib/json_decode_service.dart index 299b73c3..293f267e 100644 --- a/example/lib/json_decode_service.dart +++ b/example/lib/json_decode_service.dart @@ -1,4 +1,4 @@ -/// This example uses https://github.com/d-markey/squadron_builder +// This example uses https://github.com/d-markey/squadron_builder import 'dart:async'; import 'dart:convert' show json; diff --git a/example/pubspec.yaml b/example/pubspec.yaml index df06f946..510c6c82 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -21,7 +21,7 @@ dev_dependencies: chopper_generator: json_serializable: ^6.8.0 built_value_generator: ^8.9.2 - lints: ^3.0.0 + lints: ^4.0.0 squadron_builder: ^2.4.5 dependency_overrides: