Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version/2.3.5 #308

Merged
merged 53 commits into from
Jan 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
4f84c08
Fixed some issues
Nov 1, 2021
26c00bd
Added fix for Field annotations. Updatec changelog and pubspec
Nov 1, 2021
57186d5
Fixed lot of issues with AllOf support
Nov 2, 2021
9c20696
Updated changelog and pubspec
Nov 2, 2021
0a5e0a1
Added requestbodies generation from requests
Nov 4, 2021
4a5b13b
Merge remote-tracking branch 'origin/master' into version/2.2.5
Nov 4, 2021
e22cf42
Add windows support (#273)
Mause Nov 10, 2021
73d60e2
Fixed errors with requestBodies generation
Nov 12, 2021
cfc205f
Added possibility to use operationId for request name
Nov 12, 2021
364a7b4
Format code
Nov 12, 2021
42ee7ed
Updated pubspec and changelog
Nov 12, 2021
2da1393
Fix tests
Nov 12, 2021
95c4478
Fix analyser issues
Nov 12, 2021
bdd025b
Updated example readme
Nov 12, 2021
e5de95a
Removed converter generator
Nov 19, 2021
fc1a8e7
Fix cases when refs are overriden
Nov 24, 2021
e14ed6a
Fixed enum generation
Dec 14, 2021
16d788e
Released 2.2.8
Dec 14, 2021
73d0ae5
Added support int64
Dec 15, 2021
850624f
Updated changelog and pubspec
Dec 15, 2021
9139808
Fix for models int64
Dec 16, 2021
c575224
Updated changelog and pubspec
Dec 16, 2021
c1d69b3
Merge remote-tracking branch 'origin/version/2.2.8' into version/2.3.0
Dec 17, 2021
2a6f9cd
Removed not needed file
Dec 17, 2021
3f850d3
Fixed responses array of int
Dec 22, 2021
c6e9cb3
Reverted analysis options
Dec 22, 2021
b987918
Updated changelog
Dec 22, 2021
2c20a3b
Updated version
Dec 22, 2021
a1a93c3
Fixed tests
Dec 22, 2021
22075cd
Merge remote-tracking branch 'origin/master' into version/2.3.0
Dec 22, 2021
a1b6bd3
Fixed analyser issues
Dec 22, 2021
b6eb45b
Fixed issue #291
Dec 23, 2021
f495829
updated changelog and pubcpec
Dec 23, 2021
f006011
Merge remote-tracking branch 'origin/master' into version/2.3.1
Dec 23, 2021
39f4a7e
Added parsing of security for requests
Dec 24, 2021
56882c9
Fixed num parsing as Num
Dec 24, 2021
c2e4412
Implemented security keys definition
Dec 24, 2021
76073db
Removed not needed prints
Dec 24, 2021
d1d056e
Updated changelog and pubspec
Dec 24, 2021
79b7393
Merge remote-tracking branch 'origin/master' into version/2.3.2
Dec 24, 2021
8445037
Removed use_inheritance field
Jan 10, 2022
a4fc03b
Merge remote-tracking branch 'origin/master' into version/2.3.3
Jan 10, 2022
9a19d7a
Removed outdated tests
Jan 10, 2022
c519d47
Implemented integer enums support
Jan 11, 2022
a4bc616
Merge remote-tracking branch 'origin/master' into version/2.3.4
Jan 11, 2022
c114860
Updated changelog and pubspec
Jan 11, 2022
96f6873
Fixed fromJson for integer enum fields
Jan 11, 2022
17b84d9
Updated changelog and pubspec
Jan 11, 2022
38813b2
Formatted code
Jan 11, 2022
cb458f2
Updated changelog
Jan 11, 2022
d51a393
Fixed issue 263
Jan 13, 2022
52f3983
Merge remote-tracking branch 'origin/master' into version/2.3.5
Jan 13, 2022
fe39ba2
Fixed test
Jan 13, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# 2.3.5

* Fixed Issue ([#263](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/263))
* Fixed generation of Enums, defined in /parameters/ and used in request parameters

# 2.3.4+1

* Fixed fromJson method for integer Enum fields in models

# 2.3.4

* Fixed Issue ([#268](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/268))
Expand Down
19 changes: 14 additions & 5 deletions lib/src/code_generators/swagger_enums_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,24 @@ $enumsFromRequestBodies
final map = jsonDecode(swagger) as Map<String, dynamic>;
final swaggerRoot = SwaggerRoot.fromJson(map);

final definedParameters = <String, SwaggerRequestParameter>{};
definedParameters.addAll(swaggerRoot.parameters);
definedParameters.addAll(swaggerRoot.components?.parameters ?? {});

//Link defined parameters with requests
swaggerRoot.paths.forEach((String path, SwaggerPath swaggerPath) {
swaggerPath.requests
.forEach((String requestType, SwaggerRequest swaggerRequest) {
swaggerRequest.parameters = swaggerRequest.parameters
.map((SwaggerRequestParameter parameter) =>
getOriginalOrOverriddenRequestParameter(parameter,
swaggerRoot.components?.parameters.values.toList() ?? []))
.toList();
swaggerRequest.parameters =
swaggerRequest.parameters.map((SwaggerRequestParameter parameter) {
if (definedParameters
.containsKey(parameter.ref.getUnformattedRef())) {
return definedParameters[parameter.ref.getUnformattedRef()]!;
}

return getOriginalOrOverriddenRequestParameter(parameter,
swaggerRoot.components?.parameters.values.toList() ?? []);
}).toList();
});
});

Expand Down
19 changes: 14 additions & 5 deletions lib/src/code_generators/swagger_models_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ abstract class SwaggerModelsGenerator {

if (exceptionWords.contains(result.camelCase) ||
kBasicTypes.contains(result.camelCase)) {
return '\$$parameterName';
return '\$$result';
}

if (result.isEmpty) {
Expand Down Expand Up @@ -963,17 +963,26 @@ String? ${neededName.camelCase}ToJson(enums.$neededName? ${neededName.camelCase}
return enums.\$${neededName}Map[${neededName.camelCase}];
}

enums.$neededName ${neededName.camelCase}FromJson(String? ${neededName.camelCase}) {
enums.$neededName ${neededName.camelCase}FromJson(Object? ${neededName.camelCase}) {

if(${neededName.camelCase} == null)
if(${neededName.camelCase} is int)
{
return enums.$neededName.swaggerGeneratedUnknown;
return enums.\$${neededName}Map.entries
.firstWhere((element) => element.value$toLowerCaseString == ${neededName.camelCase}.toString(),
orElse: () => const MapEntry(enums.$neededName.swaggerGeneratedUnknown, ''))
.key;
}

return enums.\$${neededName}Map.entries
if(${neededName.camelCase} is String)
{
return enums.\$${neededName}Map.entries
.firstWhere((element) => element.value$toLowerCaseString == ${neededName.camelCase}$toLowerCaseString,
orElse: () => const MapEntry(enums.$neededName.swaggerGeneratedUnknown, ''))
.key;

}

return enums.$neededName.swaggerGeneratedUnknown;
}

List<String> ${neededName.camelCase}ListToJson(
Expand Down
30 changes: 13 additions & 17 deletions lib/src/code_generators/swagger_requests_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,18 @@ class SwaggerRequestsGenerator {
..returns = Reference(className)
..name = 'create'
..static = true
..optionalParameters.add(
Parameter(
(p) => p
..named = true
..type = Reference('ChopperClient?')
..name = 'client',
)
)
..optionalParameters.add(
Parameter(
(p) => p
..named = true
..type = Reference('String?')
..name = 'baseUrl',
)
)
..optionalParameters.add(Parameter(
(p) => p
..named = true
..type = Reference('ChopperClient?')
..name = 'client',
))
..optionalParameters.add(Parameter(
(p) => p
..named = true
..type = Reference('String?')
..name = 'baseUrl',
))
..body = Code(body),
);
}
Expand Down Expand Up @@ -364,7 +360,7 @@ class SwaggerRequestsGenerator {
.join();

final result =
'$pathString${requestType.pascalCase}${SwaggerModelsGenerator.getValidatedClassName(parameterName)}';
'${SwaggerModelsGenerator.getValidatedClassName(pathString)}${requestType.pascalCase}${SwaggerModelsGenerator.getValidatedClassName(parameterName)}';

return result.asEnum();
}
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.4
version: 2.3.5

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
4 changes: 2 additions & 2 deletions test/generator_tests/models_generator_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,8 @@ void main() {
};

const className = 'Animals';
const jsonKeyExpectedResult = "\t@JsonKey(name: '\$with')\n";
const fieldExpectedResult = 'final Pet? \$with';
const jsonKeyExpectedResult = "\t@JsonKey(name: '\$With')\n";
const fieldExpectedResult = 'final Pet? \$With';
final result = generator.generatePropertiesContent(
carsService,
map,
Expand Down