Skip to content

AEP-0140 Linter Rules

Rules for AEP-140- Field Names # Rules for AEP-140: Field Names

Rule: Boolean properties should omit the prefix “is”.

This rule enforces that all boolean properties don’t start with the prefix “is”.

This rule looks for “boolean” properties and complains if the ‘boolean’ field name starts with the prefix “is”.

Incorrect code for this rule:

schemas:
{
'book':
{
'type': 'object',
'properties':
{
'isbn': { 'type': 'array', 'items': { 'type': 'string' } },
'is_published': { 'type': 'boolean' }

Correct code for this rule:

schemas:
{
'book':
{
'type': 'object',
'properties':
{
'isbn': { 'type': 'array', 'items': { 'type': 'string' } },
'published': { 'type': 'boolean' }

If you need to violate this rule for a specific operation, add an “override” to the Spectral rule file for the specific file and fragment.

overrides:
- files:
- 'openapi.json#/components/schemas/book/properties/is_published'
rules:
aep-140-boolean-field-naming: 'off'

Rule: Properties representing URLs or URIs should be named “uri” rather than “url”.

This rule checks that all “url” properties are named in accordance with the AEP-140 ruleset.

This rule complains if there are any string properties named “url”.

Incorrect code for this rule:

schemas:
{
'book':
{
'type': 'object',
'properties':
{
'url': { 'type': 'string', 'readOnly': true },
'published': { 'type': 'boolean' }

Correct code for this rule:

schemas:
{
'book':
{
'type': 'object',
'properties':
{
'uri': { 'type': 'string', 'readOnly': true },
'published': { 'type': 'boolean' }

If you need to violate this rule for a specific operation, add an “override” to the Spectral rule file for the specific file and fragment.

overrides:
- files:
- 'openapi.json#/components/schemas/book/properties/url'
rules:
aep-140-uri-field-naming: 'off'