Skip to main content

schema-then-only-with-if-clause

Overview

This rule belongs to the openapi-v3-standards-validation ruleset and states that:

Property then can be used in a Schema Object along with the if clause to apply subschemas conditionally. When if is not present, the then property will be entirely ignored.

PropertyValue
EnabledYes
Maximum SeverityError
MessageSchema Object property then used without the if clause.
CodeOPENAPI3STANDARDS_V346
TypeValidation
Rule SystemSemantic
Broad CategorySchemas
Products ImpactedAPI Transformer, Code Generation, Developer Experience Portal
Tagsopenapi3 openapi standards semantic validation if then json schema schema

Suggested Fixes

  • Add the subschema in the Schema Object that needs to be evaluated, using the if property.
  • If you do not want to apply a subschema conditionally remove the then property from the Schema Object.
  • Only schemas that are valid against a subschema in if are evaluated against the then subschema. Therefore, property then alone has no effect during schema validation and works along with if to produce the overall evaluation result.

For More Information