forked from loafle/openapi-generator-original
Fix npe when unwrapping optional. (#12882)
This commit is contained in:
parent
f176716a61
commit
8fded5c47e
@ -353,8 +353,8 @@ private var credentialStore = SynchronizedDictionary<Int, URLCredential>()
|
|||||||
default:
|
default:
|
||||||
|
|
||||||
guard let data = data, !data.isEmpty else {
|
guard let data = data, !data.isEmpty else {
|
||||||
if T.self is ExpressibleByNilLiteral.Type {
|
if let E = T.self as? ExpressibleByNilLiteral.Type {
|
||||||
completion(.success(Response(response: httpResponse, body: Optional<T>.none as! T)))
|
completion(.success(Response(response: httpResponse, body: E.init(nilLiteral: ()) as! T)))
|
||||||
} else {
|
} else {
|
||||||
completion(.failure(ErrorResponse.error(httpResponse.statusCode, nil, response, DecodableRequestBuilderError.emptyDataResponse)))
|
completion(.failure(ErrorResponse.error(httpResponse.statusCode, nil, response, DecodableRequestBuilderError.emptyDataResponse)))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user