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

Cannot generate Enums from Dictionary Object

Đang mở
#156 2 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ệ
typescript
Lĩnh vực
devtools

Hướng nghiên cứu

Start with the provided OpenAPI dictionary schema and compare enum generation with useEnums set to false and true. Trace the generator path handling additionalProperties and allOf, then verify that the generated TypeScript references a defined enum like the regular-object output rather than undefinedTest.

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

Mô tả

The useEnum option is a great addition! Super happy that got in. Trying it out I ran into an edge case when generating enums from a Dict object. Given the schema:

{
      "Test": {
        "additionalProperties": {
          "properties": {
            "test": {
              "enum": [
                "A",
                "B"
              ],
              "type": "string"
            }
          },
          "required": [
            "test"
          ],
          "type": "object"
        },
        "properties": {},
        "type": "object"
      }
}

With useEnums: false:

export type Test = {
  [key: string]: {
    test: 'A' | 'B'
  }
}

With useEnums: true:

export type Test = {
  [key: string]: {
    test: undefinedTest
  }
}

with a regular object

   "Test": {
          "properties": {
            "test": {
              "enum": [
                "A",
                "B"
              ],
              "type": "string"
            }
          },
          "required": [
            "test"
          ],
          "type": "object"
      }
export enum TestTest {
  A = 'A',
  B = 'B',
}

export type Test = {
  test: TestTest
}

Was also able to duplicate the same behavior when using allOf which makes me think #157 is related

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

  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 fabien0102/openapi-codegen

Tất cả issue của fabien0102/openapi-codegen

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.