Skip to content

Commit

Permalink
Version/2.3.10 (#325)
Browse files Browse the repository at this point in the history
* 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

* Fixed list enums generation in requests

* Updated pubspec and changelog

* Fixed issue #296

* Updated pubspec and changelog

* Fixed conflicts

* [BUB] Array in spec is not being generated as expected

* Updated pubspec and changelog

* Fixed responses returns Stream<Something>
Fixed cases when we have List<List<...<List<SomeClass> in model parameter

* Updated changelog and pubspec

Co-authored-by: uladzimir_paliukhovich <>
Co-authored-by: Elliana May <me@mause.me>
  • Loading branch information
Vovanella95 and Mause authored Jan 27, 2022
1 parent 69773af commit 021a618
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 15 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# 2.3.9

* Fixed cases when we have Stream<SomeClass> as request parameter
* Fixed cases when we have List<List<....<SomeClass>>> in model properties

# 2.3.9

* Fixed Issue ([#313](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/313))
* Fixed cases with array string definitions

Expand Down
54 changes: 42 additions & 12 deletions lib/src/code_generators/swagger_models_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -617,16 +617,15 @@ abstract class SwaggerModelsGenerator {
final ${className.capitalize + key.capitalize}? ${SwaggerModelsGenerator.generateFieldName(key)};''';
}

String generateListPropertyContent(
String propertyName,
String propertyKey,
String className,
Map<String, dynamic> propertyEntryMap,
bool useDefaultNullForLists,
List<String> allEnumNames,
List<String> allEnumListNames,
GeneratorOptions options,
Map<String, String> basicTypesMap) {
String _generateListPropertyTypeName({
required List<String> allEnumNames,
required List<String> allEnumListNames,
required Map<String, dynamic> propertyEntryMap,
required GeneratorOptions options,
required Map<String, String> basicTypesMap,
required String propertyName,
required String className,
}) {
final items = propertyEntryMap['items'];

var typeName = '';
Expand All @@ -652,7 +651,7 @@ abstract class SwaggerModelsGenerator {

if (basicTypesMap.containsKey(typeName)) {
typeName = basicTypesMap[typeName]!;
} else if (typeName != kDynamic) {
} else if (typeName.isNotEmpty && typeName != kDynamic) {
typeName = typeName.pascalCase;
}
} else if (!allEnumNames.contains('enums.$typeName') &&
Expand All @@ -666,7 +665,15 @@ abstract class SwaggerModelsGenerator {

if (typeName.isEmpty) {
if (items['type'] == 'array' || items['items'] != null) {
typeName = 'List<Object>';
return _generateListPropertyTypeName(
allEnumListNames: allEnumListNames,
allEnumNames: allEnumNames,
basicTypesMap: basicTypesMap,
className: className,
options: options,
propertyEntryMap: items as Map<String, dynamic>,
propertyName: propertyName,
).asList();
}
}

Expand All @@ -685,6 +692,29 @@ abstract class SwaggerModelsGenerator {
);
}

return typeName;
}

String generateListPropertyContent(
String propertyName,
String propertyKey,
String className,
Map<String, dynamic> propertyEntryMap,
bool useDefaultNullForLists,
List<String> allEnumNames,
List<String> allEnumListNames,
GeneratorOptions options,
Map<String, String> basicTypesMap) {
final typeName = _generateListPropertyTypeName(
allEnumListNames: allEnumListNames,
allEnumNames: allEnumNames,
basicTypesMap: basicTypesMap,
className: className,
options: options,
propertyEntryMap: propertyEntryMap,
propertyName: propertyName,
);

final unknownEnumValue = generateUnknownEnumValue(
allEnumNames, allEnumListNames, typeName, true);

Expand Down
2 changes: 1 addition & 1 deletion lib/src/code_generators/swagger_requests_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class SwaggerRequestsGenerator {

//Models from response

final neededResponse = response.removeList();
final neededResponse = response.removeListOrStream();
if (!kBasicTypes.contains(neededResponse)) {
results.add(neededResponse);
}
Expand Down
3 changes: 2 additions & 1 deletion lib/src/extensions/string_extension.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ extension TypeExtension on String {

String asList() => 'List<$this>';

String removeList() => replaceAll('List<', '').replaceAll('>', '');
String removeListOrStream() =>
replaceAll('List<', '').replaceAll('Stream<', '').replaceAll('>', '');

String asEnum() => 'enums.$this';

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: swagger_dart_code_generator

version: 2.3.9
version: 2.3.10

homepage: https://github.com/epam-cross-platform-lab/swagger-dart-code-generator
repository: https://github.com/epam-cross-platform-lab/swagger-dart-code-generator
Expand Down

0 comments on commit 021a618

Please sign in to comment.