Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Which JsonSchema version is used? Why is $schema not allwoed? #4455

Closed
1 task done
rufreakde opened this issue Jan 19, 2025 · 3 comments
Closed
1 task done

Which JsonSchema version is used? Why is $schema not allwoed? #4455

rufreakde opened this issue Jan 19, 2025 · 3 comments
Labels
awaiting response needs reproducible example Missing a link to a reproduction in the playground, CodeSandbox, JSFiddle, etc. question

Comments

@rufreakde
Copy link

Prerequisites

What theme are you using?

validator-ajv8

What is your question?

I am using c# to export some classes with a tool:
https://github.com/RicoSuter/NJsonSchema

Which seems to export with:
https://json-schema.org/draft-05

With a property within

{
"$schema":"http://json-schema.org/draft-04/schema#"
}

I had to manually modify and delete $schema property.

exampe

@rufreakde rufreakde added needs triage Initial label given, to be assigned correct labels and assigned question labels Jan 19, 2025
@nickgros
Copy link
Contributor

@rufreakde Can you provide an example with the $schema property and explain how it doesn't work? The schema you sent seems to work fine at first glance, and if I add the $schema property to the top level, it still seems to work.

@nickgros nickgros added awaiting response needs reproducible example Missing a link to a reproduction in the playground, CodeSandbox, JSFiddle, etc. and removed needs triage Initial label given, to be assigned correct labels and assigned labels Jan 24, 2025
@rufreakde
Copy link
Author

@nickgros I thought the example worked but somehow the schema references are gone maybe I did something wrong with the playground?

I would need to modify my exporter I will come to it maybe in the upcoming days then I can post a full example.

@rufreakde
Copy link
Author

Okay crazy. It works now... I am very surprised. I should have screenshottet the error message! This was my test.

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Unit",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "Type": {
      "type": "string"
    },
    "Path": {
      "type": "string"
    },
    "Name": {
      "type": "string"
    },
    "ProductionClass": {
      "$ref": "#/definitions/ProductionClass"
    },
    "LuckModifier": {
      "type": "integer",
      "format": "int32"
    },
    "Movement": {
      "$ref": "#/definitions/Movement"
    },
    "Armor": {
      "$ref": "#/definitions/Armor"
    },
    "ArmorModifier": {
      "type": "integer",
      "format": "int32"
    },
    "PrimaryWeapon": {
      "$ref": "#/definitions/Weapon"
    },
    "SecondaryWeapon": {
      "$ref": "#/definitions/Weapon"
    }
  },
  "definitions": {
    "ProductionClass": {
      "type": "string",
      "description": "",
      "x-enumNames": [
        "Ground",
        "Air",
        "Water"
      ],
      "enum": [
        "Ground",
        "Air",
        "Water"
      ]
    },
    "Movement": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "BaseMovement": {
          "type": "integer",
          "format": "int32"
        },
        "CanWalkDrive": {
          "type": "boolean"
        },
        "CanSwim": {
          "type": "boolean"
        },
        "CanFly": {
          "type": "boolean"
        },
        "Weight": {
          "type": "integer",
          "format": "int32"
        },
        "Tires": {
          "$ref": "#/definitions/TiresOrLegs"
        }
      }
    },
    "TiresOrLegs": {
      "type": "string",
      "description": "",
      "x-enumNames": [
        "RubberTires",
        "Chains",
        "HumanLegs",
        "RoboticLegs",
        "Hover",
        "Fly"
      ],
      "enum": [
        "RubberTires",
        "Chains",
        "HumanLegs",
        "RoboticLegs",
        "Hover",
        "Fly"
      ]
    },
    "Armor": {
      "type": "string",
      "description": "",
      "x-enumNames": [
        "LightInfantry",
        "HeavyInfantry",
        "LightVehicle",
        "MediumVehicle",
        "HeavyVehicle",
        "SuperHeavyVehicle"
      ],
      "enum": [
        "LightInfantry",
        "HeavyInfantry",
        "LightVehicle",
        "MediumVehicle",
        "HeavyVehicle",
        "SuperHeavyVehicle"
      ]
    },
    "Weapon": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "Calibre": {
          "$ref": "#/definitions/Calibre"
        },
        "BaseDamage": {
          "type": "integer",
          "format": "int32"
        },
        "canHitGround": {
          "type": "boolean"
        },
        "canHitGroundSpecial": {
          "type": "boolean"
        },
        "canHitAir": {
          "type": "boolean"
        },
        "canHitAirSpecial": {
          "type": "boolean"
        }
      }
    },
    "Calibre": {
      "type": "string",
      "description": "",
      "x-enumNames": [
        "Light",
        "Medium",
        "Heavy",
        "SuperHeavy"
      ],
      "enum": [
        "Light",
        "Medium",
        "Heavy",
        "SuperHeavy"
      ]
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting response needs reproducible example Missing a link to a reproduction in the playground, CodeSandbox, JSFiddle, etc. question
Projects
None yet
Development

No branches or pull requests

2 participants