Exhaustive OData Navigation Path Generation Problem

未關閉
#1,000 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 2 天內回覆

還沒有人認領這個 Issue。

評估

難度
5/5
預估耗時
一週以上
新手友好度
35/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
openapi

研究方向

未指定來源檔案、測試或進入點。先找出 Microsoft.OpenApi.OData 的產生流程並重現 35MB v1.0 規格,接著將受深度限制或經過篩選的輸出與包含 21 條路徑的概念驗證進行比較。完成後應在不遺失必要直接操作的情況下,實際減少路徑數量與規格大小。

由索引模型根據 Issue 內容生成。

描述

ToTriage

OpenAPI Spec is 35MB Due to Exhaustive OData Navigation Path Generation
Problem:
The generated OpenAPI spec (v1.0) is 35MB with 10,405 paths, making it unusable in API clients (Insomnia, Postman, Swagger UI). The root cause is that the spec includes every possible navigation path through the object graph, not just useful endpoints.

Example of Path Explosion:
A single resource like /drives/{id}/items/{id} generates 1,505 paths because it includes every nested relationship:

/drives/{id}/items/{id} - the actual file (useful)

/drives/{id}/items/{id}/createdByUser - navigate to creator

/drives/{id}/items/{id}/createdByUser/manager - creator's manager

/drives/{id}/items/{id}/createdByUser/manager/directReports/{id} - manager's team

/drives/{id}/items/{id}/createdByUser/manager/directReports/{id}/photo - their photos

... continues 5-10 levels deep

Reality Check:
Nobody uses /drives/{id}/items/{id}/createdByUser/manager/photo - they'd call /users/{id}/photo directly. These navigation paths are technically valid in OData but practically useless.

Analysis:

10,405 paths (most are nested navigation bloat)

4,292 schemas (3,242 unused - 75%)

1,157 responses (521 unused - 45%)

2,360 examples (all unused)

Impact:

Clients freeze/crash loading the spec

Impossible to explore the API effectively

Poor developer experience

Proposed Remedies:

Option 1: Limit navigation depth (Recommended)
Configure Microsoft.OpenApi.OData to only generate direct resource operations, not nested navigation paths. Max depth of 1 would reduce 10K paths to ~500-1000 useful endpoints.

Option 2: Split by service area
Publish separate specs per service:

openapi-files.yaml - drives/items/sites (core file operations only)

openapi-users.yaml - users/groups

openapi-mail.yaml - messages/mailFolders

openapi-calendar.yaml - events/calendars

etc.

Option 3: Provide filtered variants

openapi-full.yaml - complete with all navigation (current)

openapi-core.yaml - direct operations only, no nested navigation

openapi-{service}.yaml - per-service splits

Option 4: Post-generation pruning
Add a build step that removes:

Navigation paths beyond depth 1

Unused schemas/responses

All examples (2,360 unused)

Proof of Concept:
Filtering to just essential file operations (21 paths) reduces the spec from 35MB to 1.1MB - a 97% reduction while maintaining full functionality.

主要語言
XSLT
星號
171
分支
56
平均合併
1 天 11 小時
30 天內合併 PR
9

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

microsoftgraph/msgraph-metadata 的其他 Issue

查看 microsoftgraph/msgraph-metadata 的全部 Issue

相似的 Issue

更多 Backend & API Design Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。