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

Development #694

Merged
merged 84 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
2c826d8
Fixed some issues
Jun 7, 2023
f064936
formatted code
Jun 7, 2023
352d09f
updated SDK
Jun 7, 2023
861dfac
Updated SDK and version
Jun 7, 2023
d320f12
Fixed generation of lists of classes
Jun 7, 2023
fbda249
Fixed generation $Items classes
Jun 7, 2023
1ade0c7
Updated pubspec and changelog
Jun 7, 2023
fe41f12
Fixed #524
Jun 9, 2023
173d9aa
Fixed #598 Generation of query enum parameters
Jun 23, 2023
a09e442
Merge branch 'master' into version/2.11.6
Jun 23, 2023
16b5e3f
Fixed conflicts
Jun 23, 2023
d1c7d2f
Fixed some issues in swaggers
Jul 5, 2023
6ae1b7d
Updated changelog and pubspec
Jul 5, 2023
ff4d14e
Fix #583, #637, #619 and update readme (#638)
romainboucher Sep 8, 2023
3466b48
Merge branch 'master' into version/2.11.6
Sep 8, 2023
290deb0
Fixed generation of some fields
Sep 22, 2023
d3a77eb
Removed test
Sep 22, 2023
8283674
Fixed classes named List
Sep 22, 2023
a71a9e9
Fixed generation of query parameters with ref default type
Sep 22, 2023
dead103
Merge branch 'master' into version/2.11.6
Sep 22, 2023
d99e4f9
Fixed generation of DateTime parameters
Sep 22, 2023
e2fe57f
Fixed generation of responses in some cases
Sep 22, 2023
8e8c5ff
Merge branch 'master' into version/2.11.6
Sep 22, 2023
1b24515
Some fixes
Sep 22, 2023
4bdd297
Updated changelog and pubspec
Sep 22, 2023
b974025
Merge branch 'master' into version/2.11.6
Sep 22, 2023
3e6c745
Implemented not nullable fields
Sep 29, 2023
bc0c305
Fixed tests
Sep 29, 2023
0ed9163
fixed generation of some swaggers
Oct 13, 2023
baec549
Added ability to return String values
Oct 13, 2023
fdc496a
Merge branch 'master' into development
Oct 13, 2023
899833e
Returned main.dart content
Oct 13, 2023
1eabeb0
Updated pubspec and changelog
Oct 13, 2023
360b837
Fixed generation of required and not required fields
Oct 20, 2023
6c2f1a7
Added check for object ref in body
Oct 20, 2023
e973370
Fixed some things
Oct 20, 2023
4fa3a11
Fixed tests
Oct 20, 2023
7896617
Fixed tests
Oct 20, 2023
22af9f0
Fixed some things
Oct 20, 2023
ddf6b4c
Updated changelog and pubspec
Oct 20, 2023
66dba04
Removed not needed lines in tests
Oct 20, 2023
8fcfbb0
Fixed generation of nullable responses
Nov 1, 2023
7448d28
Added generation of DateTime
Nov 1, 2023
c8c3522
Updated pubspec and changelog
Nov 1, 2023
d7a06b2
Merge branch 'master' into development
Nov 1, 2023
4c7f4df
Fixed tests
Nov 1, 2023
6b9e104
Fixed #669 Generation models from content schema allof
Nov 10, 2023
c191faf
Fixed #665 generation putIfAbsent for response from content schema
Nov 10, 2023
f37ea45
Merge branch 'master' into development
Nov 10, 2023
313cea9
Fixed generation of nullable and required properties
Nov 10, 2023
cc170ce
Merge branch 'master' into development
Nov 10, 2023
74bd541
Fixed tests
Nov 10, 2023
07421ca
Fixed some stuff related to nullable properties
Nov 10, 2023
d19f042
Updated changelog and pubspec
Nov 10, 2023
82db0eb
Formatted code
Nov 10, 2023
ecb17c4
Merge branch 'master' into development
Nov 10, 2023
7719589
Formatted code
Nov 10, 2023
d277030
Fixed tests
Nov 10, 2023
73db345
Fixed generation of some enums inside classes
Nov 17, 2023
fb2242c
Implemented support of exploded parameters
Nov 17, 2023
649e129
Merge branch 'master' into development
Nov 17, 2023
8c1fe97
Pushed constants file
Nov 17, 2023
48dfe4a
Fixed generation of allOf for request bodies
Nov 22, 2023
15c58ba
Merge branch 'master' into development
Nov 22, 2023
1158b4b
Implemented overriden_models functionality
Nov 22, 2023
0201193
Improved overriden models logic
Nov 22, 2023
cbcc034
Fixed tests
Nov 22, 2023
1a20bf3
Updated pubspec and changelog
Nov 22, 2023
2197841
Merge branch 'master' into development
Nov 22, 2023
70a6665
Removed support of exploded parameters
Nov 22, 2023
a1fb0e5
Fixed generation of patameters contains keywords
Dec 1, 2023
29a517c
Updated pubspec and changelog
Dec 1, 2023
86336bc
Merge branch 'master' into development
Dec 1, 2023
0e1e110
Fixed generation of nullable and not nullable fields
Dec 1, 2023
285fdc3
Merge branch 'master' into development
Dec 1, 2023
41b4fbd
Fixed generation of list parameters with specific names
Dec 1, 2023
b050bf6
Merge branch 'master' into development
Dec 1, 2023
d103118
Fixed formurlencoded requests
Dec 1, 2023
6a433b7
Revert "Fixed formurlencoded requests"
Dec 1, 2023
0644fc2
Merge branch 'master' into development
Dec 8, 2023
a472fa4
Updated changelog and pubspec
Dec 8, 2023
8e7a9a1
formatted code
Dec 8, 2023
d464b68
Fixed version in changelog
Dec 8, 2023
f07c5c5
Added generation of writeOnly and readOnly fields as nullable and no …
Dec 15, 2023
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 2.13.3

