Skip to content

Commit c21fa06

Browse files
authored
feat: add JSON Schema (#1681)
1 parent f4e3c92 commit c21fa06

3 files changed

Lines changed: 13 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Create a `db.json` or `db.json5` file
2020

2121
```json
2222
{
23+
"$schema": "./node_modules/json-server/schema.json",
2324
"posts": [
2425
{ "id": "1", "title": "a title", "views": 100 },
2526
{ "id": "2", "title": "another title", "views": 200 }

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
},
1515
"files": [
1616
"lib",
17-
"views"
17+
"views",
18+
"schema.json"
1819
],
1920
"type": "module",
2021
"scripts": {

schema.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"type": "object",
4+
"additionalProperties": {
5+
"oneOf": [
6+
{ "type": "array" },
7+
{ "type": "object" }
8+
]
9+
}
10+
}

0 commit comments

Comments
 (0)