santhosh-tekuri/jsonschema

Extension.Validate provides data in inconsistent order

hadar-co opened this issue · 1 comments

Hi:)

I am using a custom keyword to perform some validations of properties in a specific location in a YAML.

For example, here is a ConfigMap YAML I'm using:

apiVersion: v1
kind: ConfigMap
metadata:
  name: game-demo
data:
  player_initial_lives: "3"
  game.properties: enemy.types=aliens,monsters
  user-interface.properties: color.good=purple

I created a custom key in my schema under "data", and as expected in the Validate function I get all 3 properties under it, but their order is different in every run - sometimes they appear in their correct order (as in the YAML), and sometimes they are sorted alphabetically for some reason.

Some of my validations rely on their original order, so this randomness throws them off.
Any idea why this is happening?

I would be happy to provide any more info.
Thanks!

This library does not parse yaml document. Your application must be parsing the yaml using some external library. It is yaml parsing library that is not retaining the order. Check documentation of the yaml library to see if they provide any option to retain the order.