From f156280d98ecf91134ccd15ea791a0644187d55a Mon Sep 17 00:00:00 2001 From: Uladzimir_Paliukhovich Date: Fri, 22 Sep 2023 13:08:25 +0300 Subject: [PATCH] Version/2.11.6 (#655) * 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 --------- Co-authored-by: Uladzimir Paliukhovich Co-authored-by: Romain --- lib/src/code_generators/constants.dart | 3 +++ lib/src/code_generators/swagger_requests_generator.dart | 8 ++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/src/code_generators/constants.dart b/lib/src/code_generators/constants.dart index 35690b25..3b76d788 100644 --- a/lib/src/code_generators/constants.dart +++ b/lib/src/code_generators/constants.dart @@ -58,6 +58,7 @@ const kPath = 'path'; const kOptionalBody = 'optionalBody'; const kFormData = 'formData'; const kMultipart = 'multipart'; +const kDateTimeFormat = 'date-time'; const kDefaultBodyParameter = 'Object'; const kField = 'Field'; @@ -90,6 +91,8 @@ const kBody = 'body'; const kPartFile = 'partFile'; const kPart = 'part'; +const kDateTimeType = 'DateTime'; + const kDynamic = 'dynamic'; const supportedRequestTypes = ['get', 'post', 'put', 'delete', 'head', 'patch']; diff --git a/lib/src/code_generators/swagger_requests_generator.dart b/lib/src/code_generators/swagger_requests_generator.dart index 59faf38c..aaa502be 100644 --- a/lib/src/code_generators/swagger_requests_generator.dart +++ b/lib/src/code_generators/swagger_requests_generator.dart @@ -657,6 +657,10 @@ class SwaggerRequestsGenerator extends SwaggerGeneratorBase { } if (parameter.schema?.type.isNotEmpty == true) { + if (parameter.schema?.format == kDateTimeFormat) { + return kDateTimeType; + } + return _mapParameterName(parameter.schema!.type, format, modelPostfix); } @@ -1216,8 +1220,8 @@ class SwaggerRequestsGenerator extends SwaggerGeneratorBase { final contentSchemaType = content.schema?.type ?? ''; if (contentSchemaType.isNotEmpty == true) { if (contentSchemaType == 'string' && - content.schema?.format == 'date-time') { - return 'DateTime'; + content.schema?.format == kDateTimeFormat) { + return kDateTimeType; } return kBasicTypesMap[contentSchemaType]; }