1
0
mirror of https://github.com/immich-app/immich.git synced 2025-08-09 23:17:29 +02:00

fix(server): http error parsing on endpoints without a default response (#12927)

This commit is contained in:
Jason Rasmussen
2024-09-25 12:05:03 -04:00
committed by GitHub
parent 8d515adac5
commit 005528ab5e
13 changed files with 162 additions and 18 deletions

View File

@ -260,6 +260,7 @@ part 'model/tag_update_dto.dart';
part 'model/tag_upsert_dto.dart';
part 'model/tags_response.dart';
part 'model/tags_update.dart';
part 'model/test_email_response_dto.dart';
part 'model/time_bucket_response_dto.dart';
part 'model/time_bucket_size.dart';
part 'model/tone_mapping.dart';

View File

@ -48,10 +48,18 @@ class NotificationsApi {
/// Parameters:
///
/// * [SystemConfigSmtpDto] systemConfigSmtpDto (required):
Future<void> sendTestEmail(SystemConfigSmtpDto systemConfigSmtpDto,) async {
Future<TestEmailResponseDto?> sendTestEmail(SystemConfigSmtpDto systemConfigSmtpDto,) async {
final response = await sendTestEmailWithHttpInfo(systemConfigSmtpDto,);
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'TestEmailResponseDto',) as TestEmailResponseDto;
}
return null;
}
}

View File

@ -574,6 +574,8 @@ class ApiClient {
return TagsResponse.fromJson(value);
case 'TagsUpdate':
return TagsUpdate.fromJson(value);
case 'TestEmailResponseDto':
return TestEmailResponseDto.fromJson(value);
case 'TimeBucketResponseDto':
return TimeBucketResponseDto.fromJson(value);
case 'TimeBucketSize':

View File

@ -0,0 +1,99 @@
//
// AUTO-GENERATED FILE, DO NOT MODIFY!
//
// @dart=2.18
// ignore_for_file: unused_element, unused_import
// ignore_for_file: always_put_required_named_parameters_first
// ignore_for_file: constant_identifier_names
// ignore_for_file: lines_longer_than_80_chars
part of openapi.api;
class TestEmailResponseDto {
/// Returns a new [TestEmailResponseDto] instance.
TestEmailResponseDto({
required this.messageId,
});
String messageId;
@override
bool operator ==(Object other) => identical(this, other) || other is TestEmailResponseDto &&
other.messageId == messageId;
@override
int get hashCode =>
// ignore: unnecessary_parenthesis
(messageId.hashCode);
@override
String toString() => 'TestEmailResponseDto[messageId=$messageId]';
Map<String, dynamic> toJson() {
final json = <String, dynamic>{};
json[r'messageId'] = this.messageId;
return json;
}
/// Returns a new [TestEmailResponseDto] instance and imports its values from
/// [value] if it's a [Map], null otherwise.
// ignore: prefer_constructors_over_static_methods
static TestEmailResponseDto? fromJson(dynamic value) {
upgradeDto(value, "TestEmailResponseDto");
if (value is Map) {
final json = value.cast<String, dynamic>();
return TestEmailResponseDto(
messageId: mapValueOfType<String>(json, r'messageId')!,
);
}
return null;
}
static List<TestEmailResponseDto> listFromJson(dynamic json, {bool growable = false,}) {
final result = <TestEmailResponseDto>[];
if (json is List && json.isNotEmpty) {
for (final row in json) {
final value = TestEmailResponseDto.fromJson(row);
if (value != null) {
result.add(value);
}
}
}
return result.toList(growable: growable);
}
static Map<String, TestEmailResponseDto> mapFromJson(dynamic json) {
final map = <String, TestEmailResponseDto>{};
if (json is Map && json.isNotEmpty) {
json = json.cast<String, dynamic>(); // ignore: parameter_assignments
for (final entry in json.entries) {
final value = TestEmailResponseDto.fromJson(entry.value);
if (value != null) {
map[entry.key] = value;
}
}
}
return map;
}
// maps a json object with a list of TestEmailResponseDto-objects as value to a dart map
static Map<String, List<TestEmailResponseDto>> mapListFromJson(dynamic json, {bool growable = false,}) {
final map = <String, List<TestEmailResponseDto>>{};
if (json is Map && json.isNotEmpty) {
// ignore: parameter_assignments
json = json.cast<String, dynamic>();
for (final entry in json.entries) {
map[entry.key] = TestEmailResponseDto.listFromJson(entry.value, growable: growable,);
}
}
return map;
}
/// The list of required keys that must be present in a JSON.
static const requiredKeys = <String>{
'messageId',
};
}