openapi-generators / openapi-generators/openapi-python-client
readOnly property not marked as optional in the generated model
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- Python
- Star
- 2k
- Fork
- 293
- Merge trung bình
- 34 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
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]
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách chạy bản tái hiện OpenAPI 3.1 được cung cấp với openapi-python-client 0.22 và kiểm tra model Bug được tạo cùng cách sử dụng POST. Theo dõi nơi các trường readOnly và required được chuyển đổi; hoàn tất khi các trường readOnly không bắt buộc đối với đầu vào POST nhưng vẫn khả dụng trong các model response được tạo, kèm theo độ bao phủ hồi quy.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- python
- Lĩnh vực
- tooling
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Khá rõ ràng
- Mức phù hợp với người mới
- 42/100