open-contracting / extension-explorer

Disclose more data about your contracting processes, using extensions to the Open Contracting Data Standard
https://extensions.open-contracting.org/
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

Schema key ordering #77

Closed duncandewhurst closed 1 year ago

duncandewhurst commented 1 year ago

The ordering of keys in the schema files served by the Extension Explorer differs from the ordering in the schema files in extension GitHub repositories.

It's not a major problem, but when working on standard development, I often use the OCDS Extensions Field and Code Search tool to find a property or definition from which I can reuse a snippet of schema. That tool links to the documentation pages in the Extension Explorer so the natural thing to do is to copy-paste snippets from the schema files served by the Extension Explorer. However, I then need to manually reorder keys, e.g. to put title first.

For example, the keys in the bid extension's SimpleIdentifier definition are ordered as follows in release-schema.json on GitHub:

{
      "title": "Simple identifier",
      "description": "An unambiguous reference to a resource within a given context.",
      "type": "object",
      "properties": {
        "scheme": {
          "title": "Scheme",
          "description": "The list, register or system from which the identifier is taken.",
          "type": [
            "string",
            "null"
          ],
          "minLength": 1
        },
        "id": {
          "title": "ID",
          "description": "The identifier taken from the scheme.",
          "type": [
            "string",
            "null"
          ],
          "versionId": true,
          "minLength": 1
        }
      },
      "minProperties": 1
}

Whilst in release-schema.json served by the Extension Explorer they are ordered as follows:

{
      "description": "An unambiguous reference to a resource within a given context.",
      "extension_explorer:source": {
        "identifier": "bids",
        "version": "master"
      },
      "minProperties": 1,
      "properties": {
        "id": {
          "description": "The identifier taken from the scheme.",
          "minLength": 1,
          "title": "ID",
          "type": [
            "string",
            "null"
          ],
          "versionId": true
        },
        "scheme": {
          "description": "The list, register or system from which the identifier is taken.",
          "minLength": 1,
          "title": "Scheme",
          "type": [
            "string",
            "null"
          ]
        }
      },
      "title": "Simple identifier",
      "type": "object"
}
jpmckinney commented 1 year ago

Unbelievably, Flask thinks it's best to sort keys (based on a Python < 3.5 context). Anyway, fixed now!

duncandewhurst commented 1 year ago

Oh, I didn't even twig they were sorted alphabetically. Thanks!