Skip to content

Commit cc0ca5a

Browse files
committed
Merge branch 'bump-up-dart-version' of https://github.com/al-kimmel-serj/openapi-generator into al-kimmel-serj-bump-up-dart-version
2 parents c2c161e + 3b34060 commit cc0ca5a

File tree

11 files changed

+37
-9
lines changed

11 files changed

+37
-9
lines changed

docs/generators/dart-dio.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
4040
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
4141
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
4242
|sourceFolder|source folder for generated code| |src|
43+
|supportDart2|Use dependencies compatible with Dart 2.| |false|
4344
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |false|
4445

4546
## IMPORT MAPPING

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
7171
public static final String FINAL_PROPERTIES = "finalProperties";
7272
public static final String FINAL_PROPERTIES_DEFAULT_VALUE = "true";
7373

74+
public static final String SUPPORT_DART2 = "supportDart2";
75+
public static final String SUPPORT_DART2_DEFAULT_VALUE = "false";
76+
7477
private static final String CLIENT_NAME = "clientName";
7578

7679
@Getter @Setter
@@ -138,6 +141,11 @@ public DartDioClientCodegen() {
138141
final CliOption finalProperties = CliOption.newBoolean(FINAL_PROPERTIES, "Whether properties are marked as final when using Json Serializable for serialization");
139142
finalProperties.setDefault("true");
140143
cliOptions.add(finalProperties);
144+
145+
// Support Dart 2 Option
146+
final CliOption supportDart2 = CliOption.newBoolean(SUPPORT_DART2, "Use dependencies compatible with Dart 2.");
147+
supportDart2.setDefault("false");
148+
cliOptions.add(supportDart2);
141149
}
142150

143151
@Override
@@ -183,6 +191,14 @@ public void processOpts() {
183191
additionalProperties.put(FINAL_PROPERTIES, Boolean.parseBoolean(additionalProperties.get(FINAL_PROPERTIES).toString()));
184192
}
185193

194+
if (!additionalProperties.containsKey(SUPPORT_DART2)) {
195+
additionalProperties.put(SUPPORT_DART2, Boolean.parseBoolean(SUPPORT_DART2_DEFAULT_VALUE));
196+
LOGGER.debug("supportDart2 not set, using default {}", SUPPORT_DART2_DEFAULT_VALUE);
197+
}
198+
else {
199+
additionalProperties.put(SUPPORT_DART2, Boolean.parseBoolean(additionalProperties.get(SUPPORT_DART2).toString()));
200+
}
201+
186202
if (!additionalProperties.containsKey(CLIENT_NAME)) {
187203
final String name = org.openapitools.codegen.utils.StringUtils.camelize(pubName);
188204
additionalProperties.put(CLIENT_NAME, name);

modules/openapi-generator/src/main/resources/dart/libraries/dio/README.mustache

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})
2020

2121
## Requirements
2222

