From c21fa06c6af0407a96de25a520881ed151f599f5 Mon Sep 17 00:00:00 2001 From: typicode Date: Thu, 22 Jan 2026 00:02:59 +0100 Subject: [PATCH] feat: add JSON Schema (#1681) --- README.md | 1 + package.json | 3 ++- schema.json | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 schema.json diff --git a/README.md b/README.md index f153f96..bbdd20c 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ Create a `db.json` or `db.json5` file ```json { + "$schema": "./node_modules/json-server/schema.json", "posts": [ { "id": "1", "title": "a title", "views": 100 }, { "id": "2", "title": "another title", "views": 200 } diff --git a/package.json b/package.json index 6c5eac0..589f465 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,8 @@ }, "files": [ "lib", - "views" + "views", + "schema.json" ], "type": "module", "scripts": { diff --git a/schema.json b/schema.json new file mode 100644 index 0000000..5ebd857 --- /dev/null +++ b/schema.json @@ -0,0 +1,10 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "type": "object", + "additionalProperties": { + "oneOf": [ + { "type": "array" }, + { "type": "object" } + ] + } +}