@@ -12,8 +12,12 @@ import 'json_key.dart';
1212
1313part 'json_serializable.g.dart' ;
1414
15+ // TODO: Remove typedef
16+ @Deprecated ('Use RenameType instead' )
17+ typedef FieldRename = RenameType ;
18+
1519/// Values for the automatic field renaming behavior for [JsonSerializable] .
16- enum FieldRename {
20+ enum RenameType {
1721 /// Use the field name without changes.
1822 none,
1923
@@ -31,31 +35,11 @@ enum FieldRename {
3135 screamingSnake,
3236}
3337
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-
5438/// An annotation used to specify a class to generate code for.
5539@JsonSerializable (
5640 checked: true ,
5741 disallowUnrecognizedKeys: true ,
58- fieldRename: FieldRename .snake,
42+ fieldRename: RenameType .snake,
5943)
6044@Target ({TargetKind .classType})
6145class JsonSerializable {
@@ -173,14 +157,14 @@ class JsonSerializable {
173157 /// Defines the automatic naming strategy when converting class field names
174158 /// into JSON map keys.
175159 ///
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
177161 /// used without modification.
178162 ///
179- /// See [FieldRename ] for details on the other options.
163+ /// See [RenameType ] for details on the other options.
180164 ///
181165 /// Note: the value for [JsonKey.name] takes precedence over this option for
182166 /// fields annotated with [JsonKey] .
183- final FieldRename ? fieldRename;
167+ final RenameType ? fieldRename;
184168
185169 /// When `true` on classes with type parameters (generic types), extra
186170 /// "helper" parameters will be generated for `fromJson` and/or `toJson` to
@@ -252,11 +236,11 @@ class JsonSerializable {
252236 /// Defines the automatic naming strategy when converting class names
253237 /// to union type names.
254238 ///
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
256240 /// used without modification.
257241 ///
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;
260244
261245 /// A list of [JsonConverter] to apply to this class.
262246 ///
@@ -328,12 +312,12 @@ class JsonSerializable {
328312 createToJson: true ,
329313 disallowUnrecognizedKeys: false ,
330314 explicitToJson: false ,
331- fieldRename: FieldRename .none,
315+ fieldRename: RenameType .none,
332316 ignoreUnannotated: false ,
333317 includeIfNull: true ,
334318 genericArgumentFactories: false ,
335319 unionDiscriminator: 'type' ,
336- unionRename: UnionRename .none,
320+ unionRename: RenameType .none,
337321 );
338322
339323 /// Returns a new [JsonSerializable] instance with fields equal to the
0 commit comments