Bungie-net / api

Resources for the Bungie.net API
Other
1.22k stars 92 forks source link

Documentation: Document when dictionary keys are hashes #1373

Open joshhunt opened 3 years ago

joshhunt commented 3 years ago

In the OpenAPI spec, dictionary keys are specified with the custom extension x-dictionary-key. It would be exceptionally helpful (for all three of us who're building tooling from the JSON spec) if this also included the x-mapped-definition reference for when the dictionary key is a hash referencing definition.

For example:

"Destiny.Components.Records.DestinyRecordsComponent": {
  "type": "object",
  "properties": {
    "records": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/components/schemas/Destiny.Components.Records.DestinyRecordComponent"
      },
      "x-dictionary-key": {
        "type": "integer",
        "format": "uint32",
+        "x-mapped-definition": {
+          "$ref": "#/components/schemas/Destiny.Definitions.Records.DestinyRecordDefinition"
+        }
      }
    },

I hope this relationship information is available and can be documented in the API spec!

joshhunt commented 3 years ago

Oh, it turns out the these relationships are documented, but just not how I would have expected, and not everywhere 😅

It's there fine on DestinyCollectiblesComponent

"Destiny.Components.Collectibles.DestinyCollectiblesComponent": {
  "type": "object",
  "properties": {
    "collectibles": {
      "type": "object",
      "additionalProperties": {
        "$ref": "#/components/schemas/Destiny.Components.Collectibles.DestinyCollectibleComponent"
      },
      "x-mapped-definition": {
        "$ref": "#/components/schemas/Destiny.Definitions.Collectibles.DestinyCollectibleDefinition"
      },
      "x-dictionary-key": {
        "type": "integer",
        "format": "uint32"
      }
    },

and on a few other components (it's there on DestinyPresentationNodesComponent and DestinyItemStatBlockDefinition.stats), but it would be really nice if it was included in more places (such as DestinyRecordsComponent ) 🙂