Skip to main content

valid-schema-pattern-properties-key

Overview

This rule belongs to the openapi-v3-syntax-linting ruleset and states that:

The unique key of each entry in the Schema Object patternProperties property must be a valid regular expression, according to the ECMA-262 regular expression dialect. It is recommended to restrict yourself to following regular expression tokens: individual Unicode characters, as defined by the JSON specification [RFC8259], simple character classes ([abc]), range character classes ([a-z]), complemented character classes ([^abc], [^a-z]), simple quantifiers: + (one or more), * (zero or more), ? (zero or one), and their lazy versions (+?, *?, ??), range quantifiers: {x} (exactly x occurrences), {x,y} (at least x, at most y, occurrences), {x,} (x occurrences or more), and their lazy versions, the beginning-of-input (^) and end-of-input ($) anchors.

PropertyValue
EnabledYes
Maximum SeverityWarning
MessageKey provided for the Schema Object patternProperties entry is invalid.
CodeOPENAPI3SYNTAX_L143
TypeLinting
Rule SystemSyntax
Broad CategorySchemas
Products ImpactedAPI Transformer, Code Generation, Developer Experience Portal
Tagsopenapi3 openapi syntax linting regex pattern pattern properties json schema schema

Suggested Fixes

  • Ensure that the key value is a valid regex expression.
  • Ensure that the key value is properly escaped i.e. any reserved characters are appropriately handled.
  • Ensure that the regex expression is valid according to the ECMA 262 dialect of regular expressions.
  • Ensure that the regex pattern uses allowed tokens only.

For More Information