valid-schema-dollar-anchor-format
Overview
This rule belongs to the openapi-v3-syntax-validation
ruleset and states that:
Property $anchor
in a Schema Object is an identifier keyword used for creation of named fragments. The value of this property must start with a letter ([A-Za-z]) or underscore (_
), followed by any number of letters, digits ([0-9]), hyphens (-
), underscores (_
), and periods (.
).
Property | Value |
---|---|
Enabled | Yes |
Maximum Severity | Error |
Message | Value for $anchor in Schema Object is invalid. |
Code | OPENAPI3SYNTAX_V141 |
Type | Validation |
Rule System | Syntax |
Broad Category | Schemas |
Products Impacted | API Transformer, Code Generation, Developer Experience Portal |
Tags | openapi3 openapi syntax validation $anchor anchor json schema schema |
Suggested Fixes
- Ensure that the $anchor value does not contain any forbidden characters.
- Ensure that the $anchor value follows the regex pattern: ^[A-Za-z_]+[A-Za-z0-9-_.]*$
- Use only alpha-numeric characters, underscores, hyphens, and periods.
- Ensure that the starting character is a letter or underscore. Numbers and other symbols cannot be used to start an $anchor value.
For More Information
- https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-8.2.2
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schema-object
- https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#openapi-specification
- https://docs.apimatic.io/rulesets/overview/