Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

oneOf with discriminator on path

Aperta
#52 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
openapi, python

Direzione di ricerca

Start with the minimal OpenAPI example in the issue and review how discriminator validation is handled for request bodies and path parameters. Check the project's validation entry points and tests for oneOf and discriminator behavior; done should clarify or implement the expected relationship between the path item_type and the selected schema.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

resolution/invalid

As all different types of request bodies should be processed by the same function, I was hoping to do something the following minimal example:

  /api/{item_type}:
    post:
      parameters:
        - in: path
          name: item_type
          required: true
          schema:
            type: string  
      requestBody:
        $ref: '#/components/requestBodies/object'
        required: true
      responses:
        '201':
          description: Item created
components:
  requestBodies:
    object:
      content:
        application/json:
          schema:
            oneOf:
              - $ref: '#/components/schemas/Movie'
              - $ref: '#/components/schemas/Program'
            discriminator:
              propertyName: item_type
  schemas:
    Movie:
      type: object
    Program:
      type: object

Essentially, I want one function, to parse all item_types, but still ensure validation based on item_type in the path. However, I can create a Movie with the properties of Program.
Is this not the intended use? Or is there no discriminator validation on parameters specified in the path?

Thanks in advance.

Lingua principale
Python
Stelle
409
Fork
73
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

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.

Altre issue di python-openapi/openapi-spec-validator

Tutte le issue di python-openapi/openapi-spec-validator

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.