Skip to content

Nullable top-level object schema with a nested nullable object is dropped #1522

Open

Description

@dmarin-pixel

Describe the bug
A schema in components/schemas with type: ["object", "null"] that has a
property which is itself a nullable object is dropped, and the generator
still exits 0. It only prints "Client was generated, but some pieces may be
missing":

Unable to process schema /components/schemas/Inner_type_0:
Invalid property in union <...UntrustedString object ...>
Failure to process schema has resulted in the removal of: {...}

The model Inner_type_0 is not generated, although the client is.

OpenAPI Spec File

openapi: 3.1.0
info: {title: probe, version: "1"}
paths: {}
components:
  schemas:
    Outer:
      type: object
      properties:
        inner:
          $ref: "#/components/schemas/Inner"
    Inner:
      type: ["object", "null"]
      properties:
        labels:
          type: ["object", "null"]
          additionalProperties: { type: "string" }

Expected: models Outer, Inner_type_0 and InnerLabelsType0 are generated.
Actual: Inner_type_0 is missing.

Desktop (please complete the following information):

  • OS: Linux
  • Python Version: 3.12.3
  • openapi-python-client version: 0.30.0 (also main at 46a4340)

Additional context
Cause: UnionProperty.build splits a type list into one variant per type and
calls property_from_data for each, but does not forward process_properties or
roots. Variants are therefore built eagerly while the schema is also queued
in models_to_process. The same applies to anyOf/oneOf unions.
Fix: #1518 forwards both arguments through UnionProperty.build.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions