├── users └── v1 │ ├── roles.json │ └── events │ ├── user-updated.json │ └── user-created.json ├── package.json └── common └── v1 └── metadata.json /users/v1/roles.json: -------------------------------------------------------------------------------- 1 | { 2 | "anyOf": [ 3 | { "type": "string", "value": "user" }, 4 | { "type": "string", "value": "admin" } 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "event-schema", 3 | "version": "1.0.0", 4 | "description": "", 5 | "scripts": { 6 | "test": "echo \"Error: no test specified\" && exit 1" 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/StephenGrider/event-schema.git" 11 | }, 12 | "keywords": [], 13 | "author": "", 14 | "license": "ISC", 15 | "bugs": { 16 | "url": "https://github.com/StephenGrider/event-schema/issues" 17 | }, 18 | "homepage": "https://github.com/StephenGrider/event-schema#readme" 19 | } 20 | -------------------------------------------------------------------------------- /users/v1/events/user-updated.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": {}, 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "$id": "user-updated", 5 | "type": "object", 6 | "title": "User Updated Event", 7 | "required": ["metadata", "data"], 8 | "properties": { 9 | "metadata": { 10 | "allOf": [ 11 | { 12 | "$ref": "/common/v1/metadata.json" 13 | } 14 | ] 15 | }, 16 | "data": { 17 | "type": "object", 18 | "required": ["id", "email", "role"], 19 | "properties": { 20 | "id": { 21 | "type": "string", 22 | "default": "", 23 | "pattern": "^(.*)$" 24 | }, 25 | "email": { 26 | "type": "string", 27 | "format": "email", 28 | "default": "" 29 | }, 30 | "role": { 31 | "$ref": "/users/v1/roles.json" 32 | } 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /users/v1/events/user-created.json: -------------------------------------------------------------------------------- 1 | { 2 | "definitions": {}, 3 | "$schema": "http://json-schema.org/draft-07/schema#", 4 | "$id": "user-created", 5 | "type": "object", 6 | "title": "User Created Event", 7 | "required": ["metadata", "data"], 8 | "properties": { 9 | "metadata": { 10 | "allOf": [ 11 | { 12 | "$ref": "/common/v1/metadata.json" 13 | } 14 | ] 15 | }, 16 | "data": { 17 | "$id": "#/properties/data", 18 | "type": "object", 19 | "title": "The Data Schema", 20 | "required": ["id", "email", "role"], 21 | "properties": { 22 | "id": { 23 | "type": "string", 24 | "title": "The Id Schema", 25 | "default": "", 26 | "examples": ["k1k53-3k52k35-2k35-k2525"], 27 | "pattern": "^(.*)$" 28 | }, 29 | "email": { 30 | "$id": "#/properties/data/properties/email", 31 | "type": "string", 32 | "title": "The Email Schema", 33 | "format": "email", 34 | "default": "", 35 | "examples": ["test@test.com"] 36 | }, 37 | "role": { 38 | "$ref": "/users/v1/roles.json" 39 | } 40 | } 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /common/v1/metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "$id": "#/properties/metadata", 3 | "type": "object", 4 | "title": "Metadata", 5 | "description": "Metadata common to all events", 6 | "required": ["type", "version", "timestamp", "id"], 7 | "properties": { 8 | "type": { 9 | "$id": "#/properties/metadata/properties/type", 10 | "type": "string", 11 | "title": "The Type Schema", 12 | "default": "", 13 | "examples": ["user-created"], 14 | "pattern": "^(.*)$" 15 | }, 16 | "version": { 17 | "$id": "#/properties/metadata/properties/version", 18 | "type": "string", 19 | "title": "The Version Schema", 20 | "default": "", 21 | "examples": ["2000-11-13T20:20:39+00:00"], 22 | "pattern": "^(.*)$" 23 | }, 24 | "timestamp": { 25 | "$id": "#/properties/metadata/properties/timestamp", 26 | "type": "string", 27 | "format": "date-time", 28 | "title": "The Timestamp Schema", 29 | "default": "", 30 | "examples": ["2000-01-01T00:00:00+00:00"], 31 | "pattern": "^(.*)$" 32 | }, 33 | "id": { 34 | "$id": "#/properties/metadata/properties/id", 35 | "type": "string", 36 | "title": "The Id Schema", 37 | "default": "", 38 | "examples": ["6a2f41a3-c54c-fce8-32d2-0324e1c32e22"], 39 | "pattern": "^(.*)$" 40 | } 41 | } 42 | } 43 | --------------------------------------------------------------------------------