{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://aep.dev/json-schema/extensions/x-aep-resource.json",
  "title": "x-aep-resource",
  "description": "Defines the resource name patterns and naming for an AEP API resource",
  "type": "object",
  "required": [
    "plural",
    "patterns",
    "singular",
    "type"
  ],
  "properties": {
    "plural": {
      "type": "string",
      "description": "The plural form of the resource name",
      "pattern": "^[a-z][a-z0-9-]*$"
    },
    "parents": {
      "type": "array",
      "description": "The parent resources of this resource.",
      "items": {
        "type": "string",
        "pattern": "^[a-z0-9][a-z0-9.-]*/[a-z0-9][-a-z0-9]*$",
        "examples": [
          "library.example.com/author",
          "library.example.com/user-profile"
        ]
      }
    },
    "patterns": {
      "type": "array",
      "description": "The resource name patterns that are valid for this resource",
      "items": {
        "type": "string",
        "pattern": "^[a-z][a-z0-9-]*(/\\{[a-z][a-z0-9_]*\\}|[a-z][a-z0-9-])*",
        "examples": [
          "books/{book_id}",
          "authors/{author_id}/books/{book_id}",
          "authors/{author_id}/books/{book_id}"
        ]
      },
      "minItems": 1
    },
    "singleton": {
      "type": "boolean",
      "description": "If true, the resource is a singleton.",
      "default": false
    },
    "singular": {
      "type": "string",
      "description": "The singular form of the resource name",
      "pattern": "^[a-z][a-z0-9-]*$"
    },
    "type": {
      "type": "string",
      "description": "The type of resource, in the form of `{api name}.{resource singular}`. For example, `api.examples.com/user`.\n",
      "pattern": "^[a-z0-9][a-z0-9_.]*/[a-z0-9][-a-z0-9]*$",
      "examples": [
        "library.example.com/book",
        "library.example.com/author",
        "library.example.com/user-profile"
      ]
    }
  }
}