You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
codegen fails to produce anyOf/oneOf with a null type #817
ideally it should produce an optional. But an enum would also work.
Environment
swift 6.2
Xcode 26.0 beta 6
Additional information
The only workaround I've found is to do something like this, but the library our back end is using to produce the openapi spec does not seem to support something like this:
I believe this is a duplicate, we already have one or two issues tracking it, I believe you already commented on them as well.
This is known - I'd recommend removing any explicit null types from the OpenAPI doc, and instead just rely on the required property in your object schemas. If a property is present, it'll be non-optional. If it's absent, it'll be optional - and that'll handle automatically both the case where the field is missing from the JSON and if it's present as null. You don't need to explicitly allow null in the OpenAPI doc, in fact that causes the issue you're seeing.
Hey there 👋🏽 . Is there any update on this issue? For context, in my project we're using Pydantic and the OpenAPI document is generated from that. I.e., we can't just update our open api document and fix things that way.
Please fix. I'm blocked on the same as well. In my Swift app, I consume a FastAPI endpoint that has the same issue as well and I can't really change the external API on my end. Thank you
Activity
czechboy0 commentedon Aug 28, 2025
Hi @BrentMifsud,
I believe this is a duplicate, we already have one or two issues tracking it, I believe you already commented on them as well.
This is known - I'd recommend removing any explicit null types from the OpenAPI doc, and instead just rely on the
requiredproperty in your object schemas. If a property is present, it'll be non-optional. If it's absent, it'll be optional - and that'll handle automatically both the case where the field is missing from the JSON and if it's present as null. You don't need to explicitly allow null in the OpenAPI doc, in fact that causes the issue you're seeing.czechboy0 commentedon Aug 28, 2025
In your example, I'd just use:
czechboy0 commentedon Aug 28, 2025
Related, #419, #513.
Remove null from anyOf enumerations
Refresh OpenAPI spec from prod (v3.12.0 → v3.12.2) and add update scr…
vdsingh commentedon May 11, 2026
Hey there 👋🏽 . Is there any update on this issue? For context, in my project we're using Pydantic and the OpenAPI document is generated from that. I.e., we can't just update our open api document and fix things that way.
Any advice or insight?
saikatdas0790 commentedon Sep 4, 2026
Please fix. I'm blocked on the same as well. In my Swift app, I consume a FastAPI endpoint that has the same issue as well and I can't really change the external API on my end. Thank you
Create flow OpenAPI contract: drop anyOf-null from CreateInfluencerRe…
OpenAPI create-flow contract: anyOf-null-free create request, typed w…
feat(yral-ios): generate the Rishi API client from the live OpenAPI spec
czechboy0 commentedon Sep 4, 2026
The workaround continues to be the same: turn:
into
using a script, for example.
fix(yral-ios): create flow sends the durable avatar URL — adapted to …
OpenAPI for swift-openapi-generator: no null in unions, 204 for nothing