Addshore has uploaded a new change for review.
https://gerrit.wikimedia.org/r/71610
Change subject: Adding and fixing API examples
......................................................................
Adding and fixing API examples
Change-Id: Ie18eca3b051ea1435e526ea1c0c990d9f6f49695
---
M repo/includes/api/CreateClaim.php
M repo/includes/api/EditEntity.php
M repo/includes/api/GetClaims.php
M repo/includes/api/RemoveClaims.php
M repo/includes/api/RemoveQualifiers.php
M repo/includes/api/RemoveReferences.php
M repo/includes/api/SearchEntities.php
M repo/includes/api/SetClaim.php
M repo/includes/api/SetClaimValue.php
M repo/includes/api/SetDescription.php
M repo/includes/api/SetQualifier.php
M repo/includes/api/SetReference.php
M repo/includes/api/SetSiteLink.php
13 files changed, 35 insertions(+), 27 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/10/71610/1
diff --git a/repo/includes/api/CreateClaim.php
b/repo/includes/api/CreateClaim.php
index 0beb963..271bab1 100644
--- a/repo/includes/api/CreateClaim.php
+++ b/repo/includes/api/CreateClaim.php
@@ -305,8 +305,7 @@
protected function getExamples() {
return array(
'api.php?action=wbcreateclaim&entity=q42&property=p9001&snaktype=novalue&token=foobar&baserevid=7201010',
-
'api.php?action=wbcreateclaim&entity=q42&property=p9001&snaktype=value&value={"entity-type":"item","numeric-id":1}&token=foobar&baserevid=7201010',
- // 'ex' => 'desc'
+
'api.php?action=wbcreateclaim&entity=q42&property=p9001&snaktype=value&value={"entity-type":"item","numeric-id":1}&token=foobar&baserevid=7201010'
=> 'Creates a claim for q42 of p101, q1',
);
}
}
diff --git a/repo/includes/api/EditEntity.php b/repo/includes/api/EditEntity.php
index 543b042..62bed06 100644
--- a/repo/includes/api/EditEntity.php
+++ b/repo/includes/api/EditEntity.php
@@ -508,6 +508,8 @@
=> 'Set an empty JSON structure for the entity, it will
be extended with an id and the structure cleansed and completed. Report it as
pretty printed json format.',
'api.php?action=wbeditentity&data={"labels":{"de":{"language":"de","value":"de-value"},"en":{"language":"en","value":"en-value"}}}'
=> 'Set a more complete JSON structure for the entity,
it will be extended with an id and the structure cleansed and completed.',
+
'api.php?action=wbeditentity&id=q42&data={"sitelinks":{"nowiki":"København","svwiki":"Köpenhamn"}}'
+ => 'Extencs item with id q42 with a more complete JSON
structure for the entity, structure cleansed and completed.',
);
}
diff --git a/repo/includes/api/GetClaims.php b/repo/includes/api/GetClaims.php
index eebc0e5..eb70680 100644
--- a/repo/includes/api/GetClaims.php
+++ b/repo/includes/api/GetClaims.php
@@ -11,6 +11,7 @@
use Wikibase\EntityId;
use Wikibase\Entity;
use Wikibase\EntityContentFactory;
+use Wikibase\Item;
use Wikibase\Statement;
use Wikibase\Claims;
use Wikibase\Claim;
@@ -45,7 +46,6 @@
class GetClaims extends ApiWikibase {
// TODO: automcomment
- // TODO: example
// TODO: rights
// TODO: conflict detection
@@ -270,9 +270,12 @@
* @return array
*/
protected function getExamples() {
+ $exampleId = new EntityId( Item::ENTITY_TYPE, 42 );
+ $exampleId = $exampleId->getPrefixedId();
return array(
- // TODO
- // 'ex' => 'desc'
+ "api.php?action=wbgetclaims&entity=q42" => "Get claims
for item with ID $exampleId",
+
"api.php?action=wbgetclaims&entity=$exampleId&rank=normal" => "Get claims for
item with ID $exampleId that are ranked as normal",
+
'api.php?action=wbgetclaims&claim=q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F' =>
"Get claim with GUID of q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F",
);
}
diff --git a/repo/includes/api/RemoveClaims.php
b/repo/includes/api/RemoveClaims.php
index 4883629..64650f4 100644
--- a/repo/includes/api/RemoveClaims.php
+++ b/repo/includes/api/RemoveClaims.php
@@ -364,8 +364,7 @@
*/
protected function getExamples() {
return array(
- // TODO
- // 'ex' => 'desc'
+
'api.php?action=wbremoveclaims&claim=q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0N&token=foobar&baserevid=7201010'
=> 'Remove claim with GUID of "q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0N"',
);
}
diff --git a/repo/includes/api/RemoveQualifiers.php
b/repo/includes/api/RemoveQualifiers.php
index 9dbb802..886a383 100644
--- a/repo/includes/api/RemoveQualifiers.php
+++ b/repo/includes/api/RemoveQualifiers.php
@@ -44,7 +44,6 @@
class RemoveQualifiers extends ApiWikibase {
// TODO: automcomment
- // TODO: example
// TODO: rights
// TODO: conflict detection
// TODO: claim uniqueness
@@ -224,8 +223,7 @@
*/
protected function getExamples() {
return array(
- // TODO
- // 'ex' => 'desc'
+
'api.php?action=wbremovequalifiers&statement=q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F&references=1eb8793c002b1d9820c833d234a1b54c8e94187e&token=foobar&baserevid=7201010'
=> 'Remove qualifier with hash "1eb8793c002b1d9820c833d234a1b54c8e94187e" from
claim with GUID of "q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F"',
);
}
diff --git a/repo/includes/api/RemoveReferences.php
b/repo/includes/api/RemoveReferences.php
index fd680ef..3aff07c 100644
--- a/repo/includes/api/RemoveReferences.php
+++ b/repo/includes/api/RemoveReferences.php
@@ -50,7 +50,6 @@
}
// TODO: automcomment
- // TODO: example
// TODO: rights
// TODO: conflict detection
@@ -234,8 +233,7 @@
*/
protected function getExamples() {
return array(
- // TODO
- // 'ex' => 'desc'
+
'api.php?action=wbremovereferences&statement=q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F&references=455481eeac76e6a8af71a6b493c073d54788e7e9&token=foobar&baserevid=7201010'
=> 'Remove reference with hash "455481eeac76e6a8af71a6b493c073d54788e7e9" from
claim with GUID of "q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F"',
);
}
diff --git a/repo/includes/api/SearchEntities.php
b/repo/includes/api/SearchEntities.php
index 2f270b3..6588465 100644
--- a/repo/includes/api/SearchEntities.php
+++ b/repo/includes/api/SearchEntities.php
@@ -294,8 +294,9 @@
*/
protected function getExamples() {
return array(
- 'api.php?action=wbsearchentities&search=abc&language=en'
- => 'Search for "abc" in English language, with defaults
for type and limit.',
+
'api.php?action=wbsearchentities&search=abc&language=en' => 'Search for "abc"
in English language, with defaults for type and limit',
+
'api.php?action=wbsearchentities&search=abc&language=en&limit=50' => 'Search
for "abc" in English language with a limit of 50',
+
'api.php?action=wbsearchentities&search=alphabet&language=en&type=property' =>
'Search for "alphabet" in English language for type property',
);
}
diff --git a/repo/includes/api/SetClaim.php b/repo/includes/api/SetClaim.php
index bd4f131..c87e299 100644
--- a/repo/includes/api/SetClaim.php
+++ b/repo/includes/api/SetClaim.php
@@ -228,7 +228,6 @@
protected function getExamples() {
return array(
'api.php?action=setclaim&claim={json-stuff}&baserevid=9042&token=foobar'
- // 'ex' => 'desc'
);
}
}
diff --git a/repo/includes/api/SetClaimValue.php
b/repo/includes/api/SetClaimValue.php
index 4204ccc..8f01424 100644
--- a/repo/includes/api/SetClaimValue.php
+++ b/repo/includes/api/SetClaimValue.php
@@ -296,11 +296,9 @@
*/
protected function getExamples() {
return array(
- // TODO
- // 'ex' => 'desc'
+
'api.php?action=wbsetclaimvalue&claim=q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F&snaktype=value&value={"entity-type":"item","numeric-id":1}&token=foobar&baserevid=7201010'
=> 'Sets the claim with the GUID of q42$D8404CDA-25E4-4334-AF13-A3290BCD9C0F
to a value of q1',
);
}
-
/**
* @see \Wikibase\Api\IAutocomment::getTextForComment()
diff --git a/repo/includes/api/SetDescription.php
b/repo/includes/api/SetDescription.php
index 6a9f789..6af7132 100644
--- a/repo/includes/api/SetDescription.php
+++ b/repo/includes/api/SetDescription.php
@@ -96,6 +96,8 @@
return array(
'api.php?action=wbsetdescription&id=Q42&language=en&value=An%20encyclopedia%20that%20everyone%20can%20edit'
=> 'Set the string "An encyclopedia that
everyone can edit" for page with id "Q42" as a decription in English language',
+
'api.php?action=wbsetdescription&site=enwiki&title=Wikipedia&language=en&value=An%20encyclopedia%20that%20everyone%20can%20edit'
+ => 'Set the string "An encyclopedia that
everyone can edit" as a decription in English language for page with a sitelink
to enwiki:Wikipedia',
);
}
diff --git a/repo/includes/api/SetQualifier.php
b/repo/includes/api/SetQualifier.php
index 4ee94e3..cccbdeb 100644
--- a/repo/includes/api/SetQualifier.php
+++ b/repo/includes/api/SetQualifier.php
@@ -55,7 +55,6 @@
class SetQualifier extends ApiWikibase {
// TODO: automcomment
- // TODO: example
// TODO: rights
// TODO: conflict detection
// TODO: more explicit support for snak merging?
@@ -461,8 +460,7 @@
*/
protected function getExamples() {
return array(
- // TODO
- // 'ex' => 'desc'
+
'api.php?action=wbsetqualifier&claim=q2$4554c0f4-47b2-1cd9-2db9-aa270064c9f3&property=qp&value=GdyjxP8I6XB3&snaktype=value&token=foobar'
=> 'Set qualifier for claim to string value GdyjxP8I6XB3',
);
}
diff --git a/repo/includes/api/SetReference.php
b/repo/includes/api/SetReference.php
index 3dfe76f..08588e0 100644
--- a/repo/includes/api/SetReference.php
+++ b/repo/includes/api/SetReference.php
@@ -48,7 +48,6 @@
class SetReference extends ApiWikibase {
// TODO: automcomment
- // TODO: example
// TODO: rights
// TODO: conflict detection
@@ -323,6 +322,16 @@
}
/**
+ * @see \ApiBase::getExamples()
+ */
+ protected function getExamples() {
+ return array(
+
'api.php?action=wbsetreference&statement=q76$D4FDE516-F20C-4154-ADCE-7C5B609DFDFF&snaks={"p39":[{"snaktype":"value","property":"p14","datavalue":{"type":"string","value":"wikipedia"}}}&baserevis=7201010&token=foobar'
=> 'Create a new reference for claim with GUID
q76$D4FDE516-F20C-4154-ADCE-7C5B609DFDFF',
+
'api.php?action=wbsetreference&statement=q76$D4FDE516-F20C-4154-ADCE-7C5B609DFDFF&reference=1eb8793c002b1d9820c833d234a1b54c8e94187e&snaks={"p39":[{"snaktype":"value","property":"p14","datavalue":{"type":"string","value":"wikipedia"}}}&baserevis=7201010&token=foobar'
=> 'Set reference for claim with GUID q76$D4FDE516-F20C-4154-ADCE-7C5B609DFDFF
which has hash of 1eb8793c002b1d9820c833d234a1b54c8e94187e',
+ );
+ }
+
+ /**
* @see \ApiBase::isWriteMode()
*/
public function isWriteMode() {
diff --git a/repo/includes/api/SetSiteLink.php
b/repo/includes/api/SetSiteLink.php
index ca4be9a..89037ff 100644
--- a/repo/includes/api/SetSiteLink.php
+++ b/repo/includes/api/SetSiteLink.php
@@ -202,10 +202,12 @@
*/
protected function getExamples() {
return array(
-
'api.php?action=wbsetsitelink&id=Q42&linksite=enwiki&linktitle=Wikimedia'
- => 'Add title "Wikimedia" for English page with id
"Q42" if the site link does not exist',
-
'api.php?action=wbsetsitelink&id=Q42&linksite=enwiki&linktitle=Wikimedia&summary=World%20domination%20will%20be%20mine%20soon!'
- => 'Add title "Wikimedia" for English page with id
"Q42", if the site link does not exist',
+
'api.php?action=wbsetsitelink&id=Q42&linksite=enwiki&linktitle=Hydrogen'
+ => 'Add a sitelink "Hydrogen" for English page with id
"Q42", if the site link does not exist',
+
'api.php?action=wbsetsitelink&id=Q42&linksite=enwiki&linktitle=Hydrogen&summary=World%20domination%20will%20be%20mine%20soon!'
+ => 'Add a sitelink "Hydrogen" for English page with id
"Q42", if the site link does not exist',
+
'api.php?action=wbsetsitelink&site=enwiki&title=Hydrogen&tosite=dewiki&totitle=Wasserstoff'
+ => 'Add a sitelink "Wasserstoff" for the German page on
item with the link from the English page to "Hydrogen", if the site link does
not exist',
);
}
--
To view, visit https://gerrit.wikimedia.org/r/71610
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie18eca3b051ea1435e526ea1c0c990d9f6f49695
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Addshore <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits