⚓ T323173 🏷️📜🥸️ Provide item's label, description or aliases in a specific language


Article Images

🏷️📜🥸️ Provide item's label, description or aliases in a specific language

Closed, ResolvedPublic8 Estimated Story Points

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.

Event Timeline

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

Content licensed under Creative Commons Attribution-ShareAlike (CC BY-SA) 4.0 unless otherwise noted; code licensed under GNU General Public License (GPL) 2.0 or later and other open source licenses. By using this site, you agree to the Terms of Use, Privacy Policy, and Code of Conduct. · Wikimedia Foundation · Privacy Policy · Code of Conduct · Terms of Use · Disclaimer · CC-BY-SA · GPL · Credits