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

This commit is contained in:
Jason Rasmussen 2024-09-25 12:05:03 -04:00 committed by GitHub
parent 8d515adac5
commit 005528ab5e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 162 additions and 18 deletions
mobile/openapi/lib/api

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