// This file has been generated by Specta. DO NOT EDIT.
import Foundation
/// A comprehensive example demonstrating multi-line comment support
///
/// This example shows how Specta Swift handles complex documentation
/// including:
/// - Multi-line type documentation
/// - Bullet points and formatting
/// - Complex technical descriptions
///
/// The generated Swift code will have properly formatted doc comments
/// that are compatible with Swift's documentation system.
public enum ApiResponse<T> {
case success(ApiResponseSuccessData)
case error(ApiResponseErrorData)
case loading(ApiResponseLoadingData)
}
public struct ApiResponseSuccessData: Codable {
public let data: T
public let status: UInt16
public let headers: [(String, String)]?
}
public struct ApiResponseErrorData: Codable {
public let message: String
public let code: UInt32
public let details: String?
}
public struct ApiResponseLoadingData: Codable {
public let progress: Float
public let estimatedTime: UInt64?
private enum CodingKeys: String, CodingKey {
case progress = "progress"
case estimatedTime = "estimated_time"
}
}
// MARK: - ApiResponse Codable Implementation
extension ApiResponse: Codable {
private enum CodingKeys: String, CodingKey {
case success = "Success"
case error = "Error"
case loading = "Loading"
}
public init(from decoder: Decoder) throws {
let container = try decoder.container(keyedBy: CodingKeys.self)
if container.allKeys.count != 1 {
throw DecodingError.dataCorrupted(
DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Invalid number of keys found, expected one.")
)
}
let key = container.allKeys.first!
switch key {
case .success:
let data = try container.decode(ApiResponseSuccessData.self, forKey: .success)
self = .success(data)
case .error:
let data = try container.decode(ApiResponseErrorData.self, forKey: .error)
self = .error(data)
case .loading:
let data = try container.decode(ApiResponseLoadingData.self, forKey: .loading)
self = .loading(data)
}
}
public func encode(to encoder: Encoder) throws {
var container = encoder.container(keyedBy: CodingKeys.self)
switch self {
case .success(let data):
try container.encode(data, forKey: .success)
case .error(let data):
try container.encode(data, forKey: .error)
case .loading(let data):
try container.encode(data, forKey: .loading)
}
}
}
/// A user account in the system
///
/// This struct represents a complete user account with all necessary
/// information for authentication, authorization, and personalization.
///
/// # Security Notes
/// - The `password_hash` field should never be logged or exposed
/// - The `api_key` is sensitive and should be treated as a secret
/// - All timestamps are in UTC
public struct User: Codable {
public let id: UInt32
public let username: String
public let email: String
public let isActive: Bool
public let createdAt: String
public let lastLogin: String?
private enum CodingKeys: String, CodingKey {
case id = "id"
case username = "username"
case email = "email"
case isActive = "is_active"
case createdAt = "created_at"
case lastLogin = "last_login"
}
}