oasUnnecessaryCombinator
oasUnnecessaryCombinator
examines all schemas in an OpenAPI 3.x specification to identify combinators (allOf
, anyOf
, oneOf
) that contain only a single item. These single-item combinators are unnecessary and should be replaced with their content directly.
The function iterates through all schemas in the document using the flattened schema collection from the DrDocument, ensuring no schema is checked twice through caching mechanisms.
For each schema found with a single-item combinator, the function reports the unnecessary usage and suggests direct replacement.
Example ruleset configuration
no-unnecessary-combinator:
description: "Schema combinators with only one item should be replaced directly"
type: "style"
recommended: true
severity: "warn"
given: "$"
resolved: true
then:
function: "oasUnnecessaryCombinator"
The function is used by the no-unnecessary-combinator Rule