Skip to content

Commit

Permalink
fix: API v3 schemas (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
morremeyer authored Nov 12, 2023
1 parent c29f547 commit fa706bd
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 41 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,9 @@ repos:
rev: v3.0.3
hooks:
- id: prettier

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.27.1
hooks:
- id: check-metaschema
files: ^static/schemas/.*\.json$
2 changes: 1 addition & 1 deletion static/schemas/v3/error.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@
"$id": "https://envelope-zero.org/schemas/v3/error.schema.json",
"title": "Error",
"description": "A human readable error message",
"anyOf": [{ "type": "string" }, { "type": "null" }]
"oneOf": [{ "type": "string" }, { "type": "null" }]
}
13 changes: 9 additions & 4 deletions static/schemas/v3/get-collection.response.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@
"properties": {
"data": {
"description": "List of resources",
"type": "array",
"items": {
"type": "object"
}
"oneOf": [
{
"type": "array",
"items": {
"type": "object"
}
},
{ "type": "null" }
]
},
"error": {
"$ref": "https://envelope-zero.org/schemas/v3/error.schema.json"
Expand Down
2 changes: 1 addition & 1 deletion static/schemas/v3/get-patch-resource.response.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"properties": {
"data": {
"description": "The resource",
"type": "object"
"oneOf": [{ "type": "object" }, { "type": "null" }]
},
"error": {
"$ref": "https://envelope-zero.org/schemas/v3/error.schema.json"
Expand Down
50 changes: 28 additions & 22 deletions static/schemas/v3/pagination.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,33 @@
"title": "Pagination",
"description": "The pagination information",
"type": "object",
"required": ["count", "limit", "offset", "total"],
"properties": {
"count": {
"description": "The number of results in this response",
"type": "integer",
"minimum": 0
"oneOf": [
{
"type": "object",
"required": ["count", "limit", "offset", "total"],
"properties": {
"count": {
"description": "The number of results in this response",
"type": "integer",
"minimum": 0
},
"limit": {
"description": "The limit for the number of results used for this response",
"type": "integer",
"minimum": -1
},
"offset": {
"description": "The offset of the first resource returned",
"type": "integer",
"minimum": 0
},
"total": {
"description": "Total number of records matching the query",
"type": "integer",
"minimum": 0
}
}
},
"limit": {
"description": "The limit for the number of results used for this response",
"type": "integer",
"minimum": -1
},
"offset": {
"description": "The offset of the first resource returned",
"type": "integer",
"minimum": 0
},
"total": {
"description": "Total number of records matching the query",
"type": "integer",
"minimum": 0
}
}
{ "type": "null" }
]
}
31 changes: 18 additions & 13 deletions static/schemas/v3/post.response.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,25 @@
"properties": {
"data": {
"description": "List of resources",
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"properties": {
"error": {
"$ref": "https://envelope-zero.org/schemas/v3/error.schema.json"
},
"data": {
"description": "A single resource",
"type": "object"
"oneOf": [
{
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"properties": {
"error": {
"$ref": "https://envelope-zero.org/schemas/v3/error.schema.json"
},
"data": {
"description": "A single resource",
"type": "object"
}
}
}
}
}
},
{ "type": "null" }
]
},
"error": {
"$ref": "https://envelope-zero.org/schemas/v3/error.schema.json"
Expand Down

0 comments on commit fa706bd

Please sign in to comment.