False positive when adding optional property
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 42/100
Hướng nghiên cứu
Bắt đầu với các fixture test/old.json và test/new.json được cung cấp, rồi tái hiện kết quả bằng lệnh Docker trong báo cáo. Truy vết quá trình kiểm tra tính tương thích của schema phần thân request đối với một thuộc tính được thêm vào nhưng không có trường bắt buộc, sau đó thêm một regression test và xác nhận rằng phép so sánh không còn báo cáo một thay đổi không tương thích ngược nữa.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When comparing these 2 schemas:
test/old.json
{
"openapi": "3.0.0",
"servers": [{ "url": "https://myserver.com" }],
"info": { "title": "My API", "description": "Description", "version": "0.2.0" },
"paths": {
"/v1/entity/{id}": {
"put": {
"operationId": "myOperation",
"description": "Some description",
"requestBody": { "$ref": "#/components/requestBodies/updateBody" }
}
}
},
"components": {
"schemas": {},
"responses": {},
"requestBodies": {
"updateBody": {
"description": "Update description",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"url": { "type": "string", "description": "Some URL" }
},
"title": "updateBody",
"additionalProperties": false
}
}
}
}
},
"parameters": {}
}
}
test/new.json
{
"openapi": "3.0.0",
"servers": [{ "url": "https://myserver.com" }],
"info": { "title": "My API", "description": "Description", "version": "0.2.0" },
"paths": {
"/v1/entity/{id}": {
"put": {
"operationId": "myOperation",
"description": "Some description",
"requestBody": { "$ref": "#/components/requestBodies/updateBody" }
}
}
},
"components": {
"schemas": {},
"responses": {},
"requestBodies": {
"updateBody": {
"description": "Update description",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"url": { "type": "string", "description": "Some URL" },
"url2": { "type": "string", "description": "Some URL" }
},
"title": "updateBody",
"additionalProperties": false
}
}
}
}
},
"parameters": {}
}
}
I get a broken compatibility message:
docker run --rm -t -v $(pwd)/test/:/specs:ro openapitools/openapi-diff:latest --fail-on-incompatible /specs/old.json /specs/new.json
==========================================================================
== API CHANGE LOG ==
==========================================================================
My API
--------------------------------------------------------------------------
-- What's Changed --
--------------------------------------------------------------------------
- PUT /v1/entity/{id}
Request:
- Changed application/json
Schema: Broken compatibility
--------------------------------------------------------------------------
-- Result --
--------------------------------------------------------------------------
API changes broke backward compatibility
--------------------------------------------------------------------------
Note that the only change is the addition of the url2 optional property:
diff -u test/old.json test/new.json
--- test/old.json 2023-03-14 17:06:02
+++ test/new.json 2023-03-14 17:06:33
@@ -22,7 +22,8 @@
"schema": {
"type": "object",
"properties": {
- "url": { "type": "string", "description": "Some URL" }
+ "url": { "type": "string", "description": "Some URL" },
+ "url2": { "type": "string", "description": "Some URL" }
},
"title": "updateBody",
"additionalProperties": false
Since the required field is absent, I would expect the addition of url2 to not create a broken compatibility error.
- Ngôn ngữ chính
- Java
- Star
- 1.1k
- Fork
- 190
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
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 OpenAPITools/openapi-diff
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
OpenAPITools/openapi-diff#506 ·
-
good first issue help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
OpenAPITools/openapi-diff#364 ·
-
bug OpenAP 3.1.0 Support
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
OpenAPITools/openapi-diff#910 · 1 bình luận ·
-
Render capabilities
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
OpenAPITools/openapi-diff#893 · 1 bình luận ·
-
Breaking/Non-Breaking classification
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
OpenAPITools/openapi-diff#886 ·
Tất cả issue của OpenAPITools/openapi-diff
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
elastic/gradle-plugins#157 ·
-
enhancement Tools
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 75/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
apache/rocketmq-dashboard#5008 ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
-
DETECT_PARAMETER_NAMES=false silently disables @ConstructorProperties-based Creator detection too Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
FasterXML/jackson-databind#6229 ·