openapi-generators / openapi-generators/openapi-python-client
Model Composition with ‘allOf’ Is Missing Fields
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 2k
- Fork
- 293
- Merge medio
- 34m
- PR unite (30g)
- 1
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia eseguendo la specifica OpenAPI fornita e confronta i modelli Network e Base generati e la firma di sync_detailed. Traccia il modo in cui gli schemi allOf vengono gestiti durante la generazione dei modelli e degli endpoint. Il lavoro è completato quando Network viene generato con entrambi i campi, l'endpoint usa Network invece di Base e un test di regressione copre questa composizione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- openapi, python
- Ambito
- api, tooling
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100