jsontypedef / json-typedef-spec

The JSON Type Definition specification and official test suite
17 stars 4 forks source link

JSON Schema version? #13

Open delaneyj opened 2 years ago

delaneyj commented 2 years ago

I'd like to enable auto completion tooling in VSCode. Do you know if there is a JSON Schema DraftV7 version of the JTD definition? I know it seems like at odd ask but would make editing and validating schema in an IDE on a team much easier.

I had started one but then thought I'd reach out first

{
  "$schema": "http://json-schema.org/draft-07/schema",
  "$comment": "A JSON Schema for a JSON Type Definition RFC 8927",
  "title": "JSON Type Definition",
  "definitions": {
    "empty": {
      "type": "object",
      "properties": {},
      "additionalProperties": false
    },
    "type": {
      "type": "object",
      "properties": {
        "type": {
          "enum": [
            "boolean",
            "string",
            "timestamp",
            "float32",
            "float64",
            "int8",
            "uint8",
            "int16",
            "uint16",
            "int32",
            "uint32"
          ]
        }
      },
      "required": ["properties"],
      "additionalProperties": false
    },
    "enum": {
      "type": "object",
      "properties": {
        "enum": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "uniqueItems": true
        }
      },
      "required": ["enum"],
      "additionalProperties": false
    },
    "elements": {
      "type": "object",
      "properties": {
        "elements": { "$ref": "#/definitions/schema" }
      },
      "required": ["elements"],
      "additionalProperties": false
    },
    "properties": {
      "type": "object",
      "properties": {
        "properties": {
          "type": "object",
          "additionalProperties": { "$ref": "#/definitions/schema" }
        },
        "optionalProperties": {
          "type": "object",
          "additionalProperties": { "$ref": "#/definitions/schema" }
        },
        "additionalProperties": { "type": "boolean", "default": false }
      },
      "required": ["properties"],
      "additionalProperties": false
    },
    "values": {
      "type": "object",
      "properties": {
        "values": { "$ref": "#/definitions/schema" }
      },
      "required": ["values"],
      "additionalProperties": false
    },
    "discriminator": {
      "type": "object",
      "properties": {
        "discriminator": {
          "type": "string"
        },
        "mapping": {
          "type": "object",
          "additionalProperties": { "$ref": "#/definitions/schema" }
        }
      },
      "required": ["discriminator", "mapping"],
      "additionalProperties": false
    },
    "ref": {
      "type": "object",
      "properties": {
        "ref": { "type": "string" }
      },
      "required": ["ref"],
      "additionalProperties": false
    },
    "schema": {
      "oneOf": [
        { "$ref": "#/definitions/empty" },
        { "$ref": "#/definitions/type" },
        { "$ref": "#/definitions/enum" },
        { "$ref": "#/definitions/elements" },
        { "$ref": "#/definitions/properties" },
        { "$ref": "#/definitions/values" },
        { "$ref": "#/definitions/discriminator" },
        { "$ref": "#/definitions/ref" }
      ]
    }
  },

  "type": "object",
  "properties": {
    "definitions": {
      "type": "object",
      "additionalProperties": { "$ref": "#/definitions/schema" }
    }
  },
  "additionalProperties": {
    "$ref": "#/definitions/schema"
  }
}
ucarion commented 1 year ago

I am not aware of such a schema! Good luck with this effort, this seems valuable!

On Thu, Apr 28, 2022 at 7:14 PM Delaney @.***> wrote:

I'd like to enable auto completion tooling in VSCode https://code.visualstudio.com/docs/languages/json. Do you know if there is a JSON Schema DraftV7 version of the JTD definition? I know it seems like at odd ask but would make editing and validating schema in an IDE on a team much easier.

I had started one but then thought I'd reach out first

{ "$schema": "http://json-schema.org/draft-07/schema", "$comment": "A JSON Schema for a JSON Type Definition RFC 8927", "title": "JSON Type Definition", "definitions": { "empty": { "type": "object", "properties": {}, "additionalProperties": false }, "type": { "type": "object", "properties": { "type": { "enum": [ "boolean", "string", "timestamp", "float32", "float64", "int8", "uint8", "int16", "uint16", "int32", "uint32" ] } }, "required": ["properties"], "additionalProperties": false }, "enum": { "type": "object", "properties": { "enum": { "type": "array", "items": { "type": "string" }, "uniqueItems": true } }, "required": ["enum"], "additionalProperties": false }, "elements": { "type": "object", "properties": { "elements": { "$ref": "#/definitions/schema" } }, "required": ["elements"], "additionalProperties": false }, "properties": { "type": "object", "properties": { "properties": { "type": "object", "additionalProperties": { "$ref": "#/definitions/schema" } }, "optionalProperties": { "type": "object", "additionalProperties": { "$ref": "#/definitions/schema" } }, "additionalProperties": { "type": "boolean", "default": false } }, "required": ["properties"], "additionalProperties": false }, "values": { "type": "object", "properties": { "values": { "$ref": "#/definitions/schema" } }, "required": ["values"], "additionalProperties": false }, "discriminator": { "type": "object", "properties": { "discriminator": { "type": "string" }, "mapping": { "type": "object", "additionalProperties": { "$ref": "#/definitions/schema" } } }, "required": ["discriminator", "mapping"], "additionalProperties": false }, "ref": { "type": "object", "properties": { "ref": { "type": "string" } }, "required": ["ref"], "additionalProperties": false }, "schema": { "oneOf": [ { "$ref": "#/definitions/empty" }, { "$ref": "#/definitions/type" }, { "$ref": "#/definitions/enum" }, { "$ref": "#/definitions/elements" }, { "$ref": "#/definitions/properties" }, { "$ref": "#/definitions/values" }, { "$ref": "#/definitions/discriminator" }, { "$ref": "#/definitions/ref" } ] } },

"type": "object", "properties": { "definitions": { "type": "object", "additionalProperties": { "$ref": "#/definitions/schema" } } }, "additionalProperties": { "$ref": "#/definitions/schema" } }

— Reply to this email directly, view it on GitHub https://github.com/jsontypedef/json-typedef-spec/issues/13, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQUIOJTESGACZ3HI2SE3NTVHNAZPANCNFSM5UUKYN6Q . You are receiving this because you are subscribed to this thread.Message ID: @.***>