* Some fixes and improvements

# 2.13.2

* Fixed generation key word parameter names ([#685](https://github.com/epam-cross-platform-lab/swagger-dart-code-generator/issues/685))
Expand Down
30 changes: 14 additions & 16 deletions lib/src/code_generators/swagger_models_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,7 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {
final includeIfNullString = generateIncludeIfNullString();

if (typeName != kDynamic &&
(prop.isNullable == true ||
options.nullableModels.contains(typeName))) {
(prop.shouldBeNullable || options.nullableModels.contains(typeName))) {
typeName = typeName.makeNullable();
}

Expand All @@ -488,6 +487,7 @@ abstract class SwaggerModelsGenerator extends SwaggerGeneratorBase {

final jsonKeyContent =
"@JsonKey(name: '$propertyKey'$includeIfNullString$dateToJsonValue${unknownEnumValue.jsonKey})\n";

return '\t$jsonKeyContent\tfinal $typeName ${generateFieldName(propertyName)};${unknownEnumValue.fromJson}';
}

Expand Down Expand Up @@ -598,7 +598,7 @@ static $returnType $fromJsonFunction($valueType? value) => $enumNameCamelCase$fr
String propertyKey,
SwaggerSchema prop,
) {
return prop.isNullable == true ||
return prop.shouldBeNullable ||
options.nullableModels.contains(className) ||
!requiredProperties.contains(propertyKey);
}
Expand Down Expand Up @@ -667,8 +667,7 @@ static $returnType $fromJsonFunction($valueType? value) => $enumNameCamelCase$fr
final jsonKeyContent =
"@JsonKey(name: '${_validatePropertyKey(propertyKey)}'$includeIfNullString${unknownEnumValue.jsonKey}$dateToJsonValue)\n";

if ((prop.isNullable == true ||
options.nullableModels.contains(className)) &&
if ((prop.shouldBeNullable || options.nullableModels.contains(className)) &&
!requiredProperties.contains(propertyKey)) {
typeName = typeName.makeNullable();
}
Expand Down Expand Up @@ -734,7 +733,7 @@ static $returnType $fromJsonFunction($valueType? value) => $enumNameCamelCase$fr
final jsonKeyContent =
"@JsonKey(name: '${_validatePropertyKey(propertyKey)}'$includeIfNullString${unknownEnumValue.jsonKey})\n";

if (prop.isNullable == true ||
if (prop.shouldBeNullable ||
options.nullableModels.contains(className) ||
!requiredProperties.contains(propertyKey)) {
typeName = typeName.makeNullable();
Expand Down Expand Up @@ -782,7 +781,7 @@ static $returnType $fromJsonFunction($valueType? value) => $enumNameCamelCase$fr
}

final isPropertyNullable = options.nullableModels.contains(className) ||
refSchema?.isNullable == true ||
refSchema?.shouldBeNullable == true ||
!requiredProperties.contains(propertyKey);

final unknownEnumValue = generateEnumValue(
Expand All @@ -805,15 +804,14 @@ static $returnType $fromJsonFunction($valueType? value) => $enumNameCamelCase$fr
final jsonKeyContent =
"@JsonKey(name: '${_validatePropertyKey(propertyKey)}'$includeIfNullString${unknownEnumValue.jsonKey})\n";

if ((prop.isNullable == true ||
options.nullableModels.contains(className)) &&
if ((prop.shouldBeNullable || options.nullableModels.contains(className)) &&
!requiredProperties.contains(propertyKey)) {
typeName = typeName.makeNullable();
}

final propertySchema = allClasses[prop.ref.getUnformattedRef()];

if (propertySchema?.isNullable == true ||
if (propertySchema?.shouldBeNullable == true ||
isPropertyNullable ||
options.nullableModels.contains(className)) {
typeName = typeName.makeNullable();
Expand Down Expand Up @@ -855,8 +853,7 @@ static $returnType $fromJsonFunction($valueType? value) => $enumNameCamelCase$fr

var enumPropertyName = className.capitalize + key.capitalize;

if ((prop.isNullable == true ||
options.nullableModels.contains(className)) &&
if ((prop.shouldBeNullable || options.nullableModels.contains(className)) &&
!requiredProperties.contains(propertyKey)) {
enumPropertyName = enumPropertyName.makeNullable();
}
Expand Down Expand Up @@ -1006,7 +1003,7 @@ static $returnType $fromJsonFunction($valueType? value) => $enumNameCamelCase$fr

var listPropertyName = 'List<$typeName>';

if (prop.isNullable == true ||
if (prop.shouldBeNullable ||
options.nullableModels.contains(className) ||
!requiredProperties.contains(propertyKey)) {
listPropertyName = listPropertyName.makeNullable();
Expand Down Expand Up @@ -1079,7 +1076,7 @@ static $returnType $fromJsonFunction($valueType? value) => $enumNameCamelCase$fr
jsonKeyContent += ')\n';
}

if (prop.isNullable == true ||
if (prop.shouldBeNullable ||
options.nullableModels.contains(className) ||
!requiredProperties.contains(propertyKey)) {
typeName = typeName.makeNullable();
Expand Down Expand Up @@ -1341,10 +1338,11 @@ static $returnType $fromJsonFunction($valueType? value) => $enumNameCamelCase$fr
propertyNames.add(fieldName);

final isNullableProperty = options.nullableModels.contains(className) ||
value.isNullable == true ||
value.shouldBeNullable ||
!requiredProperties.contains(key);

final isRequiredProperty = requiredProperties.contains(key);
final isRequiredProperty =
!value.shouldBeNullable && requiredProperties.contains(key);

if (isRequiredProperty || !isNullableProperty) {
results += '\t\t$kRequired this.$fieldName,\n';
Expand Down
3 changes: 1 addition & 2 deletions lib/src/code_generators/swagger_requests_generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,7 @@ class SwaggerRequestsGenerator extends SwaggerGeneratorBase {
});

final isUrlencoded = parameters.any((p) =>
p.type != null &&
p.type!.symbol == options.urlencodedFileType);
p.type != null && p.type!.symbol == options.urlencodedFileType);

var annotationPath = path;
if (options.addBasePathToRequests) {
Expand Down
10 changes: 10 additions & 0 deletions lib/src/swagger_models/responses/swagger_schema.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,16 @@ class SwaggerSchema {
this.hasAdditionalProperties = false,
this.msEnum,
this.title = '',
this.readOnly = false,
this.writeOnly = false,
});

@JsonKey(name: 'readOnly', defaultValue: false)
bool readOnly;

@JsonKey(name: 'writeOnly', defaultValue: false)
bool writeOnly;

@JsonKey(name: 'type', defaultValue: '')
String type;

Expand Down Expand Up @@ -83,6 +91,8 @@ class SwaggerSchema {
@JsonKey(name: 'nullable', defaultValue: null)
bool? isNullable;

bool get shouldBeNullable => isNullable == true || readOnly || writeOnly;

@JsonKey(name: 'schema')
SwaggerSchema? schema;

Expand Down
4 changes: 4 additions & 0 deletions lib/src/swagger_models/responses/swagger_schema.g2.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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.13.2
version: 2.13.3

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