openapi-generators / openapi-generators/openapi-python-client
Schema processing fails when "allOf" references to nullable object
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 2k
- Forks
- 293
- Ø Merge
- 34 Min.
- Gemergte PRs (30 T.)
- 1
Beschreibung
Describe the bug
When using a schema that contains an "allOf" reference to a nullable object, the generation fails with the message "Cannot take allOf a non-object".
OpenAPI Spec File
Document to recreate:
openapi: 3.0.1
info:
title: Title
description: Description
version: 1.0.0
servers:
- url: /api
paths:
/item:
get:
operationId: item
responses:
"200":
description: Successful operation
content:
application/json:
schema:
$ref: '#/components/schemas/Item'
components:
schemas:
RelatedItemSuper:
type: object
nullable: true
properties:
propertyA:
type: string
RelatedItem:
type: object
allOf:
- $ref: '#/components/schemas/RelatedItemSuper'
- type: object
properties:
propertyB:
type: string
Item:
type: object
nullable: false
properties:
key:
type: string
relatedItem:
$ref: '#/components/schemas/RelatedItem'
A real world example can be found here.
Desktop (please complete the following information):
- OS: Linux
- Python Version: 3.11.2
- openapi-python-client version: 0.21.1
Additional context
Changing "nullable" to "false" on "RelatedItem" in the above example works but does not seem to be a suitable solution as the construct used is legitimate, or is it not?
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginnen Sie damit, openapi-python-client 0.21.1 mit dem bereitgestellten OpenAPI 3.0.1-Dokument auszuführen, und verfolgen Sie den Schema-Verarbeitungspfad, der "Cannot take allOf a non-object." ausgibt. Verwenden Sie die Definitionen RelatedItemSuper und RelatedItem mit nullable als Regressionstestfall; als abgeschlossen gilt die Aufgabe, wenn die Client-Generierung erfolgreich ist, ohne dass nullable in false geändert werden muss.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- openapi, python
- Bereich
- api, tooling
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100