openapi-generators / openapi-generators/openapi-python-client
readOnly property not marked as optional in the generated model
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 2k
- Fork
- 293
- Merge medio
- 34m
- PR unite (30g)
- 1
Descrizione
Describe the bug
Fields marked as readOnly in a schema in the OpenAPI document are not set as optional in the generated model.
This makes them required in the body of any POST request in which this model is used, defeating the purpose of using the readOnly property.
OpenAPI Spec File
openapi: 3.1.0
info:
title: Minimal bug reproduction API
version: 1.0.0
paths:
/bug:
get:
summary: Get all bugs
responses:
"200":
description: A list of bugs
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/Bug"
post:
summary: Create a bug
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/Bug"
responses:
"201":
description: Bug created
content:
application/json:
schema:
$ref: "#/components/schemas/Bug"
components:
schemas:
Bug:
type: object
properties:
id:
readOnly: true
type: integer
created_at:
readOnly: true
type: string
format: date-time
name:
type: string
description:
type: string
status:
type: string
enum:
- open
- closed
required:
- id
- name
- description
- status
- created_at
Desktop (please complete the following information):
- OS: [Windows 11]
- Python Version: [3.12]
- openapi-python-client version [0.22]
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 riproduzione OpenAPI 3.1 fornita con openapi-python-client 0.22 e ispezionando il modello Bug generato e l’utilizzo di POST. Traccia il punto in cui vengono convertiti i campi readOnly e required; il lavoro è completato quando i campi readOnly non sono obbligatori per l’input POST, pur rimanendo disponibili nei modelli di risposta generati, con copertura di regressione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- tooling
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 42/100