From 06ed7c82056aace4651d65ec56b68e4520739b53 Mon Sep 17 00:00:00 2001 From: Tadas Krivickas Date: Sun, 28 Apr 2024 17:09:10 +0300 Subject: [PATCH] [dart] [dart-dio] Support Dart3 (#18001) * Support both dart 2.x and 3.x * Append dart3 keywords * Update docs --- bin/utils/dart-keywords/README.md | 5 +- bin/utils/dart-keywords/dart-version.txt | 2 +- bin/utils/dart-keywords/pubspec.lock | 159 +++++++----------- bin/utils/dart-keywords/pubspec.yaml | 2 +- .../dart-keywords/save-dart-keywords.dart | 11 +- bin/utils/dart-keywords/save_dart_keywords.sh | 5 +- docs/generators/dart-dio.md | 4 + docs/generators/dart.md | 6 +- .../languages/AbstractDartCodegen.java | 2 +- .../src/main/resources/dart/dart-keywords.txt | 4 + .../dart/libraries/dio/pubspec.mustache | 2 +- .../src/main/resources/dart2/pubspec.mustache | 2 +- .../petstore/dart-dio/oneof/pubspec.yaml | 2 +- .../pubspec.yaml | 2 +- .../dart-dio/oneof_primitive/pubspec.yaml | 2 +- .../pubspec.yaml | 2 +- .../petstore_client_lib_fake/pubspec.yaml | 2 +- .../pubspec.yaml | 2 +- .../dart2/petstore_client_lib/pubspec.yaml | 2 +- .../petstore_client_lib_fake/pubspec.yaml | 2 +- 20 files changed, 89 insertions(+), 131 deletions(-) diff --git a/bin/utils/dart-keywords/README.md b/bin/utils/dart-keywords/README.md index 2873e00dbe14..2d14a81b61d7 100644 --- a/bin/utils/dart-keywords/README.md +++ b/bin/utils/dart-keywords/README.md @@ -11,10 +11,7 @@ The last Dart version that was used to generate the keywords can be found in `da ## What does the shellscript do? -1. compile a dart app - - `dart2native save-dart-keywords.dart` - 1. run the dart app - - `./save-dart-keywords.exe` + - `dart run save-dart-keywords.dart` 1. the output is `dart-keywords.txt` and `dart-version.txt` diff --git a/bin/utils/dart-keywords/dart-version.txt b/bin/utils/dart-keywords/dart-version.txt index 81b2d0d2cd6a..d580ed2666a0 100644 --- a/bin/utils/dart-keywords/dart-version.txt +++ b/bin/utils/dart-keywords/dart-version.txt @@ -1 +1 @@ -Dart VM version: 2.7.0-dev.0.0 (Tue Nov 5 12:57:33 2019 +0100) on "macos_x64" +Dart SDK version: 3.3.0 (stable) (Tue Feb 13 10:25:19 2024 +0000) on "macos_arm64" diff --git a/bin/utils/dart-keywords/pubspec.lock b/bin/utils/dart-keywords/pubspec.lock index f01fb3f2efb0..62299e22a523 100644 --- a/bin/utils/dart-keywords/pubspec.lock +++ b/bin/utils/dart-keywords/pubspec.lock @@ -5,190 +5,145 @@ packages: dependency: transitive description: name: _fe_analyzer_shared - url: "https://pub.dartlang.org" + sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7" + url: "https://pub.dev" source: hosted - version: "1.0.0" + version: "67.0.0" analyzer: dependency: "direct main" description: name: analyzer - url: "https://pub.dartlang.org" + sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d" + url: "https://pub.dev" source: hosted - version: "0.39.1" - args: - dependency: transitive - description: - name: args - url: "https://pub.dartlang.org" - source: hosted - version: "1.5.2" + version: "6.4.1" async: dependency: transitive description: name: async - url: "https://pub.dartlang.org" - source: hosted - version: "2.4.0" - charcode: - dependency: transitive - description: - name: charcode - url: "https://pub.dartlang.org" + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" source: hosted - version: "1.1.2" + version: "2.11.0" collection: dependency: transitive description: name: collection - url: "https://pub.dartlang.org" + sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a + url: "https://pub.dev" source: hosted - version: "1.14.12" + version: "1.18.0" convert: dependency: transitive description: name: convert - url: "https://pub.dartlang.org" + sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592" + url: "https://pub.dev" source: hosted - version: "2.1.1" + version: "3.1.1" crypto: dependency: transitive description: name: crypto - url: "https://pub.dartlang.org" - source: hosted - version: "2.1.3" - csslib: - dependency: transitive - description: - name: csslib - url: "https://pub.dartlang.org" + sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab + url: "https://pub.dev" source: hosted - version: "0.16.1" - front_end: + version: "3.0.3" + file: dependency: transitive description: - name: front_end - url: "https://pub.dartlang.org" + name: file + sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c" + url: "https://pub.dev" source: hosted - version: "0.1.29" + version: "7.0.0" glob: dependency: transitive description: name: glob - url: "https://pub.dartlang.org" - source: hosted - version: "1.2.0" - html: - dependency: transitive - description: - name: html - url: "https://pub.dartlang.org" - source: hosted - version: "0.14.0+3" - js: - dependency: transitive - description: - name: js - url: "https://pub.dartlang.org" + sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63" + url: "https://pub.dev" source: hosted - version: "0.6.1+1" - kernel: - dependency: transitive - description: - name: kernel - url: "https://pub.dartlang.org" - source: hosted - version: "0.3.29" + version: "2.1.2" meta: dependency: transitive description: name: meta - url: "https://pub.dartlang.org" - source: hosted - version: "1.1.8" - node_interop: - dependency: transitive - description: - name: node_interop - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.3" - node_io: - dependency: transitive - description: - name: node_io - url: "https://pub.dartlang.org" + sha256: "7687075e408b093f36e6bbf6c91878cc0d4cd10f409506f7bc996f68220b9136" + url: "https://pub.dev" source: hosted - version: "1.0.1+2" + version: "1.12.0" package_config: dependency: transitive description: name: package_config - url: "https://pub.dartlang.org" + sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd" + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "2.1.0" path: dependency: transitive description: name: path - url: "https://pub.dartlang.org" - source: hosted - version: "1.6.4" - pedantic: - dependency: transitive - description: - name: pedantic - url: "https://pub.dartlang.org" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" + url: "https://pub.dev" source: hosted - version: "1.8.0+1" + version: "1.9.0" pub_semver: dependency: transitive description: name: pub_semver - url: "https://pub.dartlang.org" + sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c" + url: "https://pub.dev" source: hosted - version: "1.4.2" + version: "2.1.4" source_span: dependency: transitive description: name: source_span - url: "https://pub.dartlang.org" + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" source: hosted - version: "1.5.5" + version: "1.10.0" string_scanner: dependency: transitive description: name: string_scanner - url: "https://pub.dartlang.org" + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" source: hosted - version: "1.0.5" + version: "1.2.0" term_glyph: dependency: transitive description: name: term_glyph - url: "https://pub.dartlang.org" + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" source: hosted - version: "1.1.0" + version: "1.2.1" typed_data: dependency: transitive description: name: typed_data - url: "https://pub.dartlang.org" + sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c + url: "https://pub.dev" source: hosted - version: "1.1.6" + version: "1.3.2" watcher: dependency: transitive description: name: watcher - url: "https://pub.dartlang.org" + sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8" + url: "https://pub.dev" source: hosted - version: "0.9.7+12" + version: "1.1.0" yaml: dependency: transitive description: name: yaml - url: "https://pub.dartlang.org" + sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5" + url: "https://pub.dev" source: hosted - version: "2.2.0" + version: "3.1.2" sdks: - dart: ">=2.6.0 <3.0.0" + dart: ">=3.0.0 <4.0.0" diff --git a/bin/utils/dart-keywords/pubspec.yaml b/bin/utils/dart-keywords/pubspec.yaml index addb99241682..51e99b0ee945 100644 --- a/bin/utils/dart-keywords/pubspec.yaml +++ b/bin/utils/dart-keywords/pubspec.yaml @@ -4,7 +4,7 @@ description: Use the Dart SDK to generate Dart keywords. version: 1.0.0+1 environment: - sdk: ">=2.6.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dependencies: analyzer: diff --git a/bin/utils/dart-keywords/save-dart-keywords.dart b/bin/utils/dart-keywords/save-dart-keywords.dart index 4ad6908a3d59..c48de13d3762 100644 --- a/bin/utils/dart-keywords/save-dart-keywords.dart +++ b/bin/utils/dart-keywords/save-dart-keywords.dart @@ -4,13 +4,8 @@ import 'package:analyzer/dart/ast/token.dart'; main() { // save keywords to a text file - final txtFile = File( + final output = File( '../../../modules/openapi-generator/src/main/resources/dart/dart-keywords.txt'); - String txtString = ''; - for (String keyword in Keyword.keywords.keys.toList()) { - txtString += keyword + '\n'; - } - txtString = - txtString.substring(0, txtString.length - 1); // remove last newline - txtFile.writeAsStringSync(txtString); + final keywords = Keyword.keywords.keys.join('\n'); + output.writeAsStringSync(keywords); } diff --git a/bin/utils/dart-keywords/save_dart_keywords.sh b/bin/utils/dart-keywords/save_dart_keywords.sh index 4211200c8e58..5cb1e40173f6 100755 --- a/bin/utils/dart-keywords/save_dart_keywords.sh +++ b/bin/utils/dart-keywords/save_dart_keywords.sh @@ -1,3 +1,2 @@ -dart2native save-dart-keywords.dart -./save-dart-keywords.exe -dart --version &> dart-version.txt \ No newline at end of file +dart run save-dart-keywords.dart +dart --version &> dart-version.txt diff --git a/docs/generators/dart-dio.md b/docs/generators/dart-dio.md index 644631f62720..a8d6607f1dc8 100644 --- a/docs/generators/dart-dio.md +++ b/docs/generators/dart-dio.md @@ -70,7 +70,9 @@ These options may be applied as additional-properties (cli) or configOptions (pl
  • as
  • assert
  • async
  • +
  • augment
  • await
  • +
  • base
  • break
  • case
  • catch
  • @@ -118,6 +120,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
  • required
  • rethrow
  • return
  • +
  • sealed
  • set
  • show
  • source
  • @@ -132,6 +135,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
  • typedef
  • var
  • void
  • +
  • when
  • while
  • with
  • yield
  • diff --git a/docs/generators/dart.md b/docs/generators/dart.md index 45972f5e65bc..79148a7e4791 100644 --- a/docs/generators/dart.md +++ b/docs/generators/dart.md @@ -11,7 +11,7 @@ title: Documentation for the dart Generator | generator type | CLIENT | | | generator language | Dart | | | generator default templating engine | mustache | | -| helpTxt | Generates a Dart 2.x client library. | | +| helpTxt | Generates a Dart client library. | | ## CONFIG OPTIONS These options may be applied as additional-properties (cli) or configOptions (plugins). Refer to [configuration docs](https://openapi-generator.tech/docs/configuration) for more details. @@ -68,7 +68,9 @@ These options may be applied as additional-properties (cli) or configOptions (pl
  • as
  • assert
  • async
  • +
  • augment
  • await
  • +
  • base
  • break
  • case
  • catch
  • @@ -116,6 +118,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
  • required
  • rethrow
  • return
  • +
  • sealed
  • set
  • show
  • source
  • @@ -130,6 +133,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
  • typedef
  • var
  • void
  • +
  • when
  • while
  • with
  • yield
  • diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java index 5bf7fd5df307..e47530d853c1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractDartCodegen.java @@ -212,7 +212,7 @@ public String getName() { @Override public String getHelp() { - return "Generates a Dart 2.x client library."; + return "Generates a Dart client library."; } @Override diff --git a/modules/openapi-generator/src/main/resources/dart/dart-keywords.txt b/modules/openapi-generator/src/main/resources/dart/dart-keywords.txt index 5e51f8cceff6..8fe6b534ab70 100644 --- a/modules/openapi-generator/src/main/resources/dart/dart-keywords.txt +++ b/modules/openapi-generator/src/main/resources/dart/dart-keywords.txt @@ -2,7 +2,9 @@ abstract as assert async +augment await +base break case catch @@ -50,6 +52,7 @@ patch required rethrow return +sealed set show source @@ -64,6 +67,7 @@ try typedef var void +when while with yield \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/pubspec.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/pubspec.mustache index 03255f3eee86..f49fdceaf7f2 100644 --- a/modules/openapi-generator/src/main/resources/dart/libraries/dio/pubspec.mustache +++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/pubspec.mustache @@ -10,7 +10,7 @@ publish_to: {{.}} {{/pubPublishTo}} environment: - sdk: '>={{#useJsonSerializable}}2.17.0{{/useJsonSerializable}}{{^useJsonSerializable}}2.15.0{{/useJsonSerializable}} <3.0.0' + sdk: '>={{#useJsonSerializable}}2.17.0{{/useJsonSerializable}}{{^useJsonSerializable}}2.15.0{{/useJsonSerializable}} <4.0.0' dependencies: dio: '^5.2.0' diff --git a/modules/openapi-generator/src/main/resources/dart2/pubspec.mustache b/modules/openapi-generator/src/main/resources/dart2/pubspec.mustache index af522867b034..eeeb79b59296 100644 --- a/modules/openapi-generator/src/main/resources/dart2/pubspec.mustache +++ b/modules/openapi-generator/src/main/resources/dart2/pubspec.mustache @@ -13,7 +13,7 @@ repository: {{.}} publish_to: {{.}} {{/pubPublishTo}} environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.12.0 <4.0.0' dependencies: collection: '^1.17.0' http: '>=0.13.0 <0.14.0' diff --git a/samples/openapi3/client/petstore/dart-dio/oneof/pubspec.yaml b/samples/openapi3/client/petstore/dart-dio/oneof/pubspec.yaml index de93663746d0..efc0d4ccd702 100644 --- a/samples/openapi3/client/petstore/dart-dio/oneof/pubspec.yaml +++ b/samples/openapi3/client/petstore/dart-dio/oneof/pubspec.yaml @@ -4,7 +4,7 @@ description: OpenAPI API client homepage: homepage environment: - sdk: '>=2.15.0 <3.0.0' + sdk: '>=2.15.0 <4.0.0' dependencies: dio: '^5.2.0' diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/pubspec.yaml b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/pubspec.yaml index de93663746d0..efc0d4ccd702 100644 --- a/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/pubspec.yaml +++ b/samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/pubspec.yaml @@ -4,7 +4,7 @@ description: OpenAPI API client homepage: homepage environment: - sdk: '>=2.15.0 <3.0.0' + sdk: '>=2.15.0 <4.0.0' dependencies: dio: '^5.2.0' diff --git a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/pubspec.yaml b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/pubspec.yaml index de93663746d0..efc0d4ccd702 100644 --- a/samples/openapi3/client/petstore/dart-dio/oneof_primitive/pubspec.yaml +++ b/samples/openapi3/client/petstore/dart-dio/oneof_primitive/pubspec.yaml @@ -4,7 +4,7 @@ description: OpenAPI API client homepage: homepage environment: - sdk: '>=2.15.0 <3.0.0' + sdk: '>=2.15.0 <4.0.0' dependencies: dio: '^5.2.0' diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/pubspec.yaml b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/pubspec.yaml index dc16507435f0..8a32778ad38a 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/pubspec.yaml +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/pubspec.yaml @@ -4,7 +4,7 @@ description: OpenAPI API client homepage: homepage environment: - sdk: '>=2.17.0 <3.0.0' + sdk: '>=2.17.0 <4.0.0' dependencies: dio: '^5.2.0' diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/pubspec.yaml b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/pubspec.yaml index de93663746d0..efc0d4ccd702 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/pubspec.yaml +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake/pubspec.yaml @@ -4,7 +4,7 @@ description: OpenAPI API client homepage: homepage environment: - sdk: '>=2.15.0 <3.0.0' + sdk: '>=2.15.0 <4.0.0' dependencies: dio: '^5.2.0' diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake_tests/pubspec.yaml b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake_tests/pubspec.yaml index 8475e362b888..5b4ebb1c5c09 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake_tests/pubspec.yaml +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake_tests/pubspec.yaml @@ -5,7 +5,7 @@ description: OpenAPI API Dart DIO client tests for petstore_client_lib_fake publish_to: none environment: - sdk: '>=2.15.0 <3.0.0' + sdk: '>=2.15.0 <4.0.0' dev_dependencies: built_collection: 5.1.1 diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/pubspec.yaml b/samples/openapi3/client/petstore/dart2/petstore_client_lib/pubspec.yaml index f03302843292..72a2cdd8d138 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/pubspec.yaml +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/pubspec.yaml @@ -7,7 +7,7 @@ version: '1.0.0' description: 'OpenAPI API client' homepage: 'homepage' environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.12.0 <4.0.0' dependencies: collection: '^1.17.0' http: '>=0.13.0 <0.14.0' diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/pubspec.yaml b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/pubspec.yaml index f03302843292..72a2cdd8d138 100644 --- a/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/pubspec.yaml +++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/pubspec.yaml @@ -7,7 +7,7 @@ version: '1.0.0' description: 'OpenAPI API client' homepage: 'homepage' environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.12.0 <4.0.0' dependencies: collection: '^1.17.0' http: '>=0.13.0 <0.14.0'