From f74d7cbc5f83cc2eba3996a31bd9c3d102264479 Mon Sep 17 00:00:00 2001 From: Uladzimir_Paliukhovich Date: Fri, 14 Jan 2022 11:44:38 +0300 Subject: [PATCH] Version/2.3.6 (#312) * Fixed some issues * Added fix for Field annotations. Updatec changelog and pubspec * Fixed lot of issues with AllOf support * Updated changelog and pubspec * Added requestbodies generation from requests * Add windows support (#273) * Run CI on windows too * chore: Fix a number of path joins * fix: Revert change to getFileNameWithoutExtension * fix: Normalize paths used for extensions * Fixed errors with requestBodies generation * Added possibility to use operationId for request name * Format code * Updated pubspec and changelog * Fix tests * Fix analyser issues * Updated example readme * Removed converter generator * Fix cases when refs are overriden * Fixed enum generation Changed int64 parsing to double * Released 2.2.8 * Added support int64 * Updated changelog and pubspec * Fix for models int64 * Updated changelog and pubspec * Removed not needed file * Fixed responses array of int * Reverted analysis options * Updated changelog * Updated version * Fixed tests * Fixed analyser issues * Fixed issue #291 * updated changelog and pubcpec * Added parsing of security for requests * Fixed num parsing as Num * Implemented security keys definition * Removed not needed prints * Updated changelog and pubspec * Removed use_inheritance field * Removed outdated tests * Implemented integer enums support * Updated changelog and pubspec * Fixed fromJson for integer enum fields * Updated changelog and pubspec * Formatted code * Updated changelog * Fixed issue 263 * Fixed test * Fixed issue #311 * Updated pubspec and changelog Co-authored-by: uladzimir_paliukhovich <> Co-authored-by: Elliana May --- CHANGELOG.md | 5 ++++ .../swagger_enums_generator.dart | 7 +++++- .../swagger_models_generator.dart | 25 +++++++++++++------ pubspec.yaml | 2 +- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9489006d..d401c47a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# 2.3.6 + +* Fixed Issue ([#311](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/311)) +* Fixed some borded cases in Swagger generator + # 2.3.5 * Fixed Issue ([#263](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/263)) diff --git a/lib/src/code_generators/swagger_enums_generator.dart b/lib/src/code_generators/swagger_enums_generator.dart index 77528212..8aeec6dc 100644 --- a/lib/src/code_generators/swagger_enums_generator.dart +++ b/lib/src/code_generators/swagger_enums_generator.dart @@ -367,7 +367,12 @@ $enumMap final gemeratedEnumsContent = map.keys .map((String key) { - final enumValuesMap = map[key] as Map; + final enumValues = map[key]; + + final enumValuesMap = enumValues is Map + ? enumValues + : {}; + map[key]; if (enumValuesMap.containsKey('type')) { return generateEnumContentIfPossible( diff --git a/lib/src/code_generators/swagger_models_generator.dart b/lib/src/code_generators/swagger_models_generator.dart index 4a150974..7a32f64a 100644 --- a/lib/src/code_generators/swagger_models_generator.dart +++ b/lib/src/code_generators/swagger_models_generator.dart @@ -839,8 +839,12 @@ abstract class SwaggerModelsGenerator { for (var i = 0; i < propertiesMap.keys.length; i++) { var propertyName = propertiesMap.keys.elementAt(i); - final propertyEntryMap = - propertiesMap[propertyName] as Map; + + final propertyEntry = propertiesMap[propertyName]; + final propertyEntryMap = propertyEntry is Map + ? propertyEntry + : {}; + final propertyKey = propertyName; final basicTypesMap = generateBasicTypesMapFromSchemas(swagger); @@ -1212,10 +1216,12 @@ $allHashComponents; final refString = allOfRef['\$ref'].toString(); final schema = schemas[refString.getUnformattedRef()]; - final moreProperties = - schema['properties'] as Map? ?? {}; + if (schema != null) { + final moreProperties = + schema['properties'] as Map? ?? {}; - currentProperties.addAll(moreProperties); + currentProperties.addAll(moreProperties); + } } return currentProperties; @@ -1303,10 +1309,13 @@ $allHashComponents; } properties.forEach((propertyName, propertyValue) { - var property = propertyValue as Map; + if (propertyValue is! Map) { + return; + } - if (property.containsKey('enum') || - (property['items'] != null && property['items']['enum'] != null)) { + if (propertyValue.containsKey('enum') || + (propertyValue['items'] != null && + propertyValue['items']['enum'] != null)) { results.add(SwaggerModelsGenerator.getValidatedClassName( SwaggerEnumsGeneratorV3().generateEnumName( SwaggerModelsGenerator.getValidatedClassName(className), diff --git a/pubspec.yaml b/pubspec.yaml index 58bd6cde..e8f150bf 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: swagger_dart_code_generator -version: 2.3.5 +version: 2.3.6 homepage: https://github.com/epam-cross-platform-lab/swagger-dart-code-generator repository: https://github.com/epam-cross-platform-lab/swagger-dart-code-generator