RESTful APIs · Schema

RESTful API Resource

Represents a RESTful API resource following REST architectural constraints including resource identification, representation, and CRUD operations via HTTP methods.

ArchitectureHTTPRESTWeb ServicesOpenAPIStandardsDesign

Properties

Name Type Description
id stringinteger Unique identifier for the resource.
href string Self-referencing URI for the resource (HATEOAS).
type string Resource type name (e.g., 'user', 'product', 'order').
attributes object Resource-specific attributes as key-value pairs.
relationships object Related resources linked via URIs.
meta object Metadata about the resource (pagination, versioning, etc.).
View JSON Schema on GitHub

JSON Schema

restful-apis-resource-schema.json Raw ↑
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/restful-apis/refs/heads/main/json-schema/restful-apis-resource-schema.json",
  "title": "RESTful API Resource",
  "description": "Represents a RESTful API resource following REST architectural constraints including resource identification, representation, and CRUD operations via HTTP methods.",
  "type": "object",
  "properties": {
    "id": {
      "type": ["string", "integer"],
      "description": "Unique identifier for the resource."
    },
    "href": {
      "type": "string",
      "format": "uri",
      "description": "Self-referencing URI for the resource (HATEOAS)."
    },
    "type": {
      "type": "string",
      "description": "Resource type name (e.g., 'user', 'product', 'order')."
    },
    "attributes": {
      "type": "object",
      "description": "Resource-specific attributes as key-value pairs.",
      "additionalProperties": true
    },
    "relationships": {
      "type": "object",
      "description": "Related resources linked via URIs.",
      "additionalProperties": {
        "type": "object",
        "properties": {
          "href": {"type": "string", "format": "uri"},
          "type": {"type": "string"}
        }
      }
    },
    "meta": {
      "type": "object",
      "description": "Metadata about the resource (pagination, versioning, etc.).",
      "properties": {
        "createdAt": {"type": "string", "format": "date-time"},
        "updatedAt": {"type": "string", "format": "date-time"},
        "version": {"type": "integer"}
      }
    }
  },
  "required": ["id", "type"]
}