Page MenuHomePhabricator

API: When creating a Lexeme with wbeditentity API the result is confusing and mixed
Closed, ResolvedPublic

Description

In the below example when creating a lexeme with the wbeditentity API module it looks as though the API is not going to output the created entity for me, which is fine (even though this api module does output the creation of items and properties).
But then the returned object does also include a claims key.

I guess the expected behaviour is actually:

  • Don't return any part of the entity created for lexemes, in which case the claims key should probably not be there
  • Return the created entity, in which case more things should be there.

Request:

POST /mediawiki/api.php HTTP/1.1
Host: default.web.mw.localhost:8080
Cache-Control: no-cache
Postman-Token: d5c7388c-4b46-cb91-fa5c-ac325214a94e
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW

------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="data"

{
            "lemmas": {
                "en": {
                    "language": "en",
                    "value": "lexeme1"
                }
            },
            "lexicalCategory": "Q1",
            "language": "Q1",
            "claims": {},
            "forms": [],
            "senses": []
        }
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="action"

wbeditentity
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="new"

lexeme
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="token"

+\
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="format"

json
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="id"

L11
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="clear"

1
------WebKitFormBoundary7MA4YWxkTrZu0gW--

Result:

{
    "entity": {
        "claims": {},
        "id": "L10",
        "type": "lexeme",
        "lastrevid": 13
    },
    "success": 1
}

Event Timeline

Lydia_Pintscher renamed this task from When creating a Lexeme with wbeditentity API the result is confusing and mixed to API: When creating a Lexeme with wbeditentity API the result is confusing and mixed.Sep 2 2018, 4:05 PM

This is currently slowing down development of lexeme editing in WDTK. See: https://github.com/Wikidata/Wikidata-Toolkit/issues/437

Looking at this "Don't return any part of the entity created for lexemes, in which case the claims key should probably not be there" should definitely be the easier option.
Moving to the product column.

Change 658601 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/core@master] Allow replacing ApiResult value with same value

https://gerrit.wikimedia.org/r/658601

Change 658602 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/Wikibase@master] Make wbeditentity return full entity data

https://gerrit.wikimedia.org/r/658602

Change 658603 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[mediawiki/extensions/WikibaseLexeme@master] Test that wbeditentity returns full entity data

https://gerrit.wikimedia.org/r/658603

Change 658601 merged by jenkins-bot:
[mediawiki/core@master] Allow replacing ApiResult value with same value

https://gerrit.wikimedia.org/r/658601

Change 658602 merged by jenkins-bot:
[mediawiki/extensions/Wikibase@master] Make wbeditentity return full entity data

https://gerrit.wikimedia.org/r/658602

Change 658603 merged by jenkins-bot:
[mediawiki/extensions/WikibaseLexeme@master] Test that wbeditentity returns full entity data

https://gerrit.wikimedia.org/r/658603

I think this might be resolved with the recently announced wbeditentity result change:

request
-----------------------------128309791625304997022618975514
Content-Disposition: form-data; name="data"

{
            "lemmas": {
                "en": {
                    "language": "en",
                    "value": "lexeme1"
                }
            },
            "lexicalCategory": "Q6",
            "language": "Q6",
            "claims": {},
            "forms": [],
            "senses": []
        }
-----------------------------128309791625304997022618975514
Content-Disposition: form-data; name="action"

wbeditentity
-----------------------------128309791625304997022618975514
Content-Disposition: form-data; name="format"

jsonfm
-----------------------------128309791625304997022618975514
Content-Disposition: form-data; name="new"

lexeme
-----------------------------128309791625304997022618975514
Content-Disposition: form-data; name="wrappedhtml"

1
-----------------------------128309791625304997022618975514
Content-Disposition: form-data; name="token"

[redacted]+\
-----------------------------128309791625304997022618975514--
response
{
    "entity": {
        "type": "lexeme",
        "id": "L1483",
        "lemmas": {
            "en": {
                "language": "en",
                "value": "lexeme1"
            }
        },
        "lexicalCategory": "Q6",
        "language": "Q6",
        "claims": {},
        "forms": [],
        "senses": [],
        "lastrevid": 537539
    },
    "success": 1
}