redocly-cli
redocly-cli copied to clipboard
Improve sort order in assertions
How it is works now
if you want a sort property that contains an array of primitives, the config would look like this:
assert/sort-something:
subject:
type: Schema
property: enum
assertions:
sortOrder:
direction: 'asc'
If the property contains an array of objects, you must specify the property you want to sort by
Example:
assert/sort-something:
subject:
type: PathItem
property: parameters
assertions:
sortOrder:
direction: 'asc'
property: name # The name of the property by which the sorting occurs
If you do not specify subject property, sortOrder will use an array of object keys
Example:
assert/sort-something:
subject:
type: PathItem
assertions:
sortOrder:
direction: 'asc'
Will check sort order of keys from PathItemObject: [ 'summary', 'parameters', 'get' ]
Problem
If you have an array of objects and don't specify a subject: property
sortOrder will check order of the keys in each object
Solution
Check if subject: type
is an array type and subject: property
not specified then check the sort order by value (instead key) and if assertion: property
not specified display the warning message
If you have any questions, thoughts or ideas please add them here @adamaltman @tatomyr