Skip to content

[2.x] Fix container diagnostics for external JSON Pointer references - #1327

Merged
stevehu merged 1 commit into
2.xfrom
fix/1325-ref-container-keywords-2x
Oct 13, 2026
Merged

stevehu merged 1 commit into
2.xfrom
fix/1325-ref-container-keywords-2x

Conversation

@stevehu

@stevehu stevehu commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Related to #1325

Port the external-reference container fix to 2.x. An external $ref to doc.yaml#/components/schemas/Item loads the document without its fragment before selecting the target, so the #1205 fix did not suppress unknown OpenAPI root fields on this path. Mark that load as a container and give it a separate registry cache. Direct registry loads retain their own diagnostics and strict-factory rejection regardless of registry load order; target-schema and subschema keywords still reach the configured factory.

Move the container annotation fallback into Dialect.newValidator, after the error-message, nullable, and discriminator special cases. Make the container marker volatile. The new public SchemaContext.isDocumentContainer(Schema) query allows the dialect package to inspect it.

Known limitation: references within one schema still share loaded documents. If a JSON Pointer reference loads a document before a whole-document reference to it, the latter reuses the container and suppresses root diagnostics, including strict-factory rejection. Reversing that order retains normal root diagnostics. This limitation is documented; reference traversal is unchanged.

Validation:

  • Full suite on Java 8 (Amazon Corretto 8.0.432): 8,743 tests, 0 failures, 0 errors, 31 skipped.
  • All 19 new recording-factory regression cases pass, covering external references, both OpenAPI dialects, preload/cache settings, strict factories, registry load ordering, anchors/whole-document references, $id and nested dialects, and special-keyword ordering.
  • Independent review reported 18 of the 19 new cases failing against the original implementation on both branches.
  • git diff --check passes. Final publication edits only clarify the documented limitation.

@stevehu
stevehu merged commit d25a6e5 into 2.x Oct 13, 2026
5 checks passed
@stevehu
stevehu deleted the fix/1325-ref-container-keywords-2x branch October 23, 2026 06:54
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.

1 participant