Skip to content

Commit

Permalink
Version/2.2.5 (#271)
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

Co-authored-by: uladzimir_paliukhovich <>
Co-authored-by: Elliana May <[email protected]>
  • Loading branch information
Vovanella95 and Mause authored Nov 12, 2021
1 parent f98a352 commit 012301e
Show file tree
Hide file tree
Showing 17 changed files with 437 additions and 249 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ${{ matrix.runs-on }}

strategy:
matrix:
runs-on: [windows-latest, ubuntu-latest]

steps:
- uses: actions/[email protected]
- uses: subosito/flutter-action@v1
Expand Down
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# 2.2.5

* Fixed Issue ([#265](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/265))
* Fixed Issue ([#275](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/275))
* Returned possibility to use operationId for request name
* Added generation of requestBodies integrated to requests, when it's complex model

# 2.2.4

* Fixes issues with allOf support
* Fixed issue with basic types in responses models

# 2.2.3

* Fixed Issue ([#138](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/138))
Expand Down
2 changes: 1 addition & 1 deletion example/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ targets:
use_path_for_request_names: true
use_default_null_for_lists: false
build_only_models: false
separate_models: true
separate_models: false
enums_case_sensitive: false
ignore_headers: false
use_required_attribute_for_headers: false
Expand Down
1 change: 1 addition & 0 deletions lib/src/code_generators/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const kBasicTypes = [
const kChopperService = 'ChopperService';
const kChopperApi = 'ChopperApi';
const kResponse = 'Response';
const kRequestBody = 'RequestBody';
const kFutureResponse = 'Future<chopper.Response>';
const kString = 'string';
const kUndefinedParameter = 'undefinedParameter';
Expand Down
38 changes: 29 additions & 9 deletions lib/src/code_generators/swagger_enums_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ abstract class SwaggerEnumsGenerator {
final enumsFromClasses = definitions.keys
.map((String className) {
return generateEnumsFromClasses(
SwaggerModelsGenerator.getValidatedClassName(
className.pascalCase),
definitions[className] as Map<String, dynamic>);
SwaggerModelsGenerator.getValidatedClassName(className.pascalCase),
definitions[className] as Map<String, dynamic>,
definitions,
);
})
.where((element) => element.isNotEmpty)
.join('\n');
Expand Down Expand Up @@ -81,9 +82,10 @@ $enumsFromRequestBodies
}

return generateEnumsFromClasses(
SwaggerModelsGenerator.getValidatedClassName(
className.pascalCase),
schema as Map<String, dynamic>);
SwaggerModelsGenerator.getValidatedClassName(className.pascalCase),
schema as Map<String, dynamic>,
{},
);
})
.where((element) => element.isNotEmpty)
.join('\n');
Expand All @@ -110,9 +112,10 @@ $enumsFromRequestBodies
}

return generateEnumsFromClasses(
SwaggerModelsGenerator.getValidatedClassName(
className.pascalCase),
schema as Map<String, dynamic>);
SwaggerModelsGenerator.getValidatedClassName(className.pascalCase),
schema as Map<String, dynamic>,
{},
);
})
.where((element) => element.isNotEmpty)
.join('\n');
Expand Down Expand Up @@ -376,6 +379,7 @@ $enumMap
String generateEnumsFromClasses(
String className,
Map<String, dynamic> map,
Map<String, dynamic> schemas,
) {
if (map['enum'] != null) {
return generateEnumContentIfPossible(map, className);
Expand All @@ -400,6 +404,22 @@ $enumMap
} else {
properties = map['properties'] as Map<String, dynamic>? ?? {};
}

var allOfRef = allOf.firstWhereOrNull(
(e) => (e as Map<String, dynamic>).containsKey('\$ref'),
) as Map<String, dynamic>?;

if (allOfRef != null) {
final ref = allOfRef['\$ref'] as String;

final allOfModel =
schemas[ref.getUnformattedRef()] as Map<String, dynamic>? ?? {};

final allOfModelProperties =
allOfModel['properties'] as Map<String, dynamic>? ?? {};

properties.addAll(allOfModelProperties);
}
} else {
properties = map['properties'] as Map<String, dynamic>? ?? {};
}
Expand Down
Loading

0 comments on commit 012301e

Please sign in to comment.