#![allow(clippy::unwrap_used, dead_code, missing_docs)]
use specta::{Type, Types};
use specta_swift::Swift;
#[derive(Type)]
enum ApiResponse<T> {
Success {
data: T,
status: u16,
headers: Option<Vec<(String, String)>>,
},
Error {
message: String,
code: u32,
details: Option<String>,
},
Loading {
progress: f32,
estimated_time: Option<u64>,
},
}
#[derive(Type)]
struct User {
id: u32,
username: String,
email: String,
is_active: bool,
created_at: String,
last_login: Option<String>,
}
fn main() {
let types = Types::default()
.register::<ApiResponse<String>>()
.register::<User>();
let swift = Swift::default();
let output = swift.export(&types, specta_serde::Format).unwrap();
println!(
"Generated Swift code with comprehensive comments:\n{}",
output
);
swift
.export_to(
"./examples/generated/CommentsExample.swift",
&types,
specta_serde::Format,
)
.unwrap();
println!("\nComments example written to CommentsExample.swift");
}