Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Commit d75b7b6

Browse files
authored
[Dart] Remove toString() call in enum TypeTransformers (#13452)
* Updated samples * [Dart] Removed 'toString' check on enum TypeTransformers (#12167)
1 parent 4a28451 commit d75b7b6

File tree

15 files changed

+19
-19
lines changed

15 files changed

+19
-19
lines changed

modules/openapi-generator/src/main/resources/dart2/serialization/native/native_enum.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class {{{classname}}}TypeTransformer {
6161
/// and users are still using an old app with the old code.
6262
{{{classname}}}? decode(dynamic data, {bool allowNull = true}) {
6363
if (data != null) {
64-
switch (data.toString()) {
64+
switch (data) {
6565
{{#allowableValues}}
6666
{{#enumVars}}
6767
case {{#isString}}r{{/isString}}{{{value}}}: return {{{classname}}}.{{{name}}};

modules/openapi-generator/src/main/resources/dart2/serialization/native/native_enum_inline.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class {{{enumName}}}TypeTransformer {
6161
/// and users are still using an old app with the old code.
6262
{{{enumName}}}? decode(dynamic data, {bool allowNull = true}) {
6363
if (data != null) {
64-
switch (data.toString()) {
64+
switch (data) {
6565
{{#allowableValues}}
6666
{{#enumVars}}
6767
case {{#isString}}r{{/isString}}{{{value}}}: return {{{enumName}}}.{{{name}}};

samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/order.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class OrderStatusEnumTypeTransformer {
247247
/// and users are still using an old app with the old code.
248248
OrderStatusEnum? decode(dynamic data, {bool allowNull = true}) {
249249
if (data != null) {
250-
switch (data.toString()) {
250+
switch (data) {
251251
case r'placed': return OrderStatusEnum.placed;
252252
case r'approved': return OrderStatusEnum.approved;
253253
case r'delivered': return OrderStatusEnum.delivered;

samples/openapi3/client/petstore/dart2/petstore_client_lib/lib/model/pet.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ class PetStatusEnumTypeTransformer {
231231
/// and users are still using an old app with the old code.
232232
PetStatusEnum? decode(dynamic data, {bool allowNull = true}) {
233233
if (data != null) {
234-
switch (data.toString()) {
234+
switch (data) {
235235
case r'available': return PetStatusEnum.available;
236236
case r'pending': return PetStatusEnum.pending;
237237
case r'sold': return PetStatusEnum.sold;

samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_arrays.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class EnumArraysJustSymbolEnumTypeTransformer {
176176
/// and users are still using an old app with the old code.
177177
EnumArraysJustSymbolEnum? decode(dynamic data, {bool allowNull = true}) {
178178
if (data != null) {
179-
switch (data.toString()) {
179+
switch (data) {
180180
case r'>=': return EnumArraysJustSymbolEnum.greaterThanEqual;
181181
case r'$': return EnumArraysJustSymbolEnum.dollar;
182182
default:
@@ -250,7 +250,7 @@ class EnumArraysArrayEnumEnumTypeTransformer {
250250
/// and users are still using an old app with the old code.
251251
EnumArraysArrayEnumEnum? decode(dynamic data, {bool allowNull = true}) {
252252
if (data != null) {
253-
switch (data.toString()) {
253+
switch (data) {
254254
case r'fish': return EnumArraysArrayEnumEnum.fish;
255255
case r'crab': return EnumArraysArrayEnumEnum.crab;
256256
default:

samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_class.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class EnumClassTypeTransformer {
6969
/// and users are still using an old app with the old code.
7070
EnumClass? decode(dynamic data, {bool allowNull = true}) {
7171
if (data != null) {
72-
switch (data.toString()) {
72+
switch (data) {
7373
case r'_abc': return EnumClass.abc;
7474
case r'-efg': return EnumClass.efg;
7575
case r'(xyz)': return EnumClass.leftParenthesisXyzRightParenthesis;

samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/enum_test.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ class EnumTestEnumStringEnumTypeTransformer {
263263
/// and users are still using an old app with the old code.
264264
EnumTestEnumStringEnum? decode(dynamic data, {bool allowNull = true}) {
265265
if (data != null) {
266-
switch (data.toString()) {
266+
switch (data) {
267267
case r'UPPER': return EnumTestEnumStringEnum.UPPER;
268268
case r'lower': return EnumTestEnumStringEnum.lower;
269269
case r'': return EnumTestEnumStringEnum.empty;
@@ -340,7 +340,7 @@ class EnumTestEnumStringRequiredEnumTypeTransformer {
340340
/// and users are still using an old app with the old code.
341341
EnumTestEnumStringRequiredEnum? decode(dynamic data, {bool allowNull = true}) {
342342
if (data != null) {
343-
switch (data.toString()) {
343+
switch (data) {
344344
case r'UPPER': return EnumTestEnumStringRequiredEnum.UPPER;
345345
case r'lower': return EnumTestEnumStringRequiredEnum.lower;
346346
case r'': return EnumTestEnumStringRequiredEnum.empty;
@@ -415,7 +415,7 @@ class EnumTestEnumIntegerEnumTypeTransformer {
415415
/// and users are still using an old app with the old code.
416416
EnumTestEnumIntegerEnum? decode(dynamic data, {bool allowNull = true}) {
417417
if (data != null) {
418-
switch (data.toString()) {
418+
switch (data) {
419419
case 1: return EnumTestEnumIntegerEnum.number1;
420420
case -1: return EnumTestEnumIntegerEnum.numberNegative1;
421421
default:
@@ -489,7 +489,7 @@ class EnumTestEnumNumberEnumTypeTransformer {
489489
/// and users are still using an old app with the old code.
490490
EnumTestEnumNumberEnum? decode(dynamic data, {bool allowNull = true}) {
491491
if (data != null) {
492-
switch (data.toString()) {
492+
switch (data) {
493493
case '1.1': return EnumTestEnumNumberEnum.number1Period1;
494494
case '-1.2': return EnumTestEnumNumberEnum.numberNegative1Period2;
495495
default:

samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/map_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class MapTestMapOfEnumStringEnumTypeTransformer {
186186
/// and users are still using an old app with the old code.
187187
MapTestMapOfEnumStringEnum? decode(dynamic data, {bool allowNull = true}) {
188188
if (data != null) {
189-
switch (data.toString()) {
189+
switch (data) {
190190
case r'UPPER': return MapTestMapOfEnumStringEnum.UPPER;
191191
case r'lower': return MapTestMapOfEnumStringEnum.lower;
192192
default:

samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/order.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class OrderStatusEnumTypeTransformer {
247247
/// and users are still using an old app with the old code.
248248
OrderStatusEnum? decode(dynamic data, {bool allowNull = true}) {
249249
if (data != null) {
250-
switch (data.toString()) {
250+
switch (data) {
251251
case r'placed': return OrderStatusEnum.placed;
252252
case r'approved': return OrderStatusEnum.approved;
253253
case r'delivered': return OrderStatusEnum.delivered;

samples/openapi3/client/petstore/dart2/petstore_client_lib_fake/lib/model/outer_enum.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class OuterEnumTypeTransformer {
6969
/// and users are still using an old app with the old code.
7070
OuterEnum? decode(dynamic data, {bool allowNull = true}) {
7171
if (data != null) {
72-
switch (data.toString()) {
72+
switch (data) {
7373
case r'placed': return OuterEnum.placed;
7474
case r'approved': return OuterEnum.approved;
7575
case r'delivered': return OuterEnum.delivered;

0 commit comments

Comments
 (0)