voxpupuli / json-schema

Ruby JSON Schema Validator
MIT License
1.53k stars 242 forks source link

Properties as Property not working #273

Closed Zilev closed 8 years ago

Zilev commented 8 years ago

Hi, I would like to something like this:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "$schema": {
      "type": "string"
    },
    "title": {
      "type": "string"
    },
    "properties": {
      "type": "object",
      "enum": "metadata"
    },
    "required": {
      "type": "array",
      "items": {
        "metadata": "string"
      }
    }
  }
}

but this part is not working well:

"properties": {
      "type": "object",
      "enum": "metadata"
 },

Is possible to do this? or is estrictamente prohibido to use those built schema words like: "required", "enum", "properties" as a property inside "properties"?. Thanks in advance for helping me to understand this part :smile:

Zilev commented 8 years ago

I see, sorry, my mistake, I've created wrong the json schema, updating my json schema I dont have problems with properties as properties any more :)

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "id": "http://jsonschema.net",
  "type": "object",
  "properties": {
    "title": {
      "type": "string"
    },
    "type": {
      "type": "string"
    },
    "properties": {
      "type": "object",
      "properties": {
        "myData": {
          "type": "object"
        }
      }
    },
    "required": {
      "type": "array",
      "items": {
        "type": "string"
      }
    }
  }
}

Is working fine :)