Page MenuHomePhabricator

🥣️ Do not include redundant "type" field in statement data (both requests and responses)
Closed, ResolvedPublic3 Estimated Story Points

Description

Concerns "endpoints"
GET /entities/items/{item_id}
GET /entities/items/{item_id}/statements
GET /entities/items/{item_id}/statements/{statement_id}
GET /statements/{statement_id}
POST /entities/items/{item_id}/statements
PUT /entities/items/{item_id}/statements/{statement_id}
PUT /statements/{statement_id}
PATCH /entities/items/{item_id}/statements/{statement_id}
PATCH /statements/{statement_id}

Providing "type": "statement" is redundant as "statement" is the only value of the "type" field.

Acceptance criteria

  • Responses containing statement data, i.e. GET /entities/items/{item_id}, GET /entities/items/{item_id}/statements, GET /statements/{statement_id} do not include the discussed "type" field in the provided data. Also applies to success responses to POST/PUT/PATCH requests
  • POST /entities/items/{item_id}/statements requests do not require "type" field to be provided in the request
  • PUT /entities/items/{item_id}/statements/{statement_id} requests do not require "type" field to be provided in the request
  • PUT /statements/{statement_id} requests do not require "type" field to be provided in the request
  • PATCH /entities/items/{item_id}/statements/{statement_id} requests do not require "type" field to be provided in the request
  • PATCH /statements/{statement_id} requests do not require "type" field to be provided in the request

Event Timeline

"type" field is also not include in the GET responses providing the statement data, so requiring the field to be provided in the "write" request is not particularly intuitive for the clients

Actually, I just noticed that the "type": field is included in the GET responses!
https://wikidata.beta.wmflabs.org/w/rest.php/wikibase/v0/entities/items/Q11/statements/Q11$2c668af1-4daf-cbe4-3893-2a61574d8afc

Maybe we just talked about removing them?
It will be easy to implement and probably better to remove both at the same time. =)

WMDE-leszek changed the task status from Open to Stalled.Aug 24 2022, 7:28 PM

Epic finding. And epic fail on my end. Yeah, I figure I dreamt it had been changed. I sure wanted it but we might have stopped at talking. Apologies. Will adjust the scope of this. Stalling until then

Silvan_WMDE renamed this task from Do not require redundant "type" field in POST and PUT requests creating or replacing a statement to Do not include redundant "type" field in statement data (both requests and responses).Sep 12 2022, 10:25 AM
Silvan_WMDE updated the task description. (Show Details)
WMDE-leszek changed the task status from Stalled to Open.Sep 12 2022, 10:30 AM
WMDE-leszek updated the task description. (Show Details)
WMDE-leszek set the point value for this task to 3.

Task breakdown notes:

  • for request input: - @Silvan_WMDE
    • in a separate patch, first rename Wikibase\Repo\RestApi\Domain\Serializers to Wikibase\Repo\RestApi\Domain\Serialization
    • inside that namespace, create a wrapper around existing StatementDeserializer, which adds the 'type' => 'statement' field
    • use newly created wrapped Deserializer in JsonDiffStatementPatcher
    • remove type fields from all statement serializations in unit, e2e and schema tests
  • for response output: - @Ollie.Shotton_WMDE
    • remove the type field from the statement serialisation in Wikibase\Repo\RestApi\Domain\Serializers\StatementSerializer
    • explicitly test absence of the type field in unit tests
Silvan_WMDE renamed this task from Do not include redundant "type" field in statement data (both requests and responses) to 🥣️ Do not include redundant "type" field in statement data (both requests and responses).Sep 15 2022, 10:52 AM