dd-sdk-android icon indicating copy to clipboard operation
dd-sdk-android copied to clipboard

Improvements to JSON Schema

Open jonfreedman opened this issue 4 years ago • 2 comments

I'm just looking at generating some code using your JSON schema files, I have a few improvements to suggest

The date field in _common_schema.json is defined with type=integer but if you were to also use format=int64 then languages that support it would generate this as a long rather than an int e.g.

    "date": {
      "type": "integer",
      "format": "int64",
      "description": "Start of the event in ms from epoch",
      "minimum": 0,
      "readOnly": true
    }

Also your resource-schema.json and view-schema.json files add fields to the _dd object but don't reference the common one which leads to the format_version property being missed by code gen.

They can be improved by referencing the common _dd e.g.

        "_dd": {
          "type": "object",
          "description": "Internal properties",
          "required": ["document_version"],
          "allOf": [
            { "$ref": "_common-schema.json#/properties/_dd" },
            {
              "properties": {
                "document_version": {
                  "type": "integer",
                  "description": "Version of the update of the view event",
                  "minimum": 0,
                  "readOnly": true
                }
              }
            }
          ],
          "readOnly": true
        }

jonfreedman avatar Sep 20 '21 10:09 jonfreedman

https://github.com/DataDog/dd-sdk-android/blob/master/dd-sdk-android/src/main/json/rum/view-schema.json should also have the same reference back to the view in _common-schema.json as with _dd

jonfreedman avatar Sep 20 '21 16:09 jonfreedman

Hi @jonfreedman , thanks for those suggestions, we'll take some time to look into this.

xgouchet avatar Sep 21 '21 07:09 xgouchet