23+
{{#supportDart2}}
2324
* Dart 2.15.0+ or Flutter 2.8.0+
25+
{{/supportDart2}}
26+
{{^supportDart2}}
27+
* Dart 3.0.0+ or Flutter 2.8.0+
28+
{{/supportDart2}}
2429
* Dio 5.0.0+ (https://pub.dev/packages/dio)
2530
{{#useJsonSerializable}}
2631
* JSON Serializable 6.1.5+ (https://pub.dev/packages/json_serializable)

modules/openapi-generator/src/main/resources/dart/libraries/dio/pubspec.mustache

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ publish_to: {{.}}
1010
{{/pubPublishTo}}
1111

1212
environment:
13-
sdk: '>={{#useJsonSerializable}}2.17.0{{/useJsonSerializable}}{{^useJsonSerializable}}2.15.0{{/useJsonSerializable}} <4.0.0'
13+
sdk: '>={{#useJsonSerializable}}{{#supportDart2}}2.17.0{{/supportDart2}}{{^supportDart2}}3.0.0{{/supportDart2}}{{/useJsonSerializable}}{{^useJsonSerializable}}2.15.0{{/useJsonSerializable}} <4.0.0'
1414
1515
dependencies:
1616
dio: '^5.2.0'
@@ -37,6 +37,11 @@ dev_dependencies:
3737
{{/useBuiltValue}}
3838
{{#useJsonSerializable}}
3939
build_runner: any
40-
json_serializable: '^6.1.5'
40+
{{#supportDart2}}
41+
json_serializable: '>=6.1.5 <6.9.0'
42+
{{/supportDart2}}
43+
{{^supportDart2}}
44+
json_serializable: '^6.9.0'
45+
{{/supportDart2}}
4146
{{/useJsonSerializable}}
4247
test: ^1.16.0

modules/openapi-generator/src/test/java/org/openapitools/codegen/options/DartDioClientOptionsProvider.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public Map<String, String> createOptions() {
6464
.put(CodegenConstants.SERIALIZATION_LIBRARY, DartDioClientCodegen.SERIALIZATION_LIBRARY_DEFAULT)
6565
.put(DartDioClientCodegen.DATE_LIBRARY, DartDioClientCodegen.DATE_LIBRARY_DEFAULT)
6666
.put(DartDioClientCodegen.FINAL_PROPERTIES, DartDioClientCodegen.FINAL_PROPERTIES_DEFAULT_VALUE)
67+
.put(DartDioClientCodegen.SUPPORT_DART2, DartDioClientCodegen.SUPPORT_DART2_DEFAULT_VALUE)
6768
.put(DartDioClientCodegen.EQUALITY_CHECK_METHOD, DartDioClientCodegen.EQUALITY_CHECK_METHOD_DEFAULT)
6869
.put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
6970
.put(DartDioClientCodegen.USE_ENUM_EXTENSION, USE_ENUM_EXTENSION)

samples/openapi3/client/petstore/dart-dio/oneof/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This Dart package is automatically generated by the [OpenAPI Generator](https://
99

1010
## Requirements
1111

12-
* Dart 2.15.0+ or Flutter 2.8.0+
12+
* Dart 3.0.0+ or Flutter 2.8.0+
1313
* Dio 5.0.0+ (https://pub.dev/packages/dio)
1414

1515
## Installation & Usage

samples/openapi3/client/petstore/dart-dio/oneof_polymorphism_and_inheritance/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This Dart package is automatically generated by the [OpenAPI Generator](https://
1010

1111
## Requirements
1212

13-
* Dart 2.15.0+ or Flutter 2.8.0+
13+
* Dart 3.0.0+ or Flutter 2.8.0+
1414
* Dio 5.0.0+ (https://pub.dev/packages/dio)
1515

1616
## Installation & Usage

samples/openapi3/client/petstore/dart-dio/oneof_primitive/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This Dart package is automatically generated by the [OpenAPI Generator](https://
99

1010
## Requirements
1111

12-
* Dart 2.15.0+ or Flutter 2.8.0+
12+
* Dart 3.0.0+ or Flutter 2.8.0+
1313
* Dio 5.0.0+ (https://pub.dev/packages/dio)
1414

1515
## Installation & Usage

samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ This Dart package is automatically generated by the [OpenAPI Generator](https://
99

1010
## Requirements
1111

12-
* Dart 2.15.0+ or Flutter 2.8.0+
12+
* Dart 3.0.0+ or Flutter 2.8.0+
1313
* Dio 5.0.0+ (https://pub.dev/packages/dio)
1414
* JSON Serializable 6.1.5+ (https://pub.dev/packages/json_serializable)
1515

samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ description: OpenAPI API client
44
homepage: homepage
55

66
environment:
7-
sdk: '>=2.17.0 <4.0.0'
7+
sdk: '>=3.0.0 <4.0.0'
88

99
dependencies:
1010
dio: '^5.2.0'
1111
json_annotation: '^4.4.0'
1212

1313
dev_dependencies:
1414
build_runner: any
15-
json_serializable: '^6.1.5'
15+
json_serializable: '^6.9.0'
1616
test: ^1.16.0

0 commit comments

Comments
 (0)