yonaskolb / SwagGen

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

When enum case is unrecognised and `enumUndecodableCase`=true, how can I know the value? #320

Open Ricardo1980 opened 1 year ago

Ricardo1980 commented 1 year ago

Hello,

When using the option enumUndecodableCase, we will use the unknown case when a value is not recognised by the data mapping generated code. https://github.com/yonaskolb/SwagGen/pull/141 https://github.com/yonaskolb/SwagGen/issues/135

How can I know the value that was not recognised? Is there any way?

Right now we have:

struct PaymentMethod {
    enum Type {
        case creditCard
        case unknown
    }

    let type: Type
}

Would be possible to have something similar to this?

struct PaymentMethod: String {
    enum Type {
        case creditCard
        case unknown(_ value: String)
    }

    let type: Type
}

Thanks a lot.