Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Model Composition with ‘allOf’ Is Missing Fields

Open
#1,392 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
42/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
openapi, python
Domain
api, tooling

Research direction

Start by running the supplied OpenAPI spec and compare the generated Network and Base models and the sync_detailed signature. Trace how allOf schemas are handled during model and endpoint generation. Done means Network is generated with both fields, the endpoint uses Network instead of Base, and a regression test covers this composition.

Written by the indexing model from the issue text.

Description

Describe the bug
Using a composition model (https://spec.openapis.org/oas/v3.0.4.html#models-with-composition) does not generate the target type but only the underlying type. For a type A which consists of the fields of B and some additional fields, only B is generated. Furthermore, A is replaced by B.

The spec below generates the following function:

def sync_detailed(
    *,
    client: AuthenticatedClient | Client,
    body: Base,
) -> Response[Any]: ...

I would expect that the model Network is generated and used instead of Base. The Network model should include the field of Base and the field non_base_field.

OpenAPI Spec File

openapi: 3.0.0
info:
  title: Service
  version: 0.0.0
paths:
  /widgets:
    get:
      responses:
        "200":
          description: The request has succeeded.
          content:
            application/json:
              schema:
                nullable: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/Network"
components:
  schemas:
    Base:
      type: object
      required:
        - base_field
      properties:
        base_field:
          type: string
    Network:
      type: object
      required:
        - non_base_field
      properties:
        non_base_field:
          type: string
      allOf:
        - $ref: "#/components/schemas/Base"

Desktop (please complete the following information):

  • OS: Linux
  • Python Version: 3.13.11
  • openapi-python-client version: 0.28.1

Additional context
Add any other context about the problem here.

Dominant language
Python
Stars
2k
Forks
293
Avg merge
34m
Merged PRs (30d)
1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from openapi-generators/openapi-python-client

All issues in openapi-generators/openapi-python-client

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.