diff --git a/bin/configs/dart-petstore-json-serializable-client-lib-fake.yaml b/bin/configs/dart-petstore-json-serializable-client-lib-fake.yaml
deleted file mode 100644
index 8582a881d51d..000000000000
--- a/bin/configs/dart-petstore-json-serializable-client-lib-fake.yaml
+++ /dev/null
@@ -1,10 +0,0 @@
-generatorName: dart
-outputDir: samples/openapi3/client/petstore/dart2/petstore_json_serializable_client_lib_fake
-inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml
-templateDir: modules/openapi-generator/src/main/resources/dart2
-typeMappings:
- Client: "ModelClient"
- File: "ModelFile"
-additionalProperties:
- hideGenerationTimestamp: "true"
- serializationLibrary: json_serializable
diff --git a/docs/generators/dart.md b/docs/generators/dart.md
index ef805b784512..cb783be68109 100644
--- a/docs/generators/dart.md
+++ b/docs/generators/dart.md
@@ -19,7 +19,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|pubLibrary|Library name in generated code| |null|
|pubName|Name in generated pubspec| |null|
|pubVersion|Version in generated pubspec| |null|
-|serializationLibrary|Specify serialization library|
- **native_serialization**
- Use native serializer, backwards compatible
- **json_serializable**
- Use json_serializable. Experimental and subject to breaking changes without further notice
|native_serialization|
+|serializationLibrary|Specify serialization library|- **native_serialization**
- Use native serializer, backwards compatible
|native_serialization|
|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| |null|
diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java
index b26f23891c0b..25853e0b2541 100644
--- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java
+++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartClientCodegen.java
@@ -33,7 +33,6 @@ public class DartClientCodegen extends AbstractDartCodegen {
private final Logger LOGGER = LoggerFactory.getLogger(DartClientCodegen.class);
public static final String SERIALIZATION_LIBRARY_NATIVE = "native_serialization";
- public static final String SERIALIZATION_LIBRARY_JSON_SERIALIZABLE = "json_serializable";
public DartClientCodegen() {
super();
@@ -43,7 +42,6 @@ public DartClientCodegen() {
final Map serializationOptions = new HashMap<>();
serializationOptions.put(SERIALIZATION_LIBRARY_NATIVE, "Use native serializer, backwards compatible");
- serializationOptions.put(SERIALIZATION_LIBRARY_JSON_SERIALIZABLE, "Use json_serializable. Experimental and subject to breaking changes without further notice");
serializationLibrary.setEnum(serializationOptions);
cliOptions.add(serializationLibrary);
}
@@ -88,15 +86,7 @@ private void setSerializationLibrary() {
LOGGER.info("Using serialization library {}", serialization_library);
switch (serialization_library) {
- case SERIALIZATION_LIBRARY_JSON_SERIALIZABLE:
- additionalProperties.put(SERIALIZATION_LIBRARY_JSON_SERIALIZABLE, "true");
- // json_serializable requires build.yaml
- supportingFiles.add(new SupportingFile("build.yaml.mustache",
- "" /* main project dir */,
- "build.yaml"));
- break;
-
- case SERIALIZATION_LIBRARY_NATIVE: // fall trough to default backwards compatible generator
+ case SERIALIZATION_LIBRARY_NATIVE: // fall through to default backwards compatible generator
default:
additionalProperties.put(SERIALIZATION_LIBRARY_NATIVE, "true");
diff --git a/modules/openapi-generator/src/main/resources/dart2/api.mustache b/modules/openapi-generator/src/main/resources/dart2/api.mustache
index c16db47c110b..32f3ee2d8c42 100644
--- a/modules/openapi-generator/src/main/resources/dart2/api.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/api.mustache
@@ -197,33 +197,7 @@ class {{{classname}}} {
{{/isMap}}
{{^isMap}}
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), '{{{returnType}}}',) as {{{returnType}}};
- {{/isMap}}{{/isArray}}{{/native_serialization}}{{#json_serializable}}
- {{#isArray}}
- {{#uniqueItems}}
- return (json.decode(response.body) as List)
- .map((i) => {{{returnBaseType}}}.fromJson(i))
- .toSet();
- {{/uniqueItems}}
- {{^uniqueItems}}
- return (json.decode(response.body) as List)
- .map((i) => {{{returnBaseType}}}.fromJson(i))
- .toList();
- {{/uniqueItems}}
- {{/isArray}}
- {{^isArray}}
- {{#isMap}}
- return {{{returnType}}}.from(json.decode(response.body));
- {{/isMap}}
- {{^isMap}}
- {{#returnTypeIsPrimitive}}
- return response.body as {{{returnBaseType}}};
- {{/returnTypeIsPrimitive}}
- {{^returnTypeIsPrimitive}}
- return {{{returnType}}}.fromJson(json.decode(response.body));
- {{/returnTypeIsPrimitive}}
- {{/isMap}}
- {{/isArray}}
- {{/json_serializable}}
+ {{/isMap}}{{/isArray}}{{/native_serialization}}
}
return Future<{{{returnType}}}>.value();
{{/returnType}}
diff --git a/modules/openapi-generator/src/main/resources/dart2/api_client.mustache b/modules/openapi-generator/src/main/resources/dart2/api_client.mustache
index 85be6bc9376b..7eb14870b7ca 100644
--- a/modules/openapi-generator/src/main/resources/dart2/api_client.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/api_client.mustache
@@ -208,7 +208,6 @@ class ApiClient {
case '{{{classname}}}':
{{#isEnum}}
{{#native_serialization}}return {{{classname}}}TypeTransformer().decode(value);{{/native_serialization}}
- {{#json_serializable}} return _$enumDecode(_${{{classname}}}EnumMap, value);{{/json_serializable}}
{{/isEnum}}
{{^isEnum}}
return {{{classname}}}.fromJson(value);
diff --git a/modules/openapi-generator/src/main/resources/dart2/api_helper.mustache b/modules/openapi-generator/src/main/resources/dart2/api_helper.mustache
index c64effcdda0f..6b2f4f2fdef8 100644
--- a/modules/openapi-generator/src/main/resources/dart2/api_helper.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/api_helper.mustache
@@ -54,7 +54,7 @@ String parameterToString(dynamic value) {
{{#model}}
{{#isEnum}}
if (value is {{{classname}}}) {
-{{#native_serialization}} return {{{classname}}}TypeTransformer().encode(value).toString();{{/native_serialization}}{{#json_serializable}} return value.toString();{{/json_serializable}}
+{{#native_serialization}} return {{{classname}}}TypeTransformer().encode(value).toString();{{/native_serialization}}
}
{{/isEnum}}
{{/model}}
diff --git a/modules/openapi-generator/src/main/resources/dart2/apilib.mustache b/modules/openapi-generator/src/main/resources/dart2/apilib.mustache
index e2233d95ec49..2fcebda4ea46 100644
--- a/modules/openapi-generator/src/main/resources/dart2/apilib.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/apilib.mustache
@@ -7,9 +7,6 @@ import 'dart:io';
import 'package:http/http.dart';
import 'package:intl/intl.dart';
-{{#json_serializable}}
-import 'package:json_annotation/json_annotation.dart';
-{{/json_serializable}}
import 'package:meta/meta.dart';
part 'api_client.dart';
@@ -26,9 +23,6 @@ part 'auth/http_bearer_auth.dart';
{{#models}}{{#model}}part 'model/{{{classFilename}}}.dart';
{{/model}}{{/models}}
-{{#json_serializable}}
-part 'api.g.dart';
-{{/json_serializable}}
const _delimiters = {'csv': ',', 'ssv': ' ', 'tsv': '\t', 'pipes': '|'};
const _dateEpochMarker = 'epoch';
final _dateFormatter = DateFormat('yyyy-MM-dd');
diff --git a/modules/openapi-generator/src/main/resources/dart2/build.yaml.mustache b/modules/openapi-generator/src/main/resources/dart2/build.yaml.mustache
deleted file mode 100644
index 89a4dd6e1c2e..000000000000
--- a/modules/openapi-generator/src/main/resources/dart2/build.yaml.mustache
+++ /dev/null
@@ -1,18 +0,0 @@
-targets:
- $default:
- builders:
- json_serializable:
- options:
- # Options configure how source code is generated for every
- # `@JsonSerializable`-annotated class in the package.
- #
- # The default value for each is listed.
- any_map: false
- checked: true
- create_factory: true
- create_to_json: true
- disallow_unrecognized_keys: true
- explicit_to_json: true
- field_rename: none
- ignore_unannotated: false
- include_if_null: false
diff --git a/modules/openapi-generator/src/main/resources/dart2/model.mustache b/modules/openapi-generator/src/main/resources/dart2/model.mustache
index 9c738da279bd..306c54e417e6 100644
--- a/modules/openapi-generator/src/main/resources/dart2/model.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/model.mustache
@@ -6,17 +6,11 @@
{{#native_serialization}}
{{>serialization/native/native_enum}}
{{/native_serialization}}
-{{#json_serializable}}
-{{>serialization/json_serializable/json_serializable_enum}}
-{{/json_serializable}}
{{/isEnum}}
{{^isEnum}}
{{#native_serialization}}
{{>serialization/native/native_class}}
{{/native_serialization}}
-{{#json_serializable}}
-{{>serialization/json_serializable/json_serializable_class}}
-{{/json_serializable}}
{{/isEnum}}
{{/model}}
{{/models}}
diff --git a/modules/openapi-generator/src/main/resources/dart2/pubspec.mustache b/modules/openapi-generator/src/main/resources/dart2/pubspec.mustache
index 4ce12df9e486..186986237424 100644
--- a/modules/openapi-generator/src/main/resources/dart2/pubspec.mustache
+++ b/modules/openapi-generator/src/main/resources/dart2/pubspec.mustache
@@ -12,10 +12,5 @@ dependencies:
http: '>=0.13.0 <0.14.0'
intl: '^0.17.0'
meta: '^1.1.8'
-{{#json_serializable}}
- json_annotation: '^3.1.1'{{/json_serializable}}
dev_dependencies:
test: '>=1.16.0 <1.18.0'
-{{#json_serializable}}
- build_runner: '^1.10.9'
- json_serializable: '^3.5.1'{{/json_serializable}}
diff --git a/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_class.mustache b/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_class.mustache
deleted file mode 100644
index ec97f23eb726..000000000000
--- a/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_class.mustache
+++ /dev/null
@@ -1,67 +0,0 @@
-@JsonSerializable(
- checked: true,
- createToJson: true,
- disallowUnrecognizedKeys: true,
- explicitToJson: true,
-)
-class {{{classname}}} {
-{{>dart_constructor}}
-
-{{#vars}}
- {{#description}}
- /// {{{.}}}
- {{/description}}
- {{^isEnum}}
- {{#minimum}}
- // minimum: {{{.}}}
- {{/minimum}}
- {{#maximum}}
- // maximum: {{{.}}}
- {{/maximum}}
- {{/isEnum}}
- {{^isBinary}}
- @JsonKey(
- {{#defaultValue}}defaultValue: {{{.}}},{{/defaultValue}}{{^defaultValue}}nullable: {{isNullable}},{{/defaultValue}}
- name: r'{{{baseName}}}',
- required: {{#required}}true{{/required}}{{^required}}false{{/required}},
- )
- {{/isBinary}}
- {{#isBinary}}
- @JsonKey(ignore: true)
- {{/isBinary}}
- {{{datatypeWithEnum}}} {{{name}}};
-
-{{/vars}}
- @override
- bool operator ==(Object other) => identical(this, other) || other is {{{classname}}} &&
- {{#vars}}
- other.{{{name}}} == {{{name}}}{{^-last}} &&{{/-last}}{{#-last}};{{/-last}}
- {{/vars}}
-
- @override
- int get hashCode =>
- {{#vars}}
- ({{{name}}} == null ? 0 : {{{name}}}.hashCode){{^-last}} +{{/-last}}{{#-last}};{{/-last}}
- {{/vars}}
-
- factory {{{classname}}}.fromJson(Map json) => _${{{classname}}}FromJson(json);
-
- Map toJson() => _${{{classname}}}ToJson(this);
-
- @override
- String toString() => toJson().toString();
-}
-{{#vars}}
- {{#isEnum}}
- {{^isContainer}}
-
-{{>serialization/json_serializable/json_serializable_enum_inline}}
- {{/isContainer}}
- {{#isContainer}}
- {{#mostInnerItems}}
-
-{{>serialization/json_serializable/json_serializable_enum_inline}}
- {{/mostInnerItems}}
- {{/isContainer}}
- {{/isEnum}}
-{{/vars}}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_enum.mustache b/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_enum.mustache
deleted file mode 100644
index 3fe458ab91f6..000000000000
--- a/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_enum.mustache
+++ /dev/null
@@ -1,7 +0,0 @@
-enum {{{classname}}} {
-{{#allowableValues}}
-{{#enumVars}}
- {{{name}}},
-{{/enumVars}}
-{{/allowableValues}}
-}
\ No newline at end of file
diff --git a/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_enum_inline.mustache b/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_enum_inline.mustache
deleted file mode 100644
index 6e9f9016750b..000000000000
--- a/modules/openapi-generator/src/main/resources/dart2/serialization/json_serializable/json_serializable_enum_inline.mustache
+++ /dev/null
@@ -1,8 +0,0 @@
-{{#description}}/// {{{.}}}{{/description}}
-enum {{{enumName}}} {
-{{#allowableValues}}
-{{#enumVars}}
- {{{name}}},
-{{/enumVars}}
-{{/allowableValues}}
-}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 540b8505cd7d..63e68566c634 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1413,7 +1413,6 @@
samples/openapi3/client/petstore/dart2/petstore_client_lib
samples/openapi3/client/petstore/dart2/petstore
-
samples/openapi3/client/petstore/dart-dio-next/petstore_client_lib_fake
samples/openapi3/client/petstore/dart-dio-next/dio_http_petstore_client_lib_fake
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart
index 2b7e10416d27..5b299b6b2cdb 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/pet_api.dart
@@ -72,7 +72,8 @@ class PetApi {
// FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet;
- }
+
+ }
return Future.value();
}
@@ -203,6 +204,7 @@ class PetApi {
return (await apiClient.deserializeAsync(responseBody, 'List') as List)
.cast()
.toList(growable: false);
+
}
return Future>.value();
}
@@ -272,6 +274,7 @@ class PetApi {
return (await apiClient.deserializeAsync(responseBody, 'List') as List)
.cast()
.toList(growable: false);
+
}
return Future>.value();
}
@@ -337,7 +340,8 @@ class PetApi {
// FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet;
- }
+
+ }
return Future.value();
}
@@ -397,7 +401,8 @@ class PetApi {
// FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Pet',) as Pet;
- }
+
+ }
return Future.value();
}
@@ -556,7 +561,8 @@ class PetApi {
// FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'ApiResponse',) as ApiResponse;
- }
+
+ }
return Future.value();
}
}
diff --git a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart
index 9a02b1f95106..0c5c49a95541 100644
--- a/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart
+++ b/samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/api/store_api.dart
@@ -119,6 +119,7 @@ class StoreApi {
// FormatException when trying to decode an empty string.
if (response.body != null && response.statusCode != HttpStatus.noContent) {
return Map.from(await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'Map'),);
+
}
return Future