DateTime(format="timestamp") generates invalid OpenAPI schema using min instead of minimum
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 88/100
Hướng nghiên cứu
Issue xác định field_converter.py là nguồn tạo schema cho timestamp và timestamp_ms. Tái hiện ví dụ tối thiểu, kiểm tra cả hai nhánh và xác minh rằng schema được tạo sử dụng ràng buộc số hợp lệ của OpenAPI và vượt qua bước xác thực đặc tả.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
apispec generates an invalid OpenAPI schema for marshmallow.fields.DateTime(format="timestamp").
The generated schema contains the min property:
changedOn:
type: number
format: float
example: "1676451245.596"
min: "0"
However, min is not a valid OpenAPI Schema Object property. As a result, the generated specification fails validation with openapi-spec-validator:
OpenAPIValidationError:
Property 'min' is not allowed
This was reproduced with:
- apispec 6.10.0
- marshmallow 3.26.2
- openapi-spec-validator 0.9.0
- OpenAPI 3.0.2
Expected behavior
The generated schema should use the standard OpenAPI keyword minimum instead of min, for example:
changedOn:
type: number
format: float
example: "1676451245.596"
minimum: 0
or omit the constraint entirely if no minimum value is intended.
Minimal reproduction
from apispec import APISpec
from apispec.ext.marshmallow import MarshmallowPlugin
from marshmallow import Schema, fields
from pprint import pprint
class TestSchema(Schema):
ts = fields.DateTime(format="timestamp")
spec = APISpec(
title="test",
version="1.0",
openapi_version="3.0.2",
plugins=[MarshmallowPlugin()],
)
spec.components.schema("Test", schema=TestSchema)
pprint(spec.to_dict()["components"]["schemas"]["Test"])
Output:
{'additionalProperties': False,
'properties': {'ts': {'example': '1676451245.596',
'format': 'float',
'min': '0',
'type': 'number'}},
'type': 'object'}
The file field_converter.py contains the code that causes this issue:
elif field.format == "timestamp":
ret = {
"type": "number",
"format": "float",
"example": "1676451245.596",
"min": "0",
}
elif field.format == "timestamp_ms":
ret = {
"type": "number",
"format": "float",
"example": "1676451277514.654",
"min": "0",
}
Specification reference
The OpenAPI Schema Object defines the numeric constraint keyword as minimum; min is not a valid keyword.
OpenAPI 3.0.2 Schema Object:
https://spec.openapis.org/oas/v3.0.2#schema-object
- Ngôn ngữ chính
- Python
- Star
- 1.2k
- Fork
- 210
- Merge trung bình
- 2 ngày 1 giờ
- Pull request đã merge (30 ngày)
- 4
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc 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.
Issue khác của marshmallow-code/apispec
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
marshmallow-code/apispec#750 · 1 bình luận · 5 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Dependency DashboardĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 30/100
marshmallow-code/apispec#1033 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
`apispec` ignores `oneOf` from `marshmallow-oneofschema`Có thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
marshmallow-code/apispec#1012 · 6 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Support Overlays standardĐang mởenhancement
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
marshmallow-code/apispec#981 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Date and DateTime with format argument not rendered correctlyCó thể đã có người làm @jbbqqf đã nhận 173 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 30/100
marshmallow-code/apispec#938 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của marshmallow-code/apispec
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
btclib-org/btclib#3062 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Run evals automatically in CIĐang mởarea:evals area:infra enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
jse-avl/support-bot#4 · 1 bình luận ·
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
qte77/agentic-job-offer-to-application-kit#487 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
On a free-threaded build, `_decrypted` can report a ledger locked mid-sign as a damaged fileĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
btclib-org/btclib-wallet#801 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation good first issue
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 94/100