Skip to content

Commit 8fded5c

Browse files
authored
Fix npe when unwrapping optional. (OpenAPITools#12882)
1 parent f176716 commit 8fded5c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/openapi-generator/src/main/resources/swift5/libraries/urlsession/URLSessionImplementations.mustache

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ private var credentialStore = SynchronizedDictionary<Int, URLCredential>()
353353
default:
354354

355355
guard let data = data, !data.isEmpty else {
356-
if T.self is ExpressibleByNilLiteral.Type {
357-
completion(.success(Response(response: httpResponse, body: Optional<T>.none as! T)))
356+
if let E = T.self as? ExpressibleByNilLiteral.Type {
357+
completion(.success(Response(response: httpResponse, body: E.init(nilLiteral: ()) as! T)))
358358
} else {
359359
completion(.failure(ErrorResponse.error(httpResponse.statusCode, nil, response, DecodableRequestBuilderError.emptyDataResponse)))
360360
}

0 commit comments

Comments
 (0)