Essentially, I'm trying to work out the absolute bare minimum mapping from an OpenAPI YAML file to a Swift file. I was trying to fix a bunch of issues I had with various generated interfaces, including, to my mind, the over-complicated openapi-generator's swift5 output.
So far, I have a demonstration project openapi-swift which produces an enum/struct pair that describes the endpoint parameters and types. Can anyone improve on this? Ideally, down to a single enum or struct?
Generated
enum PetStore {
enum Operation {
case createPets
}
struct Endpoint<Response> {
static func createPets(_ body: Pet) -> Endpoint<PetId> { ... }
}
}
User
struct Executor {
func execute<T>(endpoint: PetStore.Endpoint<T>) async throws -> T
}
let petId = try await Executor().execute(endpoint: .createPets(pet))