$ref to array item leads to incorrect TypeScript type
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
- 45/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- typescript
Hướng nghiên cứu
Start by reproducing the generated TypeScript from the bundled OpenAPI schema, focusing on the $ref from Dog.dogName to DogNames/items. The change is complete when the property is typed as DogNames[number] rather than DogNames, while the DogNames array type remains unchanged.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I noticed a bug with the OpenAPI code generation output where a property that references an array item schema is being typed as an array in the generated TypeScript.
After bundling with swagger-parser bundler (because the original schema used an relative YAML file reference), the final JSON OpenAPI schema looks like this:
"components": {
"schemas": {
"DogNames": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
}
},
"Dog": {
"type": "object",
"properties": {
"dogName": {
"$ref": "#/components/schemas/DogNames/items"
}
}
}
}
}
In the Dog schema, the property dogName references #/components/schemas/DogNames/items, which means it should be typed as a single object that matches the item structure from the DogNames array.
export type DogNames = {
name?: string;
}[];
export type Dog = {
dogName?: DogNames; // <-- This is incorrect
};
Expected output:
export type DogNames = {
name?: string;
}[];
export type Dog = {
dogName?: DogNames[number];
}
- Ngôn ngữ chính
- TypeScript
- Star
- 635
- Fork
- 82
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
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 fabien0102/openapi-codegen
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
fabien0102/openapi-codegen#343 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
fabien0102/openapi-codegen#342 ·
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 30/100
fabien0102/openapi-codegen#356 ·
-
update dependencies & removed unused deprecatedCó thể đã có người làm @el-j đã nhận 12 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
fabien0102/openapi-codegen#354 ·
-
deepMerge mutates its arguments, corrupting request payloads across callsCó thể đã có người làm @richard-willis-chevin đã nhận 56 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
fabien0102/openapi-codegen#349 ·
Tất cả issue của fabien0102/openapi-codegen
Issue tương tự
-
[测试] 等待仓库加载后再记录多仓库排序基线Có thể đã có người làm @myot233 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
Maintainer thường phản hồi trong vòng 1 ngày
-
area:arcade p3-medium ready-for-agent testing type:docs
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
fderuiter/deruiter.dev#2369 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area:devenv origin:agent type:bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
overengineeringstudio/effect-utils#1949 ·
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 76/100
ccch1mneyyy/dsh-TUI#1631 ·
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 78/100
MiniMax-AI/minimax-code#507 ·
Maintainer thường phản hồi trong vòng 1 ngày