mattpolzin / OpenAPIKit

Codable Swift OpenAPI implementation.
MIT License
276 stars 35 forks source link

oneOf nullability propagates too well #368

Closed mattpolzin closed 3 months ago

mattpolzin commented 3 months ago

Currently, I propagate nullability up from subschemas for oneOf/anyOf/allOf. This logic should be correct already for the latter two, but oneOf is a true enumeration of options so I should not weaken a guarantee that e.g. only one of the options is nullable unless one of the options is exactly the .null() schema. That small tweak to the decoding logic for oneOf should be considered a bug fix.

mattpolzin commented 3 months ago

Upon further thinking, there was no problem with the current behavior. oneOf may map semantically well to an enumeration but since it lacks its own identity structurally there's no point in making a distinction between "this thing must not be null because it is either (a) a string or (b) a nullable integer" vs. "this thing can be null or a string or an integer."