yonaskolb / SwagGen

OpenAPI/Swagger 3.0 Parser and Swift code generator
MIT License
626 stars 146 forks source link

"cyclic metadata dependency detected, aborting" on Release builds with Xcode 11.2 #202

Open Przytua opened 4 years ago

Przytua commented 4 years ago

This code crashes on Release builds with Xcode 11.2:

extension APIResponse {
    public func asAny() -> APIResponse<AnyResponseValue> {
        return APIResponse<AnyResponseValue>(request: request.asAny(), result: result.map { $0.asAny() }, urlRequest: urlRequest, urlResponse: urlResponse, data: data, timeline: timeline)
    }
}

Exactly it crashes inside the result.map { $0.asAny() } with cyclic metadata dependency

I've looked a bit on similar issues (outside of SwagGen) and this cyclic metadata dependency bug mostly occurs, when there are generic types nested in other types (especially with multiple levels of nesting). Maybe you could consider not using nested types, but rather prefixes on type names, and flat types structure?