QuestionQ30

APIs and Services

An Adobe Commerce developer adds a new extension attribute to include an array of values on invoices retrieved through the APIs. After some time, their technical manager reviews the work and finds an issue with the extension_attributes.xml file created in the developer’s module:

Question Image

What is wrong with this XML snippet?

  • A The extension attribute references the wrong interface, it should have referenced the Magento\Sales\Api\Data\InvoiceInterface.
  • B The extension attribute references the repository instead of the interface it implements (Magento\Sales\Api\InvoiceRepositoryInterface).
  • C The type is wrong, string[] should be replaced with array.
Explanation

Extension attributes must be declared for the extensible API data interface of the entity being extended. For invoices, that interface is Magento\Sales\Api\Data\InvoiceInterface; a repository model is not the invoice data interface. The string[] notation is valid for an array extension attribute.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!