foxglove / community

This repo hosts our org-wide discussion board
0 stars 0 forks source link

Foxglove Studio does not appear to understand json-schema $ref in schemas #961

Closed kenaniah closed 7 months ago

kenaniah commented 8 months ago

Description

It appears as though Foxglove Studio does not properly parse json-schema schemas. The following reproduction steps suggest that $ref is not handled, and the Foxglove Studio documentation does not make it clear which features of json-schema are supported or not supported.

Steps To Reproduce

  1. Add a channel with a json-schema that uses references, for example:
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "TracksMessage",
  "type": "object",
  "required": [
    "objects",
    "total"
  ],
  "properties": {
    "objects": {
      "type": "array",
      "items": {
        "$ref": "#/definitions/TrackObject"
      }
    },
    "total": {
      "type": "integer",
      "format": "uint",
      "minimum": 0.0
    }
  },
  "definitions": {
    "TrackObject": {
      "type": "object",
      "required": [
        "altitude",
        "first_seen",
        "heading",
        "id",
        "last_seen",
        "latitude",
        "longitude",
        "source_type"
      ],
      "properties": {
        "altitude": {
          "type": "number",
          "format": "double"
        },
        "first_seen": {
          "type": "string",
          "format": "date-time"
        },
        "heading": {
          "type": "number",
          "format": "double"
        },
        "id": {
          "type": "string"
        },
        "last_seen": {
          "type": "string",
          "format": "date-time"
        },
        "latitude": {
          "type": "number",
          "format": "double"
        },
        "longitude": {
          "type": "number",
          "format": "double"
        },
        "on_ground": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "source_type": {
          "$ref": "#/definitions/SourceType"
        },
        "tail_number": {
          "type": [
            "string",
            "null"
          ]
        }
      }
    },
    "SourceType": {
      "description": "Source type",
      "oneOf": [
        {
          "description": "ADS-B",
          "type": "string",
          "enum": [
            "ADSB"
          ]
        },
        {
          "description": "FAA Terrestrial",
          "type": "string",
          "enum": [
            "ASDI"
          ]
        }
      ]
    }
  }
}
  1. Record some data to that topic in an MCAP file.

  2. Attempt to open the MCAP file in Foxglove Studio

Expected Behavior

File should open without issues and the topic's schema should be parsed correctly.

Actual Behavior Screenshot 2024-02-01 at 10 48 12 AM

Error in topic ... (channel 1): Unsupported type undefined for array item objects

foxhubber[bot] commented 8 months ago

Internal tracking ticket: FG-6486