-
Notifications
You must be signed in to change notification settings - Fork 2
fix: $ref compatibility #216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
close IDP-1353
🦋 Changeset detectedLatest commit: 3e5a236 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds an exported Changes
Sequence Diagram(s)sequenceDiagram
participant UI as OpenAPIProperty component
participant G as get$Ref(obj)
participant R as resolveRef($ref)
participant D as RefLink / Renderer
UI->>G: provide schema object (property/items/props)
alt $ref found (direct or in allOf)
G-->>UI: return $ref
UI->>R: resolve returned $ref
R-->>UI: resolved schema object
UI->>D: render RefLink + resolved details
else no $ref
G-->>UI: undefined
UI->>D: render inline type/properties
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Suggested labels
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
commit: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR fixes $ref compatibility in OpenAPI schema handling by refactoring how references are resolved and updating Kubernetes API documentation links.
- Introduces a
get$Refhelper function to handle both direct$refproperties andallOfpatterns - Updates Kubernetes documentation URL structure to point to common-definitions subdirectory
- Adds reference mappings for multiple Kubernetes resources (DaemonSet, Deployment, ObjectMeta, etc.)
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/doom/src/runtime/utils.ts | Updates K8S_DOC_PREFIX to include common-definitions path and simplifies reference paths |
| packages/doom/src/runtime/components/OpenAPIRef.tsx | Adds get$Ref helper and refactors property rendering to consistently use it for reference extraction |
| doom.config.yml | Adds Kubernetes API references and fixes hash fragment format |
| docs/zh/apis/references/Deployment.mdx | Adds new Deployment reference documentation page |
| docs/zh/apis/references/DaemonSet.mdx | Adds new DaemonSet reference documentation page |
| docs/zh/apis/advanced-apis/workload/daemonset.mdx | Adds namespaced daemonsets API path documentation |
| .changeset/shaggy-bees-sort.md | Documents the patch-level change |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/doom/src/runtime/components/OpenAPIRef.tsx (1)
37-50: Consider handlingoneOfandanyOfin addition toallOf.The function currently only searches through
allOffor nested$refvalues. OpenAPI schemas can also useoneOfandanyOfcomposition keywords that may contain$refvalues.Apply this diff to handle all composition keywords:
export const get$Ref = ( obj: OpenAPIV3_1.ReferenceObject | OpenAPIV3_1.SchemaObject, ) => { if ('$ref' in obj && obj.$ref) { return obj.$ref } - if ('allOf' in obj && Array.isArray(obj.allOf)) { - for (const item of obj.allOf) { + // Check allOf, oneOf, and anyOf for nested $refs + for (const key of ['allOf', 'oneOf', 'anyOf'] as const) { + if (key in obj && Array.isArray(obj[key])) { + for (const item of obj[key]) { + if ('$ref' in item && item.$ref) { + return item.$ref + } + } + } + } - if ('$ref' in item && item.$ref) { - return item.$ref - } - } - } }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (7)
.changeset/shaggy-bees-sort.md(1 hunks)docs/zh/apis/advanced-apis/workload/daemonset.mdx(1 hunks)docs/zh/apis/references/DaemonSet.mdx(1 hunks)docs/zh/apis/references/Deployment.mdx(1 hunks)doom.config.yml(1 hunks)packages/doom/src/runtime/components/OpenAPIRef.tsx(2 hunks)packages/doom/src/runtime/utils.ts(1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-09T03:10:41.010Z
Learnt from: JounQin
Repo: alauda/doom PR: 75
File: src/cli/load-config.ts:4-7
Timestamp: 2025-06-09T03:10:41.010Z
Learning: The alauda/doom project uses yarn v4 as the package manager, not npm. Always reference yarn commands when suggesting package management operations.
Applied to files:
.changeset/shaggy-bees-sort.md
🧬 Code graph analysis (1)
packages/doom/src/runtime/components/OpenAPIRef.tsx (2)
packages/doom/src/runtime/utils.ts (1)
resolveRef(11-22)packages/doom/src/runtime/components/_RefLink.tsx (1)
RefLink(10-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (6)
- GitHub Check: Upload results
- GitHub Check: Build and Lint with Node.js 24 on ubuntu-latest
- GitHub Check: Build and Lint with Node.js 22 on ubuntu-latest
- GitHub Check: Build and Lint with Node.js 20 on ubuntu-latest
- GitHub Check: Build and Lint with Node.js 22 on ubuntu-latest
- GitHub Check: Build and Lint with Node.js 20 on ubuntu-latest
🔇 Additional comments (7)
.changeset/shaggy-bees-sort.md (1)
1-5: LGTM!The changeset format is correct and appropriately documents the patch-level fix for $ref compatibility.
packages/doom/src/runtime/utils.ts (1)
24-40: LGTM!The refactoring simplifies reference path construction by using a more specific base URL and cleaner path suffixes. The changes are consistent and maintain the same functionality.
packages/doom/src/runtime/components/OpenAPIRef.tsx (1)
61-127: Effective refactoring using the newget$Refhelper.The refactoring consistently applies the new
get$Refhelper throughout the component, improving code clarity and maintainability. The logic for handling arrays, objects, and additionalProperties is well-structured.docs/zh/apis/references/DaemonSet.mdx (1)
1-3: LGTM!The documentation structure is clean and correctly uses the
OpenAPIRefcomponent to reference the Kubernetes DaemonSet schema.docs/zh/apis/references/Deployment.mdx (1)
1-3: LGTM!The documentation structure is consistent with the DaemonSet reference page and correctly references the Kubernetes Deployment schema.
docs/zh/apis/advanced-apis/workload/daemonset.mdx (1)
8-11: LGTM!The new
OpenAPIPathblock correctly documents the namespaced DaemonSet API endpoint, complementing the existing non-namespaced path. The format is consistent and the path structure is accurate.doom.config.yml (1)
16-25: All reference URLs are valid and accessible.Verification confirms:
- All 7 Kubernetes documentation URLs return HTTP 200
- All 3 internal reference files exist in the repository
The code changes in
doom.config.ymlare correct and properly configured.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: JounQin <admin@1stg.me>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
close IDP-1353
Summary by CodeRabbit
Bug Fixes
Documentation
Chores