diff --git a/CHANGELOG.md b/CHANGELOG.md index dbe7c4a7..b5278288 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.7.3 + +* Fixed issue with generation `+` and `-` signs as enum names ([#444](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/444)) + # 2.7.2 * Implemented generation of copyWithWrapped ([#438](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/438)) diff --git a/lib/src/code_generators/swagger_enums_generator.dart b/lib/src/code_generators/swagger_enums_generator.dart index bd6140cb..6aea1442 100644 --- a/lib/src/code_generators/swagger_enums_generator.dart +++ b/lib/src/code_generators/swagger_enums_generator.dart @@ -221,14 +221,7 @@ $enumMap } result.add(validatedValue); - - if (isInteger) { - resultStrings.add( - "\t@JsonValue(${value.replaceAll("\$", "\\\$")})\n\t$validatedValue"); - } else { - resultStrings.add( - "\t@JsonValue('${value.replaceAll("\$", "\\\$")}')\n\t$validatedValue"); - } + resultStrings.add(validatedValue); } return resultStrings.join(',\n'); @@ -290,6 +283,10 @@ $enumMap return '\$' + result.lower; } + if (result.isEmpty) { + return 'undefined'; + } + return result.lower; } diff --git a/pubspec.yaml b/pubspec.yaml index 88c5b516..f8934db6 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: swagger_dart_code_generator -version: 2.7.2 +version: 2.7.3 homepage: https://github.com/epam-cross-platform-lab/swagger-dart-code-generator repository: https://github.com/epam-cross-platform-lab/swagger-dart-code-generator diff --git a/test/generator_tests/enums_generator_test.dart b/test/generator_tests/enums_generator_test.dart index b6cb86ed..8f9a6361 100644 --- a/test/generator_tests/enums_generator_test.dart +++ b/test/generator_tests/enums_generator_test.dart @@ -45,7 +45,7 @@ void main() { group('Converter generator tests', () { test('Should generate enum values', () { final values = ['file_sup']; - const output = "\t@JsonValue('file_sup')\n\tfileSup"; + const output = "fileSup"; final result = generator.getEnumValuesContent( enumValues: values, isInteger: false,