Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* Fixed some issues

* formatted code

* updated SDK

* Updated SDK and version

* Fixed generation of lists of classes

* Fixed generation $Items classes

* Updated pubspec and changelog

* Fixed epam-cross-platform-lab#524

* Fixed epam-cross-platform-lab#598 Generation of query enum parameters

* Fixed conflicts

* Fixed some issues in swaggers

* Updated changelog and pubspec

* Fix epam-cross-platform-lab#583, epam-cross-platform-lab#637, epam-cross-platform-lab#619 and update readme (epam-cross-platform-lab#638)

* fix epam-cross-platform-lab#583 and update readme

* fix epam-cross-platform-lab#637

* fix epam-cross-platform-lab#619

* Fixed generation of some fields

* Removed test

* Fixed classes named List

* Fixed generation of query parameters with ref default type

* Fixed generation of DateTime parameters

* Fixed generation of responses in some cases

* Some fixes

* Updated changelog and pubspec

* Implemented not nullable fields

* Fixed tests

* fixed generation of some swaggers

* Added ability to return String values

* Returned main.dart content

* Updated pubspec and changelog

* Fixed generation of required and not required fields

* Added check for object ref in body

* Fixed some things

* Fixed tests

* Fixed tests

* Fixed some things

* Updated changelog and pubspec

* Removed not needed lines in tests

* Fixed generation of nullable responses

* Added generation of DateTime

* Updated pubspec and changelog

* Fixed tests

* Fixed epam-cross-platform-lab#669 Generation models from content schema allof

* Fixed epam-cross-platform-lab#665 generation putIfAbsent for response from content schema

* Fixed generation of nullable and required properties

* Fixed tests

* Fixed some stuff related to nullable properties

* Updated changelog and pubspec

* Formatted code

* Formatted code

* Fixed tests

* Fixed generation of some enums inside classes

* Implemented support of exploded parameters

* Pushed constants file

* Fixed generation of allOf for request bodies

* Implemented overriden_models functionality

* Improved overriden models logic

* Fixed tests

* Updated pubspec and changelog

* Removed support of exploded parameters

* Fixed generation of patameters contains keywords

* Updated pubspec and changelog

* Fixed generation of nullable and not nullable fields

* Fixed generation of list parameters with specific names

* Fixed formurlencoded requests

* Revert "Fixed formurlencoded requests"

This reverts commit d103118.

* Updated changelog and pubspec

* formatted code

* Fixed version in changelog

* Added generation of writeOnly and readOnly fields as nullable and no required (Issue 487)

* Fixed generatino of DateTime query parameters (Issue 536)

* Updated pubspec and changelog

* Fixed generation in some cases

* Added ability to rename downloaded files

* Updated example

* Implemented support of deprecated fields annotations

* Added support of deprecated requests annotations

* Fixed tests, updated pubspec and changelog

* Fixed putIfAbsent for allOf schemas epam-cross-platform-lab#700

* Fixed tests

* Implemented new build option

* Some fixes

* Implemented new generator option

* Updated changelog, readme and pubspec

* Fixed conflicts

* Fixed generation of requestBody when one oneOf provided

* Added override keyword to exceptionWords

* Fixed generation of allOf models

* Revert "Fixed generation of allOf models"

This reverts commit b61b613.

* Updated pubspec and changelog

* Updated changelog

* Fixed epam-cross-platform-lab#722 generation of some files

* Fixed generation of quoted in enum names

* Fixed generation of some requests with enums

* Updated changelog and pubspec

* Fixed generation of some swaggers

* Improved allOf generation logic

* Updated changelog and pubspec

* Fixed conflicts

* Fixed generation JsonKeys with keywords

* Updated changelog

* Fixed changelog

---------

Co-authored-by: Uladzimir Paliukhovich <[email protected]>
Co-authored-by: Romain <[email protected]>
  • Loading branch information
3 people authored and AnnaKandel committed Nov 3, 2024
1 parent 653af81 commit 4c95bd6
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 4 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 2.15.3

