diff --git a/swagger_parser/CHANGELOG.md b/swagger_parser/CHANGELOG.md index ae6a390c..3c5a6779 100644 --- a/swagger_parser/CHANGELOG.md +++ b/swagger_parser/CHANGELOG.md @@ -1,3 +1,6 @@ +## 1.20.1 +- Fixed errors with config parsing + ## 1.20.0 - Add validation params to generated `freezed` classes - Fixed errors with empty schema properties([#280](https://github.com/Carapacik/swagger_parser/issues/280)) diff --git a/swagger_parser/lib/src/config/swp_config.dart b/swagger_parser/lib/src/config/swp_config.dart index ca4c4633..fe66c59b 100644 --- a/swagger_parser/lib/src/config/swp_config.dart +++ b/swagger_parser/lib/src/config/swp_config.dart @@ -150,10 +150,10 @@ class SWPConfig { ); } - final mergeClients = yamlMap['mergeClients']; + final mergeClients = yamlMap['merge_clients']; if (mergeClients is! bool?) { throw const ConfigException( - "Config parameter 'mergeClients' must be bool.", + "Config parameter 'merge_clients' must be bool.", ); } @@ -193,6 +193,8 @@ class SWPConfig { final rawJsonSerializer = yamlMap['json_serializer']?.toString(); if (rawJsonSerializer != null) { jsonSerializer = JsonSerializer.fromString(rawJsonSerializer); + } else if (rootConfig?.jsonSerializer != null) { + jsonSerializer = rootConfig!.jsonSerializer; } final rootClient = yamlMap['root_client']; diff --git a/swagger_parser/lib/src/generator/model/programming_language.dart b/swagger_parser/lib/src/generator/model/programming_language.dart index f4ca4bc0..b7ef9b76 100644 --- a/swagger_parser/lib/src/generator/model/programming_language.dart +++ b/swagger_parser/lib/src/generator/model/programming_language.dart @@ -63,25 +63,21 @@ enum ProgrammingLanguage { markFileAsGenerated: markFilesAsGenerated, ); } - - switch (jsonSerializer) { - case JsonSerializer.freezed: - return dartFreezedDtoTemplate( + return switch (jsonSerializer) { + JsonSerializer.freezed => dartFreezedDtoTemplate( dataClass, markFileAsGenerated: markFilesAsGenerated, generateValidator: generateValidator, - ); - case JsonSerializer.jsonSerializable: - return dartJsonSerializableDtoTemplate( + ), + JsonSerializer.jsonSerializable => dartJsonSerializableDtoTemplate( dataClass, markFileAsGenerated: markFilesAsGenerated, - ); - case JsonSerializer.dartMappable: - return dartDartMappableDtoTemplate( + ), + JsonSerializer.dartMappable => dartDartMappableDtoTemplate( dataClass, markFileAsGenerated: markFilesAsGenerated, - ); - } + ) + }; } case kotlin: if (dataClass is UniversalEnumClass) { diff --git a/swagger_parser/pubspec.yaml b/swagger_parser/pubspec.yaml index e3aca081..fb690451 100644 --- a/swagger_parser/pubspec.yaml +++ b/swagger_parser/pubspec.yaml @@ -1,6 +1,6 @@ name: swagger_parser description: Package that generates REST clients and data classes from OpenApi definition file -version: 1.20.0 +version: 1.20.1 repository: https://github.com/Carapacik/swagger_parser/tree/main/swagger_parser topics: - swagger