Improve sort order in assertions
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 1.5k
- Forks
- 228
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 48
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the sortOrder assertion implementation and its tests; the issue provides YAML examples for primitive arrays, object arrays, and omitted subject properties. Trace how subject type and property are interpreted, then add coverage for sorting array values and for the warning when assertion property is absent.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100