Skip to content

codegen fails to produce anyOf/oneOf with a null type #817

@BrentMifsud

Description

@BrentMifsud

Description

The code generator skips anyOf or oneOf that have nullable listed:

warning: Schema "null" is not supported, reason: "schema type", skipping [context: foundIn=Operations.OperationName.Output.Ok.Body.JsonPayload.DataPayloadPayload (#/paths/path/to/resource/GET/responses/200/content/json/DataPayload)/my_type]

Reproduction

"my_type": {
    "anyOf": [
        {
            "$ref": "#/components/schemas/MyType"
        },
        {
            "type": "null"
        }
    ]
}
"my_type": {
    "oneOf": [
        {
            "$ref": "#/components/schemas/MyType"
        },
        {
            "type": "null"
        }
    ]
}

Package version(s)

Image

Expected behavior

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:

"my_type": {
    "$ref": "#/components/schemas/MyType",
    "type": ["object", "null"]
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugFeature doesn't work as expected.status/triageCollecting information required to triage the issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions