{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "title": "Resource Model Schema",
  "description": "This is the schema for resource models for api-pls. For more, see https://github.com/jmeas/api-pls",
  "type": "object",
  "additionalProperties": false,
  "required": ["name"],
  "properties": {
    "name": {
      "type": "string"
    },
    "plural_form": {
      "type": "string"
    },
    "actions": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "create": {
          "type": "boolean"
        },
        "read_one": {
          "type": "boolean"
        },
        "read_many": {
          "type": "boolean"
        },
        "update": {
          "type": "boolean"
        },
        "delete": {
          "type": "boolean"
        }
      }
    },
    "pagination": {
      "oneOf": [
        {
          "type": "object",
          "additionalProperties": false,
          "properties": {
            "default_page_size": {
              "type": "integer",
              "minimum": 1
            },
            "default_page_number": {
              "type": "integer",
              "minimum": 0
            },
            "enabled": {
              "type": "boolean"
            }
          }
        },
        {
          "type": "boolean"
        }
      ]
    },
    "attributes": {
      "type": "object",
      "patternProperties": {
        ".": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "type": {
                  "type": "string"
                },
                "nullable": {
                  "type": "boolean"
                },
                "default": {
                  "type": "string"
                }
              }
            }
          ]
        }
      }
    },
    "meta": {
      "type": "object",
      "patternProperties": {
        ".": {
          "oneOf": [
            {
              "type": "string"
            },
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "type": {
                  "type": "string"
                },
                "nullable": {
                  "type": "boolean"
                },
                "default": {
                  "type": "string"
                }
              }
            }
          ]
        }
      }
    },
    "relationships": {
      "type": "object",
      "patternProperties": {
        ".": {
          "oneOf": [
            {
              "type": "string",
              "enum": ["many-to-one", "one-to-many", "one-to-one", "many-to-many"]
            },
            {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "resource": {
                  "type": "string"
                },
                "cardinality": {
                  "type": "string",
                  "enum": ["many-to-one", "one-to-many", "one-to-one", "many-to-many"]
                },
                "host": {
                  "type": "boolean"
                }
              }
            }
          ]
        }
      }
    },
    "built_in_meta": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "created_at": {
          "type": "boolean"
        },
        "updated_at": {
          "type": "boolean"
        }
      }
    }
  }
}
