openapi-generators / openapi-generators/openapi-python-client
Support array of format: binary items in multipart/form-data request bodies
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 2k
- Fork
- 293
- Merge medio
- 34m
- PR unite (30g)
- 1
Descrizione
Describe the bug
When an OpenAPI 3.0 schema defines a property as an array of binaries inside a multipart/form-data requestBody, the generator currently treats it as a JSON body and emits a single body parameter. As a result:
- The generated
sync_detailed(...)signature has only:
def sync_detailed(
*,
client: Client,
body: UploadFilesPostBody,
hash_: str,
) -> Response[Any]:
…
- Internally
body.files(a list ofFileobjects withpayload: BinaryIO) is passed tojson=…, causing serialization errors.
OpenAPI Spec File
paths:
/upload_files:
post:
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
hash_:
type: string
files:
type: array
items:
type: string
format: binary
responses:
'200':
description: OK
What actually happens
- The generator emits a single body: UploadFilesPostBody parameter.
- When calling sync_detailed(..., body=…), httpx is invoked with json=… and fails on BinaryIO because it isn’t valid JSON.
Desktop:
- OS: Windows 10
- Python Version: cPython 3.12.8
- openapi-python-client version 0.24.3
Additional context
None - if anything is needed, please let me know
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
Iniziare tracciando il percorso del generatore che gestisce i corpi delle richieste multipart/form-data e confrontarlo con il metodo sync_detailed(...) generato descritto nell’issue. Verificare che il client generato invii il campo files come dati multipart anziché tramite httpx json=, e aggiungere la copertura per lo schema OpenAPI fornito se il repository dispone di una posizione pertinente per i test del generatore.
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
- 48/100