yonaskolb / SwagGen

OpenAPI/Swagger 3.0 Parser and Swift code generator

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integers contained in a [String: Any] dictionary are inferred to be booleans instead of integers

marcelvoss opened this issue · comments

Hi there 👋,

first of all, thanks for building this generator. It is a pleasure to use.

While debugging, I stumbled upon a problem with the way freeform dictionary fields (such as[String: Any]) are being encoded. Where 0 and 1 can be valid integer fields, they are being encoded as booleans. Looking at the implementation of AnyCodable.swift, it seems like in these cases Bool is the first (and best match), although not entirely correct. I know it is possible to cast and type check booleans using CFBooleanRef within NSJSONSerialization and then encode/decode correctly. I'm not sure the same trick also applies to Codable-based serializations though.

ezoic increase your site revenue