[BUG] ExampleGenerator returns the string "{}" (or null) for `type: object` schemas without `properties`
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
- 78/100
Hướng nghiên cứu
Tìm resolvePropertyToExample và resolveModelToExample trong mã Java triển khai ExampleGenerator; issue không nêu tên tệp chứa chúng hoặc một bài kiểm thử. Bắt đầu bằng cách tái hiện lỗi với lược đồ OpenAPI được cung cấp và kiểm tra cách xử lý các giá trị $ref chưa được phân giải. Công việc được xem là hoàn tất khi các lược đồ đối tượng không có thuộc tính tạo ra một đối tượng JSON rỗng trong cả ví dụ lồng nhau lẫn ví dụ cấp cao nhất, thay vì một chuỗi hoặc null.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
Description
resolvePropertyToExample returns the Java string literal "{}" for an object schema without properties and for a $ref that cannot be resolved. Json.pretty then serializes it as a JSON string ("metadata" : "{}") instead of an empty object ("metadata" : { }), so the example has the wrong type (JSON Schema Validation wright-00, 5.21).
The same happens one level up. For a top-level model type: object without properties, resolveModelToExample falls through to return null, and generate(null, ["application/json"], "Anything") returns the example null. Through the CLI this model gets unaliased first, so the operation simply has no example; only programmatic callers see null.
openapi-generator version
7.25.0 (also current master).
OpenAPI declaration file content or url
components:
schemas:
Reading:
type: object
properties:
metadata:
type: object
Steps to reproduce
generate -g html → "Example data" shows "metadata" : "{}". Expected: "metadata" : { }.
Suggest a fix
Return new LinkedHashMap<>() (an empty map) instead of the string "{}" in both branches of resolvePropertyToExample, and also for object schemas without properties in resolveModelToExample.
- Ngôn ngữ chính
- Java
- Star
- 26.8k
- Fork
- 7.7k
- Merge trung bình
- 1 ngày 15 giờ
- Pull request đã merge (30 ngày)
- 146
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Có Dockerfile hoặc tệp Docker Compose
- 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 OpenAPITools/openapi-generator
-
[BUG][RUST] Reqwest - encoding of spaces in path parametersCó thể đã có người làm @GlenWright đã nhận hôm nay. Đang mởIssue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
OpenAPITools/openapi-generator#25257 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] OpenApiEvaluator reports "default value not in enum" for numerically equal values with different scale (e.g. 1.5 and 1.50)Có thể đã có người làm @mohitduhan19 đã nhận 2 ngày trước. Đang mởIssue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OpenAPITools/openapi-generator#25233 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] OpenApiEvaluator emits "Unused model" warnings even when recommendations are disabledCó thể đã có người làm @mohitduhan19 đã nhận 2 ngày trước. Đang mởIssue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
OpenAPITools/openapi-generator#25232 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG][KOTLIN] multiplatform/jvm-ktor: `DELETE` without `requestBody` sends `"Content-Type: application/json"` with an empty bodyCó thể đã có người làm @mohitduhan19 đã nhận 2 ngày trước. Đang mởIssue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
OpenAPITools/openapi-generator#25223 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Issue: Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
OpenAPITools/openapi-generator#25218 ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của OpenAPITools/openapi-generator
Issue tương tự
-
:maddi-inspection-kotlin:test runs out of heap in a full maddi test run; exit 1 with no failing testĐang mởbuild/ci front-end:kotlin
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
uwolfer/gerrit-intellij-plugin#768 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
github_actions
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
hiero-ledger/hiero-consensus-node#27621 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
x:knowledge/elementary x:module/practice-exercise
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100