microsoft / microsoft/OpenAPI.NET
Circular references in external documents create an infinite recursion
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C#
- Sterne
- 1.6k
- Forks
- 286
- Ø Merge
- 6 Std. 38 Min.
- Gemergte PRs (30 T.)
- 35
Beschreibung
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.
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Reproduziere die Rekursion mit den verknüpften Dateien pet.json und pets2.json mithilfe des bereitgestellten Kiota Docker-Befehls und verfolge anschließend, wie externe Dokumente während der Referenzauflösung in Workspaces geladen werden. Vergleiche den angehängten circular_ref.patch mit dem aktuellen Verhalten; als abgeschlossen gilt die Aufgabe, wenn sich gegenseitig referenzierende externe Dokumente ohne unendliche Rekursion auflösen lassen und dabei im vorgesehenen Workspace verbleiben.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- csharp
- Bereich
- api
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100