Skip to main content

schema-else-only-with-if-clause

Overview

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

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

PropertyValue
EnabledYes
Maximum SeverityError
MessageSchema Object property else used without the if clause.
CodeOPENAPI3STANDARDS_V347
TypeValidation
Rule SystemSemantic
Broad CategorySchemas
Products ImpactedAPI Transformer, Code Generation, Developer Experience Portal
Tagsopenapi3 openapi standards semantic validation if else 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 else property from the Schema Object.
  • Only schemas that are not valid against a subschema in if are evaluated against the else subschema. Therefore, property else alone has no effect during schema validation and works along with if to produce the overall evaluation result.

For More Information