forked from loafle/openapi-generator-original
55 lines
1.2 KiB
Swift
55 lines
1.2 KiB
Swift
// APIs.swift
|
|
//
|
|
// Generated by openapi-generator
|
|
// https://openapi-generator.tech
|
|
//
|
|
|
|
import Foundation
|
|
|
|
public struct RequestBuilder<Response> {
|
|
public let endpoint: String
|
|
public let method: String
|
|
public let parameters: [Parameters]
|
|
public let headers: [String: String]
|
|
|
|
public init(endpoint: String, method: String, parameters: [Parameters] = [], headers: [String: String] = [:]) {
|
|
self.endpoint = endpoint
|
|
self.method = method
|
|
self.parameters = parameters
|
|
self.headers = headers
|
|
}
|
|
}
|
|
|
|
public enum Parameters {
|
|
case query([String: Any?])
|
|
case form([String: String?])
|
|
case json(AnyEncodable)
|
|
|
|
public init(_ raw: [String: Any?]) {
|
|
self = .query(raw)
|
|
}
|
|
|
|
public init(_ raw: [String: String?]) {
|
|
self = .form(raw)
|
|
}
|
|
|
|
public init<T: Encodable>(_ raw: T) {
|
|
self = .json(AnyEncodable(raw))
|
|
}
|
|
}
|
|
|
|
public struct AnyEncodable: Encodable {
|
|
var encode: (Encoder) throws -> Void
|
|
|
|
init(_ encodable: Encodable) {
|
|
func encode(to encoder: Encoder) throws {
|
|
try encodable.encode(to: encoder)
|
|
}
|
|
self.encode = encode
|
|
}
|
|
|
|
public func encode(to encoder: Encoder) throws {
|
|
try encode(encoder)
|
|
}
|
|
}
|