Ayman Bagabas 3894aa4759
[swift5] Add useSPMFileStructure (#9074)
* [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
2021-04-22 00:43:33 +08:00

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