diff --git a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/json_serializable/enum_inline.mustache b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/json_serializable/enum_inline.mustache index 53cd77098740..3b441c237c90 100644 --- a/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/json_serializable/enum_inline.mustache +++ b/modules/openapi-generator/src/main/resources/dart/libraries/dio/serialization/json_serializable/enum_inline.mustache @@ -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}} \ No newline at end of file diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/child_with_nullable.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/child_with_nullable.dart index 22b9df5c55a4..61faa249bc45 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/child_with_nullable.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/child_with_nullable.dart @@ -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; } diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/enum_arrays.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/enum_arrays.dart index 46959e7ccd72..6e2c199d3845 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/enum_arrays.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/enum_arrays.dart @@ -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; } diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/enum_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/enum_test.dart index 687e674d211a..7aa72fe0559c 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/enum_test.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/enum_test.dart @@ -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; } diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/map_test.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/map_test.dart index beb4547b7702..13cf820e0c9e 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/map_test.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/map_test.dart @@ -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; } diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/order.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/order.dart index 00b4e62e0a14..9d745c6dd9a1 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/order.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/order.dart @@ -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; } diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/parent_with_nullable.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/parent_with_nullable.dart index 880c2c33cec1..3496af6f6c3a 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/parent_with_nullable.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/parent_with_nullable.dart @@ -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; } diff --git a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/pet.dart b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/pet.dart index 1e7a108b7600..8a7ac6ad6354 100644 --- a/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/pet.dart +++ b/samples/openapi3/client/petstore/dart-dio/petstore_client_lib_fake-json_serializable/lib/src/model/pet.dart @@ -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; }