Skip to content

Commit

Permalink
Bumped up Dart min version to 3.0.0 for json_serializable, because js…
Browse files Browse the repository at this point in the history
…on_serializable requires Dart 3.5 since 6.9.0
  • Loading branch information
al-kimmel-serj committed Jan 20, 2025
1 parent 4c73faf commit 3b34060
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 9 deletions.
1 change: 1 addition & 0 deletions docs/generators/dart-dio.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|sortModelPropertiesByRequiredFlag|Sort model properties to place required parameters before optional parameters.| |true|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|sourceFolder|source folder for generated code| |src|
|supportDart2|Use dependencies compatible with Dart 2.| |false|
|useEnumExtension|Allow the 'x-enum-values' extension for enums| |false|

## IMPORT MAPPING
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public class DartDioClientCodegen extends AbstractDartCodegen {
public static final String FINAL_PROPERTIES = "finalProperties";
public static final String FINAL_PROPERTIES_DEFAULT_VALUE = "true";

public static final String SUPPORT_DART2 = "supportDart2";
public static final String SUPPORT_DART2_DEFAULT_VALUE = "false";

private static final String CLIENT_NAME = "clientName";

@Getter @Setter
Expand Down Expand Up @@ -138,6 +141,11 @@ public DartDioClientCodegen() {
final CliOption finalProperties = CliOption.newBoolean(FINAL_PROPERTIES, "Whether properties are marked as final when using Json Serializable for serialization");
finalProperties.setDefault("true");
cliOptions.add(finalProperties);

// Support Dart 2 Option
final CliOption supportDart2 = CliOption.newBoolean(SUPPORT_DART2, "Use dependencies compatible with Dart 2.");
supportDart2.setDefault("false");
cliOptions.add(supportDart2);
}

@Override
Expand Down Expand Up @@ -183,6 +191,14 @@ public void processOpts() {
additionalProperties.put(FINAL_PROPERTIES, Boolean.parseBoolean(additionalProperties.get(FINAL_PROPERTIES).toString()));
}

if (!additionalProperties.containsKey(SUPPORT_DART2)) {
additionalProperties.put(SUPPORT_DART2, Boolean.parseBoolean(SUPPORT_DART2_DEFAULT_VALUE));
LOGGER.debug("supportDart2 not set, using default {}", SUPPORT_DART2_DEFAULT_VALUE);
}
else {
additionalProperties.put(SUPPORT_DART2, Boolean.parseBoolean(additionalProperties.get(SUPPORT_DART2).toString()));
}

if (!additionalProperties.containsKey(CLIENT_NAME)) {
final String name = org.openapitools.codegen.utils.StringUtils.camelize(pubName);
additionalProperties.put(CLIENT_NAME, name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ For more information, please visit [{{{infoUrl}}}]({{{infoUrl}}})

## Requirements

{{#supportDart2}}
* Dart 2.15.0+ or Flutter 2.8.0+
{{/supportDart2}}
{{^supportDart2}}
* Dart 3.0.0+ or Flutter 2.8.0+
{{/supportDart2}}
* Dio 5.0.0+ (https://pub.dev/packages/dio)
{{#useJsonSerializable}}
* JSON Serializable 6.1.5+ (https://pub.dev/packages/json_serializable)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ publish_to: {{.}}
{{/pubPublishTo}}

environment:
sdk: '>={{#useJsonSerializable}}2.17.0{{/useJsonSerializable}}{{^useJsonSerializable}}2.15.0{{/useJsonSerializable}} <4.0.0'
sdk: '>={{#useJsonSerializable}}{{#supportDart2}}2.17.0{{/supportDart2}}{{^supportDart2}}3.0.0{{/supportDart2}}{{/useJsonSerializable}}{{^useJsonSerializable}}2.15.0{{/useJsonSerializable}} <4.0.0'
dependencies:
dio: '^5.2.0'
Expand All @@ -37,6 +37,11 @@ dev_dependencies:
{{/useBuiltValue}}
{{#useJsonSerializable}}
build_runner: any
json_serializable: '^6.1.5'
{{#supportDart2}}
json_serializable: '>=6.1.5 <6.9.0'
{{/supportDart2}}
{{^supportDart2}}
json_serializable: '^6.9.0'
{{/supportDart2}}
{{/useJsonSerializable}}
test: ^1.16.0
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public Map<String, String> createOptions() {
.put(CodegenConstants.SERIALIZATION_LIBRARY, DartDioClientCodegen.SERIALIZATION_LIBRARY_DEFAULT)
.put(DartDioClientCodegen.DATE_LIBRARY, DartDioClientCodegen.DATE_LIBRARY_DEFAULT)
.put(DartDioClientCodegen.FINAL_PROPERTIES, DartDioClientCodegen.FINAL_PROPERTIES_DEFAULT_VALUE)
.put(DartDioClientCodegen.SUPPORT_DART2, DartDioClientCodegen.SUPPORT_DART2_DEFAULT_VALUE)
.put(DartDioClientCodegen.EQUALITY_CHECK_METHOD, DartDioClientCodegen.EQUALITY_CHECK_METHOD_DEFAULT)
.put(CodegenConstants.SOURCE_FOLDER, SOURCE_FOLDER_VALUE)
.put(DartDioClientCodegen.USE_ENUM_EXTENSION, USE_ENUM_EXTENSION)
Expand Down
2 changes: 1 addition & 1 deletion samples/openapi3/client/petstore/dart-dio/oneof/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This Dart package is automatically generated by the [OpenAPI Generator](https://

## Requirements

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

## Installation & Usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ This Dart package is automatically generated by the [OpenAPI Generator](https://

## Requirements

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

## Installation & Usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This Dart package is automatically generated by the [OpenAPI Generator](https://

## Requirements

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

## Installation & Usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This Dart package is automatically generated by the [OpenAPI Generator](https://

## Requirements

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ description: OpenAPI API client
homepage: homepage

environment:
sdk: '>=2.17.0 <4.0.0'
sdk: '>=3.0.0 <4.0.0'

dependencies:
dio: '^5.2.0'
json_annotation: '^4.4.0'

dev_dependencies:
build_runner: any
json_serializable: '^6.1.5'
json_serializable: '^6.9.0'
test: ^1.16.0
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This Dart package is automatically generated by the [OpenAPI Generator](https://

## Requirements

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

## Installation & Usage
Expand Down

0 comments on commit 3b34060

Please sign in to comment.