Skip to content

Commit

Permalink
Declutter schemas.json (#66)
Browse files Browse the repository at this point in the history
* Create interfaces.json and payloads.json

* Move AliasList

* Move SnakHash

* Move DocumentPatch

* Remove unused lists

* Move SitelinkMap and Snak

* Reorganize payloads and interfaces

* Remove unused SnakMapList

* Move MediaWiki specific interfaces and payloads

* Move PersistedStatement to payloads

* Move PersistedReference to payloads

* Move PersistedQualifiers to payloads

* Reorganize HashedSnak anf list / map variants

* Invert persisted and new statments, qualifiers, references

* Fix new statement payload

* Fix new reference payload format

* Fix persisted reference and qualifiers responses

* Reorder Sitelink

* Add Snak to schema
  • Loading branch information
itamargiv authored Sep 21, 2020
1 parent d77f4ef commit bf25185
Show file tree
Hide file tree
Showing 6 changed files with 303 additions and 296 deletions.
129 changes: 129 additions & 0 deletions specs/global/interfaces.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
"Fingerprintable": {
"type": "object",
"properties": {
"labels": {
"$ref": "./schemas.json#/Labels"
},
"descriptions": {
"$ref": "./schemas.json#/Descriptions"
},
"aliases": {
"$ref": "./schemas.json#/Aliases"
}
},
"required": [
"labels",
"descriptions",
"aliases"
]
},
"HashBearing": {
"type": "object",
"properties": { "hash": { "$ref": "#/SnakHash"} }
},
"HashedSnak": {
"allOf": [
{
"$ref": "#/Snak"
},
{
"type": "object",
"properties": { "hash": { "$ref": "#/SnakHash" } }
}
]
},
"HashedSnakList": {
"type": "array",
"items": { "$ref": "#/HashedSnak" }
},
"HashedSnakMap": {
"type": "object",
"additionalProperties": {
"$ref": "#/HashedSnakList"
},
"example": {
"P31": [],
"P100": []
}
},
"MediawikiEditComment": { "type": "string" },
"MediawikiDeletionReason": { "type": "string" },
"MediawikiEditTags": {
"type": "array",
"items": { "$ref": "#/MediawikiEditTag" }
},
"MediawikiEditTag": { "type": "string" },
"SitelinkMap": {
"type": "object",
"additionalProperties": {
"$ref": "./schemas.json#/Sitelink"
},
"example": {
"afwiki": {
"site": "afwiki",
"title": "Douglas Adams",
"badges": [],
"url": "https://af.wikipedia.org/wiki/Douglas_Adams"
},
"arwiki": {
"site": "arwiki",
"title": "دوغلاس آدمز",
"badges": [],
"url": "https://ar.wikipedia.org/wiki/%D8%AF%D9%88%D8%BA%D9%84%D8%A7%D8%B3_%D8%A2%D8%AF%D9%85%D8%B2"
}
}
},
"Snak": {
"type": "object",
"properties": {
"snaktype": {
"type": "string"
},
"property": {
"type": "string"
},
"datatype": {
"type": "string"
},
"datavalue": {
"type": "object",
"additionalProperties": true,
"example": {
"type" : "string",
"value" : "I am a goat"
}
}
}
},
"SnakHash": {
"description": "Hash of a snak",
"type": "string",
"example": "455481eeac76e6a8af71a6b493c073d54788e7e9"
},
"SnakList": {
"type": "array",
"items": { "$ref": "./interfaces.json#/Snak" }
},
"SnakMap": {
"type": "object",
"additionalProperties": {
"$ref": "./interfaces.json#/SnakList"
},
"example": {
"P31": [],
"P100": []
}
},
"StatementsBearing": {
"type": "object",
"properties": {
"statements": {
"type": "object"
}
},
"required": [
"statements"
]
}
}
106 changes: 106 additions & 0 deletions specs/global/payloads.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"AliasList": {
"type": "array",
"items": { "$ref": "./schemas.json#/Term" }
},
"DocumentPatch": {
"description": "A JSONPatch object as defined by RFC 6902",
"type": "object",
"properties": {
"op": {
"description": "The operation to perform",
"type": "string",
"enum": [ "add", "remove", "replace" ]
},
"path": {
"description": "A JSON-Pointer for the property to manipulate",
"type": "string"
},
"value": {
"description": "The value to be used within the operation"
}
},
"required": ["op", "path"]
},
"DocumentPatchList" : {
"description": "A list of JSONPatch objects as defined by RFC 6902",
"type": "array",
"items": { "$ref": "./payloads.json#/DocumentPatch" }
},
"Error": {
"type": "object",
"properties": {
"code": { "type": "string" },
"message": { "type": "string" }
},
"required": [ "code", "message" ]
},
"MediawikiEdit": {
"type": "object",
"properties": {
"comment": {
"$ref": "./interfaces.json#/MediawikiEditComment"
},
"tags": {
"$ref": "./interfaces.json#/MediawikiEditTags"
}
}
},
"MediawikiDeletion": {
"type": "object",
"properties": {
"reason": {
"$ref": "./interfaces.json#/MediawikiDeletionReason"
},
"tags": {
"$ref": "./interfaces.json#/MediawikiEditTags"
}
}
},
"NewQualifier": {
"$ref": "./interfaces.json#/Snak"
},
"NewReference": {
"type": "object",
"properties": {
"snaks": {
"$ref": "./interfaces.json#/SnakMap"
}
}
},
"NewReferences": {
"type": "array",
"items": { "$ref": "#/NewReference" }
},
"NewStatement": {
"type": "object",
"properties": {
"mainsnak" : {
"$ref": "./interfaces.json#/Snak"
},
"id": {
"type": "string"
},
"rank": {
"type": "string"
},
"qualifiers": {
"$ref": "./interfaces.json#/SnakMap"
},
"references": {
"$ref": "#/NewReferences"
}
}
},
"PersistedQualifiers": {
"$ref": "./interfaces.json#/HashedSnakMap"
},
"PersistedReferences": {
"type": "array",
"items": { "$ref": "./schemas.json#/Reference" }
},
"PersistedStatementList": {
"type": "array",
"items": { "$ref": "./schemas.json#/Statement" }
}
}
37 changes: 19 additions & 18 deletions specs/global/requests.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
"allOf": [
{
"type": "object",
"properties": { "patches": { "$ref": "./schemas.json#/DocumentPatchList" } }
"properties": { "patches": { "$ref": "./payloads.json#/DocumentPatchList" } }
},
{
"$ref": "./schemas.json#/MediawikiEdit"
"$ref": "./payloads.json#/MediawikiEdit"
}
]
}
Expand All @@ -27,10 +27,10 @@
"allOf": [
{
"type": "object",
"properties": { "aliases": { "$ref": "./schemas.json#/AliasList" } }
"properties": { "aliases": { "$ref": "./payloads.json#/AliasList" } }
},
{
"$ref": "./schemas.json#/MediawikiEdit"
"$ref": "./payloads.json#/MediawikiEdit"
}
]
}
Expand All @@ -49,26 +49,26 @@
"properties": { "entity": { "$ref": "./schemas.json#/Entity" } }
},
{
"$ref": "./schemas.json#/MediawikiEdit"
"$ref": "./payloads.json#/MediawikiEdit"
}
]
}
}
}
},
"Qualifier": {
"description": "A Wikibase Snak object",
"description": "A Wikibase qualifier object",
"required": true,
"content": {
"application/json": {
"schema": {
"allOf": [
{
"type": "object",
"properties": { "snak": { "$ref": "./schemas.json#/Snak" } }
"properties": { "qualifier": { "$ref": "./payloads.json#/NewQualifier" } }
},
{
"$ref": "./schemas.json#/MediawikiEdit"
"$ref": "./payloads.json#/MediawikiEdit"
}
]
}
Expand All @@ -84,10 +84,10 @@
"allOf": [
{
"type": "object",
"properties": { "statement": { "$ref": "./schemas.json#/Statement" } }
"properties": { "statement": { "$ref": "./payloads.json#/NewStatement" } }
},
{
"$ref": "./schemas.json#/MediawikiEdit"
"$ref": "./payloads.json#/MediawikiEdit"
}
]
}
Expand All @@ -103,11 +103,12 @@
"allOf": [
{
"type": "object",
"properties": { "reference": { "$ref": "./schemas.json#/SnakMap" } }
"properties": {
"reference": { "$ref": "./payloads.json#/NewReference" }
}

},
{
"$ref": "./schemas.json#/MediawikiEdit"
}
{ "$ref": "./payloads.json#/MediawikiEdit" }
]
}
}
Expand All @@ -125,7 +126,7 @@
"properties": { "sitelink": { "$ref": "./schemas.json#/Sitelink" } }
},
{
"$ref": "./schemas.json#/MediawikiEdit"
"$ref": "./payloads.json#/MediawikiEdit"
}
]
}
Expand All @@ -144,7 +145,7 @@
"properties": { "term": { "$ref": "./schemas.json#/Term" } }
},
{
"$ref": "./schemas.json#/MediawikiEdit"
"$ref": "./payloads.json#/MediawikiEdit"
}
]
}
Expand All @@ -156,7 +157,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "./schemas.json#/MediawikiEdit"
"$ref": "./payloads.json#/MediawikiEdit"
}
}
}
Expand All @@ -166,7 +167,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "./schemas.json#/MediawikiDeletion"
"$ref": "./payloads.json#/MediawikiDeletion"
}
}
}
Expand Down
Loading

0 comments on commit bf25185

Please sign in to comment.