Skip to content

Make ordering of keys consistent #641

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
retrosight opened this issue Jul 20, 2018 · 6 comments · Fixed by #714
Closed

Make ordering of keys consistent #641

retrosight opened this issue Jul 20, 2018 · 6 comments · Fixed by #714

Comments

@retrosight
Copy link

It's the little details that matter in life -- we love consistency, so let's bring it to all of the schemas.

One example of many...

"$schema": "http://json-schema.org/draft-08/hyper-schema#",     "$id": "http://json-schema.org/draft-08/hyper-schema-output",
"$id": "http://json-schema.org/draft-08/hyper-schema#",         "$schema": "http://json-schema.org/draft-08/schema#",
"title": "JSON Hyper-Schema",                                   [Missing]
...
@awwright
Copy link
Member

It would seem to me that, if order matters, $schema should go first, since that's the key that gives all the others their meaning.

... with the exception of $id, so I could be persuaded otherwise.

@gregsdennis
Copy link
Member

While I understand the motivation of this (and agree somewhat), it feels weird to me that the sequence of keys in a key-value pair collection matters. The entire purpose of having the key-value paradigm is to get around requiring order and allow easy access to the values.

Furthermore JSON declares that while arrays are to be considered "ordered" (or, more properly, "sequenced"), objects are not. This may cause confusion with authors and consumers.


@retrosight are you asking for this to help with schema equality comparisons, or do you have another purpose?

@gregsdennis
Copy link
Member

See also #538 & #475

handrews added a commit that referenced this issue Sep 20, 2018
@retrosight
Copy link
Author

Yes, I understand order does not matter to the computers. ;-) I'm looking for the consistency to aid learning while reading between different schemas. The reader doesn't have to context switch the order.

@Relequestual
Copy link
Member

I have no issue with ordering the meta schemas we provide.
They ARE intended to be read by humans, and so we should make that as easy as possible, where possible.

PR welcome.

@handrews handrews added this to the draft-08 milestone Feb 23, 2019
@handrews
Copy link
Contributor

handrews commented Feb 23, 2019

I'm fine with this- order (as it relates to our published meta-schemas and whatnot) should be:

  1. $schema
  2. $id
  3. $vocabulary
  4. $recursiveAnchor
  5. base (Hyper-Schema)
  6. title
  7. description
  8. $ref, $recursiveRef, or an allOf of those things
  9. type
  10. type-specific validation and applicator keywords
  11. default and examples
  12. links (Hyper-Schema)
  13. $defs

I just updated all of the meta-schemas in a PR. I'm not 100% sure I got all of them in the same order, it's late so I'll look at it tomorrow or anyone else feel free to comment on PR #714

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants