Filter unused OpenAPI definitions when extracting selected operations

Đang mở
#343 0 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
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
openapi, typescript
Lĩnh vực
cli, tooling

Hướng nghiên cứu

Start at the apiops extract command in the TypeScript CLI source and trace where the --filter operation selection prunes paths before the spec is written to specification.yaml. The fix belongs after paths are filtered: collect the $ref targets reachable from the remaining operations and keep only those components/definitions, walking transitively so shared schemas and nested items survive. Validate with an extracted spec containing an invalid definition used only by an excluded operation, then run it through Spectral — done means Spectral no longer reports errors from unreferenced definitions.

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

Mô tả

type:bug
Command that triggered the bug

apiops extract

Expected behavior

When extracting an API with an operation filter, the generated OpenAPI specification contains only the selected operations, but retains definitions used exclusively by excluded operations.

This can cause validation to fail on an unrelated definition. For example, Spectral reports an array-items error for an invalid schema even when the operation using it was excluded.

Expected behavior

Filter the definitions to those needed by the selected operations, while preserving all transitively referenced components.

Actual behavior

The extractor removes unselected operations from specification.yaml, but still extracts definitions that are not referenced by the selected operations. As a result, validation can fail on an invalid definition unrelated to the selected operations.

apiops CLI version

1.0.5

Environment details

Environment

APIOps CLI: 1.0.5
Command: apiops extract --filter
CI: Azure DevOps with Spectral validation

CI/CD environment

None

Is this bug blocking you?

Yes

Ngôn ngữ chính
TypeScript
Star
44
Fork
14
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

Mở trong Codespaces

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.

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 Azure/apiops-cli

Tất cả issue của Azure/apiops-cli

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.