Skip to content

fix(schema): apply additive JSON Schema semantics to $ref sibling getters#2921

Merged
baywet merged 1 commit into
microsoft:mainfrom
aqeelat:fix/schema-reference-sibling-semantics
Jul 16, 2026
Merged

fix(schema): apply additive JSON Schema semantics to $ref sibling getters#2921
baywet merged 1 commit into
microsoft:mainfrom
aqeelat:fix/schema-reference-sibling-semantics

Conversation

@aqeelat

@aqeelat aqeelat commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Following the discussion in #2919 with @handrews and @baywet, this PR is now documentation-only.

Changes

Adds XML documentation to OpenApiSchemaReference clarifying that convenience getters return authored sibling keyword values from Reference before falling back to resolved Target values. These getters are object-model conveniences and do not represent JSON Schema evaluation semantics.

Rationale

The reference-first getter behavior (Reference.X ?? Target?.X) was an explicit design decision (#2903). Per #2919:

  • Assertion keywords alongside $ref are additive in JSON Schema evaluation, not overrides
  • The library does not perform validation — splitting getter behavior per keyword type creates setter/getter asymmetry and keyword-specific edge cases
  • The safest direction is to keep consistent reference-first getters and document the contract explicitly

Consumers that need precise JSON Schema semantics should inspect both Reference and Target, or use a JSON Schema validator.

Fixes #2919

@aqeelat aqeelat requested a review from a team as a code owner July 2, 2026 11:46
@handrews

handrews commented Jul 2, 2026

Copy link
Copy Markdown

I'm not entirely sure the additionalProperties and unevaluatedProperties behaviors are correct. Both of those have behavior that is highly dependent on their exact schema location. In particular, additionalProperties can only be evaluated in terms of its immediate adjacent keywords in the same schema object. And for unevaluatedProperties, the behavior of placing in in the $ref source vs target is very different. Based purely on the comments (I haven't had time to try to understand the code- this is not an ecosystem with which I am familiar) this also seems to treat both as booleans, when either could also be a non-trivial schema of some sort.

aqeelat added a commit to aqeelat/OpenAPI.NET that referenced this pull request Jul 2, 2026
…erence-first

Per feedback from @handrews on microsoft#2921: additionalProperties and
unevaluatedProperties are location-sensitive applicators whose behavior
depends on their exact schema location and adjacent keywords. They cannot
be safely collapsed into a single effective boolean.

Revert both from AND logic back to reference-first convenience accessors,
matching the non-lossless keyword bucket.
@aqeelat aqeelat force-pushed the fix/schema-reference-sibling-semantics branch from 4428272 to caff711 Compare July 15, 2026 17:51
baywet
baywet previously approved these changes Jul 15, 2026

@baywet baywet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thank you for making the changes!

@baywet baywet enabled auto-merge (squash) July 15, 2026 17:54
@baywet baywet requested a review from Copilot July 15, 2026 17:56

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.

Pull request overview

Documentation-only update to clarify OpenApiSchemaReference’s contract when accessing JSON Schema keywords alongside $ref, aligning with the discussion in #2919 and preserving the existing “reference-first, then target” convenience getter behavior.

Changes:

  • Add XML documentation to OpenApiSchemaReference explaining that convenience getters return sibling keyword values authored on Reference before falling back to resolved Target values.
  • Clarify that these getters are object-model conveniences and not JSON Schema evaluation semantics.

Comment thread src/Microsoft.OpenApi/Models/References/OpenApiSchemaReference.cs Outdated
auto-merge was automatically disabled July 15, 2026 20:39

Head branch was pushed to by a user without write access

@aqeelat aqeelat force-pushed the fix/schema-reference-sibling-semantics branch from caff711 to db240a2 Compare July 15, 2026 20:39
@aqeelat aqeelat force-pushed the fix/schema-reference-sibling-semantics branch from db240a2 to 018c13b Compare July 15, 2026 20:43
@baywet baywet enabled auto-merge (squash) July 16, 2026 13:34
@baywet baywet merged commit 0b31edd into microsoft:main Jul 16, 2026
8 of 9 checks passed
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.

Clarify or revise OpenApiSchemaReference semantics for $ref sibling keywords

4 participants