From 5b5ca8ba0bf864941325432ac9b9949bd88fdcaf Mon Sep 17 00:00:00 2001 From: Uladzimir_Paliukhovich Date: Fri, 15 Dec 2023 15:00:33 +0300 Subject: [PATCH] Development (#696) * 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 #524 * Fixed #598 Generation of query enum parameters * Fixed conflicts * Fixed some issues in swaggers * Updated changelog and pubspec * Fix #583, #637, #619 and update readme (#638) * fix #583 and update readme * fix #637 * fix #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 #669 Generation models from content schema allof * Fixed #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 d103118975e7f66ec2cbf10a1f9d28ef935be6eb. * 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 --------- Co-authored-by: Uladzimir Paliukhovich Co-authored-by: Romain --- lib/src/code_generators/swagger_models_generator.dart | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/src/code_generators/swagger_models_generator.dart b/lib/src/code_generators/swagger_models_generator.dart index 24f385b6..6dce5ec8 100644 --- a/lib/src/code_generators/swagger_models_generator.dart +++ b/lib/src/code_generators/swagger_models_generator.dart @@ -667,8 +667,9 @@ static $returnType $fromJsonFunction($valueType? value) => $enumNameCamelCase$fr final jsonKeyContent = "@JsonKey(name: '${_validatePropertyKey(propertyKey)}'$includeIfNullString${unknownEnumValue.jsonKey}$dateToJsonValue)\n"; - if ((prop.shouldBeNullable || options.nullableModels.contains(className)) && - !requiredProperties.contains(propertyKey)) { + if (prop.shouldBeNullable || + (options.nullableModels.contains(className) && + !requiredProperties.contains(propertyKey))) { typeName = typeName.makeNullable(); } @@ -780,7 +781,8 @@ static $returnType $fromJsonFunction($valueType? value) => $enumNameCamelCase$fr typeName += options.modelPostfix; } - final isPropertyNullable = options.nullableModels.contains(className) || + final isPropertyNullable = prop.shouldBeNullable || + options.nullableModels.contains(className) || refSchema?.shouldBeNullable == true || !requiredProperties.contains(propertyKey); @@ -804,7 +806,8 @@ static $returnType $fromJsonFunction($valueType? value) => $enumNameCamelCase$fr final jsonKeyContent = "@JsonKey(name: '${_validatePropertyKey(propertyKey)}'$includeIfNullString${unknownEnumValue.jsonKey})\n"; - if ((prop.shouldBeNullable || options.nullableModels.contains(className)) && + if (prop.shouldBeNullable || + options.nullableModels.contains(className) || !requiredProperties.contains(propertyKey)) { typeName = typeName.makeNullable(); }