Closed wqz-leo closed 5 years ago
This PR will add ability to encode objects which are assigned to dictionary value. For example, both Event and Item are generated by SwagGen:
struct Event: Codable { var detail: [String: Any]? } struct Item: Codable { var id: String var title: String } let item = Item(id: "123", title: "Game of Thrones") let event = Event(detail: ["item": item])
Then calling JSONEncoder().encode(event) will throw invalidValue error.
JSONEncoder().encode(event)
invalidValue
To get above example work, the Event can only be constructed like this:
let item: [String: Any] = ["id": "123", "title": "Game of Thrones"] let event = Event(detail: item)
Thanks Leo! Sorry for the delay. Gonna be working on this repo again, as I'm updating it to swagger 3.0. I'll do a final release with this in it
This PR will add ability to encode objects which are assigned to dictionary value. For example, both Event and Item are generated by SwagGen:
Then calling
JSONEncoder().encode(event)
will throwinvalidValue
error.To get above example work, the Event can only be constructed like this: