Skip to content

fix: Swagger resolveSchema drops every direct-$ref property (60 of 225 endpoints) - #613

Open
zjncs wants to merge 1 commit into
oss-compass:mainfrom
zjncs:fix/swagger-ref-resolution
Open

zjncs wants to merge 1 commit into
oss-compass:mainfrom
zjncs:fix/swagger-ref-resolution

Conversation

@zjncs

@zjncs zjncs commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

Problem

resolveSchema has no branch for direct $ref properties — {"$ref": "#/definitions/X", "description": "..."} has no type, so neither the array nor object branch fires. The referenced schema's properties are never resolved.

Verified against the live /api/v2/docs spec: 67 properties declared as plain $ref. 60 of 225 endpoints with a 201 schema lose at least one nested object (66 distinct objects — every metric_detail + TpcItem.scorecard).

Second layer: ResponsesViewer's hasChildren only inspects value.items — the value.items || value.properties fallback is unreachable.

Fix

  1. resolveSchema: add a $ref branch (recursively resolve the referenced schema).
  2. Fix the dead call resolveSchema(definitions, propDef.type) for inline objects.
  3. ResponsesViewer: unified childData (items or properties) for both hasChildren and render.
  4. Export resolveSchema for testability.

Verification

3 tests: $ref resolution (RED before — no branch), array-of-$ref regression guard, unknown schema. Full dataHub suite: 3/3 passed.

…5 endpoints lose nested objects)

resolveSchema 对 {$ref, description} 形状的属性没有任何分支——没有
type 字段,array/object 检查都不命中,引用的 schema 从未被解析。
对线上 /api/v2/docs 规范实测:60/225 个带 201 schema 的端点至少
丢失一个嵌套对象(66 个不同对象——所有 /api/v2/metrics/* 的
metric_detail + TpcItem.scorecard)。

ResponsesViewer 的 hasChildren 只检查 value.items,解析出的
properties 仍然渲染为叶子——value.items || value.properties
的回退不可达。

修复:resolveSchema 新增 $ref 分支(递归解析引用的 schema),
导出为可测纯函数;ResponsesViewer 用统一的 childData(items 或
properties)判定可展开性与渲染。

新增 useMenuContent.test.ts:$ref 解析/array-of-$ref 回归/
未知 schema 三例。
Copilot AI balanced review requested due to automatic review settings October 22, 2026 05:06
@vercel

vercel Bot commented Oct 22, 2026

Copy link
Copy Markdown

@zjncs is attempting to deploy a commit to the codersett's projects Team on Vercel.

A member of the Team first needs to authorize it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants