Page MenuHomePhabricator

🟦️ Use a fixed structure (in terms of elements present) in the statement data in REST API response
Closed, ResolvedPublic3 Estimated Story Points

Description

Currently some fields/elements in the statement data might be skipped in the REST API response when the related data, e.g. when there are no references or qualifiers attached to the statement.

To increase the predictability of the API responses, all fields are to be included in the response, even if they only contain an "empty" value.

Fields to include in the response:

  • id
  • mainsnak
  • rank
  • qualifiers
  • qualifiers-order
  • references

The change will likely also involve adjusting examples in the openapi specification.

This applies to statement data in responses in all relevant GET "endpoints"

Event Timeline

Jakob_WMDE set the point value for this task to 3.May 25 2022, 10:32 AM

Notes from task breakdown:

  • create a new statement serializer class that wraps the existing one and ensures the required fields are contained in the serialization
  • use new serializer and adjust statement spec to mark the listed fields as required
    • use new serializer in GetItemStatementJsonPresenter
    • use new serializer in ItemDataSerializer wrapped in StatementListSerializer (which we need to instantiate ourselves)
    • use new serializer in GetItemStatementsJsonPresenter wrapped in StatementListSerializer (which we need to instantiate ourselves)
Jakob_WMDE renamed this task from Use a fixed structure (in terms of elements present) in the statement data in REST API response to 🟦️ Use a fixed structure (in terms of elements present) in the statement data in REST API response.May 30 2022, 10:50 AM

I moved this back to ToDo for now, since I noticed something in the task description, which we had actually missed: T309633: 🟦️ Adjust examples in the OpenAPI specification to include all required statement fields

Responses and examples look good - verified.