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

Fix: Resolve Dart 3.5+ and json_serializable 6.9.0+ compatibility issues in generated dart-dio clients #20460

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mikefaille
Copy link

@mikefaille mikefaille commented Jan 13, 2025

This commit fixes compatibility problems between the generated dart-dio code, json_serializable 6.9.0+, and Dart SDK 3.5 or later.

Changes:

  • Updated pubspec.mustache:
    • Set the minimum SDK constraint for the generated package to >=3.5.0 <4.0.0, reflecting the language version used in the generated code.
    • Bump json_annotation dependency to ^4.9.0.
    • Bump json_serializable dependency to ^6.9.0.

These changes ensure that the generated code:

  • Is compatible with json_serializable 6.9.0+ and Dart SDK 3.5+.
  • Avoids Dart 3.5+ specific syntax that causes errors on older SDKs.
  • Maintains existing functionality and type safety.

@jaumard (2018/09) @josh-burton (2019/12) @amondnet (2019/12) @sbu-WBT (2020/12) @kuhnroyal (2020/12) @agilob (2020/12) @ahmednfwela (2021/08)

PS: This minor fix has been merged into master as it's a non-breaking change targeting the upcoming 7.x.0 minor release. json_serializable 6.9.0+ mandates a minimum Dart SDK of 3.5 due to its use of newer language features. Consequently, generated dart-dio clients now also require Dart SDK 3.5 or higher. Existing projects using Dart 3.0 and higher should not be impacted because this update maintains backward compatibility for the generated code's public API and serialization format. This change primarily ensures compatibility with newer projects and going forward, which often do not support older Dart versions.

Resolves: #16117, #14863

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • [ x] If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@mikefaille
Copy link
Author

mikefaille commented Jan 13, 2025

Thoroughly tested with a complex and large OpenAPI specification : https://github.com/twilio/twilio-oai/blob/main/spec/json/twilio_api_v2010.json

@mikefaille mikefaille force-pushed the fix/dart-dio-dart35-json-serialization-compatibility branch from 1982f7e to 9242d4a Compare January 13, 2025 23:15
@wing328 wing328 added this to the 7.11.0 milestone Jan 14, 2025
@mikefaille mikefaille force-pushed the fix/dart-dio-dart35-json-serialization-compatibility branch from 0fdf990 to ca3a499 Compare January 14, 2025 15:43
@mikefaille
Copy link
Author

I redo my commit. Few min.

…ues in generated dart-dio clients

This commit fixes compatibility problems between the generated dart-dio code, json_serializable 6.9.0+, and Dart SDK 3.5 or later.

Changes:

- Updated `pubspec.mustache`:
    - Set the minimum SDK constraint for the generated package to `>=3.5.0 <4.0.0`, reflecting the language version used in the generated code.
    - Bump `json_annotation` dependency to `^4.9.0`.
    - Bump `json_serializable` dependency to `^6.9.0`.

These changes ensure that the generated code:

- Is compatible with `json_serializable` 6.9.0+ and Dart SDK 3.5+.
- Avoids Dart 3.5+ specific syntax that causes errors on older SDKs.
- Maintains existing functionality and type safety.

Resolves: OpenAPITools#16117, OpenAPITools#14863
@mikefaille mikefaille force-pushed the fix/dart-dio-dart35-json-serialization-compatibility branch from ca3a499 to 7c67009 Compare January 14, 2025 15:54
@mikefaille
Copy link
Author

Done. It's ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG][DART] The language version override has to be the same in the library and its part(s).
2 participants