@@ -12,8 +12,12 @@ import 'json_key.dart';
12
12
13
13
part 'json_serializable.g.dart' ;
14
14
15
+ // TODO: Remove typedef
16
+ @Deprecated ('Use RenameType instead' )
17
+ typedef FieldRename = RenameType ;
18
+
15
19
/// Values for the automatic field renaming behavior for [JsonSerializable] .
16
- enum FieldRename {
20
+ enum RenameType {
17
21
/// Use the field name without changes.
18
22
none,
19
23
@@ -31,31 +35,11 @@ enum FieldRename {
31
35
screamingSnake,
32
36
}
33
37
34
- /// Values for the automatic class renaming behavior for [JsonSerializable]
35
- /// with sealed classes.
36
- enum UnionRename {
37
- /// Use the union class name without changes.
38
- none,
39
-
40
- /// Encodes union class named `KebabCase` with a JSON key `kebab-case` .
41
- kebab,
42
-
43
- /// Encodes union class named `SnakeCase` with a JSON key `snake_case` .
44
- snake,
45
-
46
- /// Encodes union class named `PascalCase` with a JSON key `PascalCase` .
47
- pascal,
48
-
49
- /// Encodes union class named `ScreamingSnakeCase` with a JSON key
50
- /// `SCREAMING_SNAKE_CASE`
51
- screamingSnake,
52
- }
53
-
54
38
/// An annotation used to specify a class to generate code for.
55
39
@JsonSerializable (
56
40
checked: true ,
57
41
disallowUnrecognizedKeys: true ,
58
- fieldRename: FieldRename .snake,
42
+ fieldRename: RenameType .snake,
59
43
)
60
44
@Target ({TargetKind .classType})
61
45
class JsonSerializable {
@@ -173,14 +157,14 @@ class JsonSerializable {
173
157
/// Defines the automatic naming strategy when converting class field names
174
158
/// into JSON map keys.
175
159
///
176
- /// With a value [FieldRename .none] (the default), the name of the field is
160
+ /// With a value [RenameType .none] (the default), the name of the field is
177
161
/// used without modification.
178
162
///
179
- /// See [FieldRename ] for details on the other options.
163
+ /// See [RenameType ] for details on the other options.
180
164
///
181
165
/// Note: the value for [JsonKey.name] takes precedence over this option for
182
166
/// fields annotated with [JsonKey] .
183
- final FieldRename ? fieldRename;
167
+ final RenameType ? fieldRename;
184
168
185
169
/// When `true` on classes with type parameters (generic types), extra
186
170
/// "helper" parameters will be generated for `fromJson` and/or `toJson` to
@@ -252,11 +236,11 @@ class JsonSerializable {
252
236
/// Defines the automatic naming strategy when converting class names
253
237
/// to union type names.
254
238
///
255
- /// With a value [UnionRename .none] (the default), the name of the class is
239
+ /// With a value [RenameType .none] (the default), the name of the class is
256
240
/// used without modification.
257
241
///
258
- /// See [UnionRename ] for details on the other options.
259
- final UnionRename ? unionRename;
242
+ /// See [RenameType ] for details on the other options.
243
+ final RenameType ? unionRename;
260
244
261
245
/// A list of [JsonConverter] to apply to this class.
262
246
///
@@ -328,12 +312,12 @@ class JsonSerializable {
328
312
createToJson: true ,
329
313
disallowUnrecognizedKeys: false ,
330
314
explicitToJson: false ,
331
- fieldRename: FieldRename .none,
315
+ fieldRename: RenameType .none,
332
316
ignoreUnannotated: false ,
333
317
includeIfNull: true ,
334
318
genericArgumentFactories: false ,
335
319
unionDiscriminator: 'type' ,
336
- unionRename: UnionRename .none,
320
+ unionRename: RenameType .none,
337
321
);
338
322
339
323
/// Returns a new [JsonSerializable] instance with fields equal to the
0 commit comments