I have 2 protocols, Filters
and Parameters
, both of which extend Encodable
protocol Filters: Encodable {
var page: Int { get }
}
protocol Parameters: Encodable {
var type: String { get }
var filters: Filters { get }
}
I create structs conforming to these protocols, thusly…
struct BankAccountFilters: Filters {
var page: Int
var isWithdrawal: Bool
}
struct BankAccountParamters: Parameters {
let type: String = "Bank"
var filters: Filters
}
let baf = BankAccountFilters(page: 1, isWithdrawal: true)
let bap = BankAccountParamters(filters: baf)
Which fails because…
error: type 'BankAccountParamters' does not conform to protocol 'Encodable'
note: cannot automatically synthesize 'Encodable' because 'Filters' does not conform to 'Encodable'
Filters
clearly does conform to Encodable
(at least it seems that way to me). Is there a way around this?