Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Every property marked as optional + 'any' types

Đang mở
#158 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
35/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
openapi, typescript
Lĩnh vực
api, tooling

Hướng nghiên cứu

Bắt đầu từ TypeScript interface generator và lần theo cách tính bắt buộc của các thuộc tính Swagger/OpenAPI cũng như các kiểu nguyên thủy được ánh xạ như thế nào. So sánh ví dụ ContactPerson với schema của nó, sau đó xác minh rằng các thuộc tính bắt buộc không phải là tùy chọn và các thuộc tính string hoặc date được ghi trong tài liệu không trở thành any.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

API Platform version(s) affected: 3.0

Description
I generated typescript interfaces from a API Platform with this package. This worked really well, but there are two issues that make the result pretty much unusable for me:

  • Every property is marked as optional, even '@id'. Having to manual check for every property kinda defeats the purpose of having the interfaces in the first place.
  • Some properties are marked as any, even though there is a proper type in the API docs. E.g. ContactPerson.image is listed as string in Swagger, but appears as any in TypeScript. I also noticed dates being any – but this was in a API Platform 2.6 project and might not be an issue in newer versions.

Here is an example taken out of my Swagger docs:

{
  "hydra:member": [
    {
      "@context": "string",
      "@id": "string",
      "@type": "string",
      "id": "string",
      "name": "string",
      "phoneNumber": "string",
      "email": "string",
      "jobAdvertisements": [
        "string"
      ],
      "image": "string"
    }
  ],
  "hydra:totalItems": 0,
  "hydra:view": {
    "@id": "string",
    "type": "string",
    "hydra:first": "string",
    "hydra:last": "string",
    "hydra:previous": "string",
    "hydra:next": "string"
  },
  "hydra:search": {
    "@type": "string",
    "hydra:template": "string",
    "hydra:variableRepresentation": "string",
    "hydra:mapping": [
      {
        "@type": "string",
        "variable": "string",
        "property": "string",
        "required": true
      }
    ]
  }
}

And this is the generated interface:

export interface ContactPerson {
  "@id"?: string;
  name?: string;
  phoneNumber?: string;
  email?: string;
  jobAdvertisements?: string[];
  image?: any;
}
Ngôn ngữ chính
TypeScript
Star
113
Fork
80
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

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của api-platform/api-doc-parser

Tất cả issue của api-platform/api-doc-parser

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.