microsoft / microsoft/OpenAPI.NET

Circular references in external documents create an infinite recursion

未关闭
#1,985 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
C#
星标
1.6k
派生
286
平均合并
6 小时 38 分钟
30 天内合并 PR
35

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

使用提供的 Kiota Docker 命令和链接的 pet.json、pets2.json 文件重现递归,然后跟踪在解析引用期间外部文档如何加载到工作区中。将附加的 circular_ref.patch 与当前行为进行比较;当相互引用的外部文档能够在不发生无限递归的情况下完成解析,同时仍保留在预期的工作区中时,即表示完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
csharp
领域
api
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。