Skip to content

fix: scope property annotations to offering anyOf/oneOf alternatives - #185

Open
SHUBHANSHU602 wants to merge 17 commits into
hyperjump-io:mainfrom
SHUBHANSHU602:fix/168-alternative-annotations
Open

SHUBHANSHU602 wants to merge 17 commits into
hyperjump-io:mainfrom
SHUBHANSHU602:fix/168-alternative-annotations

Conversation

@SHUBHANSHU602

Copy link
Copy Markdown

Summary

Fixes #168 by preventing annotations from one anyOf/oneOf alternative from incorrectly affecting properties offered by other alternatives.

Previously, a property's doNotSuggest or deprecated annotation could be treated as unconditional even when another alternative offered the same property without that annotation.

Changes

  • Reconcile annotations per property pointer, considering only alternatives that offer that property.
  • Compare annotation keyword values, not just keyword presence.
  • Preserve shared location annotations while handling non-shared annotations conditionally.
  • Update both the existing-property evaluation path and the completion-merging paths.
  • Prevent property-level annotations from incorrectly affecting value completions.
  • Add regression tests for anyOf, oneOf, nested alternatives, deeper child locations, doNotSuggest, and deprecated.

Testing

Verified locally on Windows:

  • npm --prefix language-server test — 617 tests passed across 21 files
  • npm --prefix language-server run type-check — Passed
  • npm --prefix language-server run lint — Passed
image

Feedback requested

@jdesrosiers, I've followed the per-pointer and per-keyword approach we discussed in #168.

I'd particularly appreciate feedback on mergeAlternativeAnnotations and reconcileAlternativeValueSets, especially the distinction between property-location annotations and annotations associated with possible values.

I've opened this as a draft PR for early architectural review.

@SHUBHANSHU602
SHUBHANSHU602 marked this pull request as draft November 4, 2026 07:22
@SHUBHANSHU602
SHUBHANSHU602 marked this pull request as ready for review November 9, 2026 04:49
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@jdesrosiers jdesrosiers left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this is on the right track. I pushed tests to your branch.

The "suggested before the discriminant is typed" test passes. The rest are regressions (pass on main, fail here):

  1. Differing child titles are lost from key hover and completion docs.
  2. defaultSnippets from a single alternative aren't offered.
  3. A $ref title and a sibling title in one alternative are treated as a conflict (sharedAnnotationKeywords).
  4. A schema applied twice duplicates its annotations, because withoutSharedKeywords defeats the identity dedupe.

The cause is that every keyword gets reconciled. Only doNotSuggest and deprecated need to be.

@SHUBHANSHU602

Copy link
Copy Markdown
Author

@jdesrosiers Please review it ,when u have time.

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.

Annotations from one anyOf/oneOf alternative apply to properties from every alternative

2 participants