forked from loafle/openapi-generator-original
* [swift5] Add useSPMFileStructure Signed-off-by: Ayman Bagabas <ayman.bagabas@gmail.com> * [swift5] Add swiftPackagePath Prioritize swiftPackagePath over useSPMFileStructure * [swift5] Add cli options and update docs * [swift5] Fix tests * [swift5] Update XcodeGen source path * [swift5] Update samples and docs Add useSPMFileStructure to URLSession library
55 lines
1.3 KiB
Swift
55 lines
1.3 KiB
Swift
// Models.swift
|
|
//
|
|
// Generated by openapi-generator
|
|
// https://openapi-generator.tech
|
|
//
|
|
|
|
import Foundation
|
|
|
|
protocol JSONEncodable {
|
|
func encodeToJSON() -> Any
|
|
}
|
|
|
|
public enum ErrorResponse: Error {
|
|
case error(Int, Data?, URLResponse?, Error)
|
|
}
|
|
|
|
public enum DownloadException: Error {
|
|
case responseDataMissing
|
|
case responseFailed
|
|
case requestMissing
|
|
case requestMissingPath
|
|
case requestMissingURL
|
|
}
|
|
|
|
public enum DecodableRequestBuilderError: Error {
|
|
case emptyDataResponse
|
|
case nilHTTPResponse
|
|
case unsuccessfulHTTPStatusCode
|
|
case jsonDecoding(DecodingError)
|
|
case generalError(Error)
|
|
}
|
|
|
|
open class Response<T> {
|
|
public let statusCode: Int
|
|
public let header: [String: String]
|
|
public let body: T?
|
|
|
|
public init(statusCode: Int, header: [String: String], body: T?) {
|
|
self.statusCode = statusCode
|
|
self.header = header
|
|
self.body = body
|
|
}
|
|
|
|
public convenience init(response: HTTPURLResponse, body: T?) {
|
|
let rawHeader = response.allHeaderFields
|
|
var header = [String: String]()
|
|
for (key, value) in rawHeader {
|
|
if let key = key.base as? String, let value = value as? String {
|
|
header[key] = value
|
|
}
|
|
}
|
|
self.init(statusCode: response.statusCode, header: header, body: body)
|
|
}
|
|
}
|