yonaskolb / SwagGen

OpenAPI/Swagger 3.0 Parser and Swift code generator
MIT License
625 stars 147 forks source link

Making Enum conform to `Equatable` and `CaseIterable` #124

Closed mackoj closed 5 years ago

mackoj commented 5 years ago

Remove old cases implementation and replacing it with CaseIterable

yonaskolb commented 5 years ago

Thanks @mackoj. Could you run the tests so that the fixtures get updated, and commit them. That's why the tests are failing. Could you also add a changelog entry

mackoj commented 5 years ago

Ok, I will do it today.

mackoj commented 5 years ago

It actually breaks Swift 4.1 support because CaseIterable has been added in Swift 4.2

yonaskolb commented 5 years ago

Perhaps a cleaner way would be to just define a custom CaseIterable below Swift 4.2, perhaps in Coding.swift

#if swift(<4.2)
public protocol CaseIterable {
    static let allCases: [Self] { get }
}
#endif
yonaskolb commented 5 years ago

In the interest of time I've just opened another PR here https://github.com/yonaskolb/SwagGen/pull/133. I opted to simply drop Swift 4.1 support