Skip to content

AEP-0144 Linter Rules

Rules for AEP-144- Array fields # Rules for AEP-144: Array fields

Rule: The operation ID must begin with the word add or remove.

This rule enforces that all standard UpdateArray methods have an operationId field with a value that begins with “add” or “remove” prefix.

This rule looks for “UpdateArray” operations and complains if the ‘operationId’ field is not present or if the value does not begin with “add” or “remove”.

Incorrect code for this rule:

paths:
# Missing operationId
'/books:addBook':
post:
summary: Add book
responses:
# operationId present but does not start with "remove"
'/publishers:removePublisher':
post:
summary: Delete publisher
operationId: deletePublisher

Correct code for this rule:

paths:
'/books:removeBook':
post:
summary: Remove book
operationId: removeBook

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#/books:removeBook/post/operationId'
rules:
aep-144-operation-id: 'off'

Rule: An Update Array operation must be POST.

This rule enforces that all UpdateArray operations use POST method.

This rule looks for “UpdateArray” operations and complains if operation uses anything except POST method.

Incorrect code for this rule:

paths:
'/books:removeBook':
delete:
summary: Remove book

Correct code for this rule:

paths:
'/books:removeBook':
post:
summary: Remove book
responses:

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#/books:removeBook/delete/operationId'
rules:
aep-144-http-method: 'off'