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

Al kimmel serj bump up dart version #20625

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = "true";

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("true");
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ dependencies:

dev_dependencies:
build_runner: any
json_serializable: '^6.1.5'
json_serializable: '>=6.1.5 <6.9.0'
test: ^1.16.0
Loading