microsoft / microsoft/OpenAPI.NET

Circular references in external documents create an infinite recursion

Đang mở
#1,985 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.

Ngôn ngữ chính
C#
Star
1.6k
Fork
286
Merge trung bình
6 giờ 38 phút
Pull request đã merge (30 ngày)
35

Mô tả

Describe the bug
Open api documents that contain circular references create an infinite recursion because each external document is loaded into a new root workspace rather than the initial document loader workspace.

OpenApi File To Reproduce
In order to reproduce, you need two files that reference each other. I've put a circular reference in the schemas section of the below specs (this is not the exact problem I'm seeing with real documents, but it's close enough to reproduce). The references are hard coded to a mount directory because I'm using kiota as a driver, so you may need to update the paths if you run against a different location.

pet.json
pets2.json

Expected behavior
I believe external documents should all be loaded into the same workspace for reference resolution.

Screenshots/Code Snippets

docker run --rm `
    -v "${PWD}\output:/app/output" `
    -v "${PWD}\specs:/app/specs" `
    -u root `
    mcr.microsoft.com/openapi/kiota generate --language csharp -n MyCode --openapi ./specs/pet.json --log-level trace

I have encountered the problem in open api documents from large enterprise software providers, so I've attached a patch file that contains my work around for an internal fork of the document loader libraries. Adding external documents to the root workspace created by the initial document load appears to resolve the problem, though I'm not sure if the external references are being resolved correctly.

This patch includes the changes I was required to make in order to resolve locally.
circular_ref.patch

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

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.

Hướng nghiên cứu

Tái hiện đệ quy với các tệp pet.json và pets2.json được liên kết bằng lệnh Docker Kiota được cung cấp, sau đó theo dõi cách các tài liệu bên ngoài được tải vào các workspace trong quá trình phân giải tham chiếu. So sánh circular_ref.patch đính kèm với hành vi hiện tại; công việc được coi là hoàn tất khi các tài liệu bên ngoài tham chiếu lẫn nhau được phân giải mà không xảy ra đệ quy vô hạn và vẫn nằm trong workspace dự kiến.

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

Đánh giá

Công nghệ
csharp
Lĩnh vực
api
Loại issue
Lỗi
Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
45/100

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.