You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please describe your feature request.
I wish I could use yq to sort 'keywords' in JSON Schema files by a certain order, i.e. title and description first. Sorting alphabetically with sort_keys(..) puts title after many other common keywords, which make schemas less usable as documentation when read as-is.
My idea for syntax would be to extend the sort_keys() function with an argument that describes the order one wants, here imagined as an array with keys in the wished order. Keys not part of that array could go in alphabetical order after those. The argument could also be some keyword referencing an ordering function, that defaults to alphabetic. I assume passing a whole function would be out of scope for yq.
Describe the solution you'd like
If we have schema1.yml like:
(please keep to around 10 lines )
additionalProperties: falsedescription: | This schema describes the foo-bar thing which consists of a string foo and a number bar.properties:
bar:
title: and the bartype: numberfoo:
title: the footype: stringtitle: An example schematype: object
title: An example schemadescription: | This schema describes the foo-bar thing which consists of a string foo and a number bar.type: objectproperties:
foo:
title: the footype: stringbar:
title: and the bartype: numberadditionalProperties: false
Describe alternatives you've considered
Doing it manually.
Writing some sort of dedicated tool for this job.
The text was updated successfully, but these errors were encountered:
Please describe your feature request.
I wish I could use yq to sort 'keywords' in JSON Schema files by a certain order, i.e.
title
anddescription
first. Sorting alphabetically withsort_keys(..)
putstitle
after many other common keywords, which make schemas less usable as documentation when read as-is.My idea for syntax would be to extend the
sort_keys()
function with an argument that describes the order one wants, here imagined as an array with keys in the wished order. Keys not part of that array could go in alphabetical order after those. The argument could also be some keyword referencing an ordering function, that defaults toalphabetic
. I assume passing a whole function would be out of scope for yq.Describe the solution you'd like
If we have schema1.yml like:
(please keep to around 10 lines )
And we run a command:
yq -P -i 'sort_keys(.., ["title", "description", "type", "properties", "additionalProperties"])' schema1.yaml
it could output
Describe alternatives you've considered
The text was updated successfully, but these errors were encountered: