openapi-generators / openapi-generators/openapi-python-client

Schema processing fails when "allOf" references to nullable object

Aperta
#1,066 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

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 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?

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia eseguendo openapi-python-client 0.21.1 sul documento OpenAPI 3.0.1 fornito e traccia il percorso di elaborazione dello schema che emette "Cannot take allOf a non-object." Usa le definizioni RelatedItemSuper e RelatedItem con nullable come caso di regressione; il lavoro è completato quando la generazione del client riesce senza richiedere che nullable venga modificato in false.

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
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.