Skip to content

Fix type-checking rules to accept allOf, anyOf, and oneOf#44

Merged
Gérald Barré (geraldbarre-workleap) merged 1 commit intomainfrom
feature/FENG-2021
Mar 5, 2026
Merged

Fix type-checking rules to accept allOf, anyOf, and oneOf#44
Gérald Barré (geraldbarre-workleap) merged 1 commit intomainfrom
feature/FENG-2021

Conversation

@geraldbarre-workleap
Copy link
Contributor

@geraldbarre-workleap Gérald Barré (geraldbarre-workleap) commented Mar 5, 2026

Jira issue link: FENG-2021

Summary

  • The Spectral type-checking rules (schema-object-must-have-a-type, items-must-have-a-type, schemas-properties-must-have-a-type, path-schema-properties-must-have-a-type) only accepted type or $ref as valid schema definitions
  • Schemas using OpenAPI composition keywords (allOf, anyOf, oneOf) were incorrectly flagged as errors — for example, schemas using allOf for inheritance or oneOf for polymorphism (discriminator patterns)
  • Added allOf, anyOf, and oneOf as accepted alternatives in all four type-checking rules

Test plan

  • Ran spectral lint against a test spec containing allOf (inheritance) and oneOf (discriminator) patterns — no false positives
  • Verify existing specs in downstream repos still pass linting

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the repository’s Spectral ruleset so OpenAPI schemas using composition keywords aren’t incorrectly flagged by the “must-have-a-type” lint rules.

Changes:

  • Extend all four type-checking rules to treat allOf, anyOf, and oneOf as valid schema definitions (in addition to type and $ref).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

…ype requirements; add new test specifications for valid compositions.
@geraldbarre-workleap Gérald Barré (geraldbarre-workleap) merged commit e12f758 into main Mar 5, 2026
7 checks passed
@geraldbarre-workleap Gérald Barré (geraldbarre-workleap) deleted the feature/FENG-2021 branch March 5, 2026 17:44
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.

3 participants