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]; }