Something went wrong. Try again.
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243import AppAPIimport Foundationimport OpenAPIRuntime
struct APIImplementation: APIProtocol { let todoRepository: TodoRepository func getHello(_ input: AppAPI.Operations.GetHello.Input) async throws -> AppAPI.Operations.GetHello.Output { return .ok(.init(body: .plainText("Hello!"))) }
func createTodo(_ input: Operations.CreateTodo.Input) async throws -> Operations.CreateTodo.Output { guard case .json(let p) = input.body else { return .badRequest(.init(body: .plainText("bad request"))) }
guard p.title != nil else { return .badRequest(.init(body: .plainText("bad request"))) }
let todo = try await todoRepository.create( title: p.title!, order: p.order, urlPrefix: "http://localhost:8080" )
return .ok( .init( body: .json( .init( id: todo.id.uuidString, title: todo.title, order: todo.order, url: todo.url, completed: todo.completed ) ) ) ) }}