readOnly property not marked as optional in the generated model
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
Research direction
Begin by running the supplied OpenAPI 3.1 reproduction with openapi-python-client 0.22 and inspecting the generated Bug model and POST usage. Trace where readOnly and required fields are converted; done when readOnly fields are not required for POST input while remaining available in generated response models, with regression coverage.
Written by the indexing model from the issue text.
Description
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]
- Dominant language
- Python
- Stars
- 2k
- Forks
- 293
- Avg merge
- 34m
- Merged PRs (30d)
- 1
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from openapi-generators/openapi-python-client
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 3/5 1-2 days Newbie friendliness 72/100
openapi-generators/openapi-python-client#1451 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 52/100
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
openapi-generators/openapi-python-client#1435 · 1 comment ·
All issues in openapi-generators/openapi-python-client
Similar issues
-
essnmx good first issue
Difficulty 1/5 Under an hour Newbie friendliness 95/100
-
[Feature] 奇物选择添加优先级 Open
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
syfoud/Simulated_Scepter#174 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Giskard-AI/giskard-oss#2840 · 1 comment ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Openarea: repo bug perceived difficulty: 2
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
yeti-platform/yeti#1380 ·