Page MenuHomePhabricator

๐Ÿท๏ธ๐Ÿ“œ๐Ÿฅธ๏ธ Provide item's label, description or aliases in a specific language
Closed, ResolvedPublic8 Estimated Story Points

Description

PLACEHOLDER @WMDE-leszek

GET /entities/items/{item_id}/labels/{language_code}
GET /entities/items/{item_id}/descriptions/{language_code}
GET /entities/items/{item_id}/aliases/{language_code}

The respective successful responses should present the relevant data as a string, or array of strings in case of aliases -- similar to the response structure of GET /entities/items/{item_id}

Cases to consider:

  • if {item_id} is a redirect, the API should generate a 308 response redirecting to a respective path on the redirect target
  • if {item_id} does not exist, the API should generate a 404 response { "code": "item-not-found", "message": "Could not find an item with the ID: {item_id}" }
  • if {item_id} is not a valid item ID, the API should generate a 400 response { "code": "invalid-item-id", "message": "Not a valid item ID: {item_id}"}
  • if {language_code} is not a valid language code, the API should generate a 400 response { "code": "invalid-language-code", "message": "Not a valid language code: {language_code}"}
  • if given item does not have a label, description, or any alias in the give the API should generate a 404 response { "code": "label|description|aliases-not-defined", "message": "Item with the ID {item_id} does not have a label/description/aliases in the language: {language_code}" }

Note: At this point, no language fallback is to be considered.

Related Objects

StatusSubtypeAssignedTask
ResolvedIfrahkhanyaree_WMDE
ResolvedWMDE-leszek
ResolvedSilvan_WMDE
ResolvedMuhammad_Yasser_Jazirahly_WMDE
ResolvedMuhammad_Yasser_Jazirahly_WMDE
ResolvedSilvan_WMDE
Resolvedโ€ข WMDE_Norman
ResolvedMuhammad_Yasser_Jazirahly_WMDE
ResolvedSilvan_WMDE
ResolvedMuhammad_Yasser_Jazirahly_WMDE
ResolvedSilvan_WMDE
ResolvedJakob_WMDE
ResolvedSilvan_WMDE
ResolvedMuhammad_Yasser_Jazirahly_WMDE
ResolvedMuhammad_Yasser_Jazirahly_WMDE
ResolvedJakob_WMDE
ResolvedMuhammad_Yasser_Jazirahly_WMDE
ResolvedMuhammad_Yasser_Jazirahly_WMDE
ResolvedSilvan_WMDE
ResolvedMuhammad_Yasser_Jazirahly_WMDE
ResolvedMuhammad_Yasser_Jazirahly_WMDE
ResolvedMuhammad_Yasser_Jazirahly_WMDE
ResolvedMuhammad_Yasser_Jazirahly_WMDE
ResolvedMuhammad_Yasser_Jazirahly_WMDE
ResolvedMuhammad_Yasser_Jazirahly_WMDE
ResolvedMuhammad_Yasser_Jazirahly_WMDE
ResolvedSilvan_WMDE
ResolvedJakob_WMDE

Event Timeline

Restricted Application added a subscriber: Aklapper. ยท View Herald TranscriptNov 15 2022, 10:26 PM
Silvan_WMDE set the point value for this task to 8.

Task breakdown notes:

Labels/Descriptions: ๐Ÿท๏ธ ๐Ÿ“œ

  • add the GET /entities/items/{item_id}/labels/{language_code} routes to our OpenAPI definition @Ollie.Shotton_WMDE
  • create an ItemLabelRetriever @Jakob_WMDE
    • interface
    • add implementation to the existing TermLookupItemDataRetriever
  • use case (GetItemLabel) happy path. @WMDE_Norman
    • create and return response using the data from the ItemLabelRetriever, and revision metadata
  • route handler (happy path only) @Silvan_WMDE
    • same middlewares as GetItemRouteHandler
    • calls json_encode using the Label read model's text
    • e2e tests
  • create a LanguageCodeValidator @Ollie.Shotton_WMDE
    • provide an array of valid term languages (WikibaseRepo::getTermsLanguages()) in the constructor
  • validate request and error if item id or language are invalid @Jakob_WMDE
    • use case + route handler
    • e2e tests
  • return appropriate response if the item is a redirect or does not exist. @WMDE_Norman
    • use case + route handler
    • e2e tests
  • spec tests @Silvan_WMDE

Aliases: ๐Ÿฅธ๏ธ

  • add the GET /entities/items/{item_id}/aliases/{language_code} routes to our OpenAPI definition
  • create an ItemAliasesInLanguageRetriever
    • interface
    • add implementation to the existing PrefetchingTermLookupAliasesRetriever.php
  • use case (GetItemAliasesInLanguage) happy path.
    • create and return response using the data from the ItemAliasesInLanguageRetriever, and revision metadata
  • route handler (happy path only)
    • same middlewares as GetItemRouteHandler
    • calls json_encode using the AliasesInLanguage read model's aliases
    • e2e tests
  • validate request and error if item id or language are invalid
    • use case + route handler
    • e2e tests
  • return appropriate response if the item is a redirect or does not exist.
    • use case + route handler
    • e2e tests
  • spec tests
Silvan_WMDE renamed this task from Provide item's label, description or aliases in a specific language to ๐Ÿท๏ธ๐Ÿ“œ๐Ÿฅธ๏ธ Provide item's label, description or aliases in a specific language.Mar 15 2023, 11:23 AM
WMDE-leszek claimed this task.