yonaskolb / SwagGen

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

Fix a potential crash when constructing a URLRequest #268

Closed marcelvoss closed 3 years ago

marcelvoss commented 3 years ago

Hi there,

we have discovered a crash in our Firebase integration that comes from APIClient.swift:L221 (a force unwrap of a URL) within multiple generated clients in our project, while we don't have incorrect/missing URLs being passed in here. Said crashes are occurring incredibly sporadic and only once or twice in a month (maybe due to freak conditions). Probably still the right call to avoid crashing.

This does a bit of a clean up by using best practices (such as non-explicit initializers as well as avoiding force unwrapping and throwing instead).

We're currently using this very same template.

marcelvoss commented 3 years ago

@yonaskolb Interestingly it doesn't happen in a reproducible way (I manually went through all clients and definitions and all seem valid). I would blame crashing on freak conditions. Thanks for the review!

Added a changelog entry.