Skip to content

Commit

Permalink
[BUGFIX][dart-dio] Align enum and enum_inline generation result (O…
Browse files Browse the repository at this point in the history
…penAPITools#19510)

* [BUGFIX][dart-dio] Align `enum` and `enum_inline` generation result

* review fixes

* Revert "review fixes"

This reverts commit 9d0b263.

---------

Co-authored-by: Vasiliy Ditsyak <[email protected]>
  • Loading branch information
vasilich6107 and vasilich6107 authored Sep 15, 2024
1 parent 740b971 commit abf9416
Show file tree
Hide file tree
Showing 8 changed files with 169 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,21 @@
enum {{{ enumName }}} {
{{#allowableValues}}
{{#enumVars}}
@JsonValue({{#isString}}r{{/isString}}{{{value}}})
{{{name}}},
{{^isNull}}
{{#description}}
/// {{{.}}}
{{/description}}
@JsonValue({{#isString}}r{{/isString}}{{{value}}})
{{{name}}}({{^isString}}'{{/isString}}{{#isString}}r{{/isString}}{{{value}}}{{^isString}}'{{/isString}}){{^-last}},{{/-last}}{{#-last}};{{/-last}}
{{/isNull}}
{{/enumVars}}
{{/allowableValues}}

const {{{enumName}}}(this.value);

final String value;

@override
String toString() => value;
}
{{/enumName}}
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,17 @@ class ChildWithNullable {


enum ChildWithNullableTypeEnum {
@JsonValue(r'ChildWithNullable')
childWithNullable,
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi,
@JsonValue(r'ChildWithNullable')
childWithNullable(r'ChildWithNullable'),
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi(r'unknown_default_open_api');

const ChildWithNullableTypeEnum(this.value);

final String value;

@override
String toString() => value;
}


Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,37 @@ class EnumArrays {


enum EnumArraysJustSymbolEnum {
@JsonValue(r'>=')
greaterThanEqual,
@JsonValue(r'$')
dollar,
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi,
@JsonValue(r'>=')
greaterThanEqual(r'>='),
@JsonValue(r'$')
dollar(r'$'),
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi(r'unknown_default_open_api');

const EnumArraysJustSymbolEnum(this.value);

final String value;

@override
String toString() => value;
}



enum EnumArraysArrayEnumEnum {
@JsonValue(r'fish')
fish,
@JsonValue(r'crab')
crab,
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi,
@JsonValue(r'fish')
fish(r'fish'),
@JsonValue(r'crab')
crab(r'crab'),
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi(r'unknown_default_open_api');

const EnumArraysArrayEnumEnum(this.value);

final String value;

@override
String toString() => value;
}


Original file line number Diff line number Diff line change
Expand Up @@ -172,49 +172,77 @@ class EnumTest {


enum EnumTestEnumStringEnum {
@JsonValue(r'UPPER')
UPPER,
@JsonValue(r'lower')
lower,
@JsonValue(r'')
empty,
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi,
@JsonValue(r'UPPER')
UPPER(r'UPPER'),
@JsonValue(r'lower')
lower(r'lower'),
@JsonValue(r'')
empty(r''),
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi(r'unknown_default_open_api');

const EnumTestEnumStringEnum(this.value);

final String value;

@override
String toString() => value;
}



enum EnumTestEnumStringRequiredEnum {
@JsonValue(r'UPPER')
UPPER,
@JsonValue(r'lower')
lower,
@JsonValue(r'')
empty,
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi,
@JsonValue(r'UPPER')
UPPER(r'UPPER'),
@JsonValue(r'lower')
lower(r'lower'),
@JsonValue(r'')
empty(r''),
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi(r'unknown_default_open_api');

const EnumTestEnumStringRequiredEnum(this.value);

final String value;

@override
String toString() => value;
}



enum EnumTestEnumIntegerEnum {
@JsonValue(1)
number1,
@JsonValue(-1)
numberNegative1,
@JsonValue(11184809)
unknownDefaultOpenApi,
@JsonValue(1)
number1('1'),
@JsonValue(-1)
numberNegative1('-1'),
@JsonValue(11184809)
unknownDefaultOpenApi('11184809');

const EnumTestEnumIntegerEnum(this.value);

final String value;

@override
String toString() => value;
}



enum EnumTestEnumNumberEnum {
@JsonValue('1.1')
number1Period1,
@JsonValue('-1.2')
numberNegative1Period2,
@JsonValue('11184809')
unknownDefaultOpenApi,
@JsonValue('1.1')
number1Period1(''1.1''),
@JsonValue('-1.2')
numberNegative1Period2(''-1.2''),
@JsonValue('11184809')
unknownDefaultOpenApi(''11184809'');

const EnumTestEnumNumberEnum(this.value);

final String value;

@override
String toString() => value;
}


Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,19 @@ class MapTest {


enum MapTestMapOfEnumStringEnum {
@JsonValue(r'UPPER')
UPPER,
@JsonValue(r'lower')
lower,
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi,
@JsonValue(r'UPPER')
UPPER(r'UPPER'),
@JsonValue(r'lower')
lower(r'lower'),
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi(r'unknown_default_open_api');

const MapTestMapOfEnumStringEnum(this.value);

final String value;

@override
String toString() => value;
}


Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,25 @@ class Order {

/// Order Status
enum OrderStatusEnum {
@JsonValue(r'placed')
placed,
@JsonValue(r'approved')
approved,
@JsonValue(r'delivered')
delivered,
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi,
/// Order Status
@JsonValue(r'placed')
placed(r'placed'),
/// Order Status
@JsonValue(r'approved')
approved(r'approved'),
/// Order Status
@JsonValue(r'delivered')
delivered(r'delivered'),
/// Order Status
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi(r'unknown_default_open_api');

const OrderStatusEnum(this.value);

final String value;

@override
String toString() => value;
}


Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,17 @@ class ParentWithNullable {


enum ParentWithNullableTypeEnum {
@JsonValue(r'ChildWithNullable')
childWithNullable,
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi,
@JsonValue(r'ChildWithNullable')
childWithNullable(r'ChildWithNullable'),
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi(r'unknown_default_open_api');

const ParentWithNullableTypeEnum(this.value);

final String value;

@override
String toString() => value;
}


Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,25 @@ class Pet {

/// pet status in the store
enum PetStatusEnum {
@JsonValue(r'available')
available,
@JsonValue(r'pending')
pending,
@JsonValue(r'sold')
sold,
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi,
/// pet status in the store
@JsonValue(r'available')
available(r'available'),
/// pet status in the store
@JsonValue(r'pending')
pending(r'pending'),
/// pet status in the store
@JsonValue(r'sold')
sold(r'sold'),
/// pet status in the store
@JsonValue(r'unknown_default_open_api')
unknownDefaultOpenApi(r'unknown_default_open_api');

const PetStatusEnum(this.value);

final String value;

@override
String toString() => value;
}


0 comments on commit abf9416

Please sign in to comment.