* Fixed generation of keywords in JsonKeys ([#734](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/734))

# 2.15.2

* Fixed generation of some complex `allOf` chains

# 2.15.1

* Fixed some issues
Expand Down
27 changes: 26 additions & 1 deletion lib/src/code_generators/swagger_models_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
String generatePropertyContentByDefault({
required SwaggerSchema prop,
required String propertyName,
required String propertyKey,
required List<String> allEnumNames,
required List<String> allEnumListNames,
required List<String> requiredProperties,
Expand All @@ -455,7 +456,7 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
typeName = kDynamic;
}

final propertyKey = propertyName.replaceAll('\$', '\\\$');
propertyKey = propertyKey.replaceAll('\$', '\\\$');

final unknownEnumValue = generateEnumValue(
allEnumNames: allEnumNames,
Expand Down Expand Up @@ -1261,6 +1262,7 @@ static $returnType $fromJsonFunction($valueType? value) => $enumNameCamelCase$fr
results.add(generatePropertyContentByDefault(
prop: prop,
propertyName: propertyName,
propertyKey: propertyKey,
allEnumNames: allEnumNames,
allEnumListNames: allEnumListNames,
requiredProperties: requiredProperties,
Expand Down Expand Up @@ -1709,6 +1711,29 @@ $allHashComponents;
final schema = schemas[refString.getUnformattedRef()];

if (schema != null) {
if (schema.allOf.isNotEmpty) {
final refs =
allOf.where((element) => element.ref.isNotEmpty).toList();

for (var allOf in refs) {
final allOfSchema = allClasses[allOf.ref.getUnformattedRef()];

if (allOfSchema != null) {
currentProperties.addAll(Map.from(allOfSchema.properties));
for (final allOf in allOfSchema.allOf) {
currentProperties.addAll(allOf.properties);

if (allOf.ref.isNotEmpty) {
final oneMoreModel =
allClasses[allOf.ref.getUnformattedRef()];
currentProperties.addAll(oneMoreModel?.properties ?? {});
}
}
}

currentProperties.addAll(allOfSchema?.properties ?? {});
}
}
final moreProperties = schema.properties;

currentProperties.addAll(moreProperties);
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.15.1
version: 2.15.2

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
8 changes: 6 additions & 2 deletions test/generator_tests/models_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ void main() {
final result = generator.generatePropertyContentByDefault(
prop: propertyEntryMap,
propertyName: propertyName,
propertyKey: propertyName,
allEnumNames: [],
allEnumListNames: [],
requiredProperties: [],
Expand All @@ -190,6 +191,7 @@ void main() {
)).generatePropertyContentByDefault(
prop: propertyEntryMap,
propertyName: propertyName,
propertyKey: propertyName,
allEnumNames: [],
allEnumListNames: [],
requiredProperties: [],
Expand All @@ -205,6 +207,7 @@ void main() {
final result = generator.generatePropertyContentByDefault(
prop: propertyEntryMap,
propertyName: propertyName,
propertyKey: propertyName,
allEnumNames: [],
allEnumListNames: [],
requiredProperties: [],
Expand Down Expand Up @@ -377,7 +380,7 @@ void main() {
};

const className = 'Animals';
const jsonKeyExpectedResult = "\t@JsonKey(name: 'animals')\n";
const jsonKeyExpectedResult = "\t@JsonKey(name: 'Animals')\n";
const fieldExpectedResult = 'final Pet animals';
final result = generator.generatePropertiesContent(
SwaggerRoot.empty,
Expand All @@ -402,7 +405,7 @@ void main() {
};

const className = 'Animals';
const jsonKeyExpectedResult = "\t@JsonKey(name: '\\\$with')\n";
const jsonKeyExpectedResult = "\t@JsonKey(name: 'with')\n";
const fieldExpectedResult = 'final Pet \$with';
final result = generator.generatePropertiesContent(
SwaggerRoot.empty,
Expand Down Expand Up @@ -618,6 +621,7 @@ void main() {
group('Tests for additionalProperties', () {
test('Should generate dynamic map type', () {
final map = SwaggerRoot.parse(objectWithadditionalProperties);

final result = generator.generate(
root: map,
fileName: 'fileName',
Expand Down

0 comments on commit 4c95bd6

Please sign in to comment.