Is your feature request related to a problem? Please describe.
When the server-side code changes by adding additional values for an enum
Unfortunately, We don't have control over the enums and cannot prevent the enums from changing upstream
e.g.
public enum SizeType: String, Codable, CaseIterable {
case _none = "None"
case erf = "Erf"
}
changes to
public enum SizeType: String, Codable, CaseIterable {
case _none = "None"
case erf = "Erf"
case floor = "Floor"
case grossLettableSqM = "GrossLettableSqM"
}
The code throws an error when floor or grossLettableSqM is returned but should just default to nil provided that the variable is nullable
Describe the solution you'd like
Instead of throwing an error, the value should default to nil if the variable is nullable.
e.g.
public var sizeType: SizeType?
can be changed to
private var __sizeType: String?
public var sizeType: SizeType? {
get {
if let __sizeType = __sizeType, let response = SizeType(rawValue: __sizeType) {
return response
}
return nil
}
set {
__sizeType = newValue?.rawValue
}
}
or a similar chack can be added in the constructor that will require less code.
Describe alternatives you've considered
The only other way at the moment is to manually go through all the models and change the enums by hand every time we update.
Additional context
Is your feature request related to a problem? Please describe.
When the server-side code changes by adding additional values for an enum
Unfortunately, We don't have control over the enums and cannot prevent the enums from changing upstream
e.g.
changes to
The code throws an error when floor or grossLettableSqM is returned but should just default to nil provided that the variable is nullable
Describe the solution you'd like
Instead of throwing an error, the value should default to nil if the variable is nullable.
e.g.
public var sizeType: SizeType?
can be changed to
or a similar chack can be added in the constructor that will require less code.
Describe alternatives you've considered
The only other way at the moment is to manually go through all the models and change the enums by hand every time we update.
Additional context