Skip to content

Commit 517bbeb

Browse files
authored
Feat: #21665 [dart][dart-dio] CopyWith for json_serializable (#21667)
* Add `@CopyWith()` annotation to model class mustache * Add copyWith deps to pubspec mustache template * generate examples * add import for copyWith
1 parent 5db1e75 commit 517bbeb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+98
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ dependencies:
2525
equatable: '^2.0.7'
2626
{{/useEquatable}}
2727
{{#useJsonSerializable}}
28+
copy_with_extension: '^7.1.0'
2829
json_annotation: '^4.9.0'
2930
{{/useJsonSerializable}}
3031
{{#useDateLibTimeMachine}}
@@ -38,6 +39,7 @@ dev_dependencies:
3839
{{/useBuiltValue}}
3940
{{#useJsonSerializable}}
4041
build_runner: any
42+
copy_with_extension_gen: ^7.1.0
4143
json_serializable: '^6.9.3'
4244
{{/useJsonSerializable}}
4345
test: '^1.16.0'

modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/json_serializable/class.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import 'package:copy_with_extension/copy_with_extension.dart';
12
import 'package:json_annotation/json_annotation.dart';
23
{{#useEquatable}}
34
import 'package:equatable/src/equatable_utils.dart';
@@ -17,6 +18,7 @@ part '{{classFilename}}.g.dart';
1718
{{#isDeprecated}}
1819
@Deprecated('{{{classname}}} has been deprecated')
1920
{{/isDeprecated}}
21+
@CopyWith()
2022
@JsonSerializable(
2123
checked: true,
2224
createToJson: true,

samples/openapi3/client/petstore/dart-dio/binary_response/pubspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ environment:
99

1010
dependencies:
1111
dio: '^5.7.0'
12+
copy_with_extension: '^7.1.0'
1213
json_annotation: '^4.9.0'
1314

1415
dev_dependencies:
1516
build_runner: any
17+
copy_with_extension_gen: ^7.1.0
1618
json_serializable: '^6.9.3'
1719
test: '^1.16.0'

samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/additional_properties_class.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
//
44

55
// ignore_for_file: unused_element
6+
import 'package:copy_with_extension/copy_with_extension.dart';
67
import 'package:json_annotation/json_annotation.dart';
78

89
part 'additional_properties_class.g.dart';
910

1011

12+
@CopyWith()
1113
@JsonSerializable(
1214
checked: true,
1315
createToJson: true,

samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/all_of_with_single_ref.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
// ignore_for_file: unused_element
66
import 'package:openapi/src/model/single_ref_type.dart';
7+
import 'package:copy_with_extension/copy_with_extension.dart';
78
import 'package:json_annotation/json_annotation.dart';
89

910
part 'all_of_with_single_ref.g.dart';
1011

1112

13+
@CopyWith()
1214
@JsonSerializable(
1315
checked: true,
1416
createToJson: true,

samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/animal.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
//
44

55
// ignore_for_file: unused_element
6+
import 'package:copy_with_extension/copy_with_extension.dart';
67
import 'package:json_annotation/json_annotation.dart';
78

89
part 'animal.g.dart';
910

1011

12+
@CopyWith()
1113
@JsonSerializable(
1214
checked: true,
1315
createToJson: true,

samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/api_response.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
//
44

55
// ignore_for_file: unused_element
6+
import 'package:copy_with_extension/copy_with_extension.dart';
67
import 'package:json_annotation/json_annotation.dart';
78

89
part 'api_response.g.dart';
910

1011

12+
@CopyWith()
1113
@JsonSerializable(
1214
checked: true,
1315
createToJson: true,

samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/array_of_array_of_number_only.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
//
44

55
// ignore_for_file: unused_element
6+
import 'package:copy_with_extension/copy_with_extension.dart';
67
import 'package:json_annotation/json_annotation.dart';
78

89
part 'array_of_array_of_number_only.g.dart';
910

1011

12+
@CopyWith()
1113
@JsonSerializable(
1214
checked: true,
1315
createToJson: true,

samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/array_of_number_only.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
//
44

55
// ignore_for_file: unused_element
6+
import 'package:copy_with_extension/copy_with_extension.dart';
67
import 'package:json_annotation/json_annotation.dart';
78

89
part 'array_of_number_only.g.dart';
910

1011

12+
@CopyWith()
1113
@JsonSerializable(
1214
checked: true,
1315
createToJson: true,

samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/array_test.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
// ignore_for_file: unused_element
66
import 'package:openapi/src/model/read_only_first.dart';
7+
import 'package:copy_with_extension/copy_with_extension.dart';
78
import 'package:json_annotation/json_annotation.dart';
89

910
part 'array_test.g.dart';
1011

1112

13+
@CopyWith()
1214
@JsonSerializable(
1315
checked: true,
1416
createToJson: true,

0 commit comments

Comments
 (0)