Skip to content

Response attributes: add id and relationship fields that the API views render - #6

Merged
HermanPeeren merged 1 commit into
joomla-projects:mainfrom
HermanPeeren:fix/response-attributes
Nov 18, 2026
Merged

HermanPeeren merged 1 commit into
joomla-projects:mainfrom
HermanPeeren:fix/response-attributes

Conversation

@HermanPeeren

Copy link
Copy Markdown
Collaborator

The response schemas miss attributes that Joomla renders. This PR adds them, after checking every GET, POST and PATCH response against the field lists of the API views in joomla-cms. It was checked against 6.2.0 and 6.3-dev (18 Nov 2026); the API code of the two is the same.

How Joomla builds the attributes

JsonApiView passes $fieldsToRenderItem or $fieldsToRenderList of the view (api/components/<component>/src/View/<View>/JsonapiView.php) to the serializer. JoomlaSerializer::getAttributes() returns the properties of the item that are in that list. The relationships come separately from $relationship, so a field can be both. POST (add) and PATCH (edit) end with displayItem(), so their responses have the attributes of the item.

A script compared, for each operation, the view of its controller (from x-source) with the response schema. Result: 104 operations on 64 paths miss attributes, and no response has attributes the view does not render. Where the 6.2.0 test site has data, the captured responses confirm it.

Changes

id added to 104 responses on 64 paths

Every view renders id; for messages the view copies it from message_id. It was missing in:

  • Categories: banners, contacts, content and newsfeeds; list, item, POST and PATCH.
  • Contacts, articles, newsfeeds: list, item, POST and PATCH.
  • Field groups of all contexts, the mail fields, and the PATCH responses of the other field paths.
  • Menus: PATCH of menus and menu items; administrator menu items (list, POST, PATCH).
  • Messages, redirects, tags (list, POST, PATCH), privacy consents.
  • Users, user groups, access levels: list, item, POST and PATCH.
  • PATCH (and some POST) responses of: banners, banner clients, content languages, modules, plugins and template styles.

68 of these schemas have additionalProperties: false, so a real response did not validate against the spec. A test with a response that has attributes.id fails before this PR for messages, redirects and newsfeeds, and passes after it.

Relationship fields that are also attributes

Path Added
/v1/content/articles (list, POST), /{id} (GET, PATCH) created_by, tags; modified_by on item, POST and PATCH
/v1/contacts (list, POST), /{id} (GET, PATCH) created_by, modified_by, tags, user_id
/v1/newsfeeds/feeds (list, POST), /{id} (GET, PATCH) created_by, modified_by; tags on item, POST and PATCH
  • category is in these field lists too, but the item has no category property (only catid), so it stays a relationship only.
  • tags is an object { "<tag id>": "<title>" }, or [] when there are no tags.
  • Contacts and newsfeeds tags: the view pairs the IDs, in mapping order, with titles from getTagNames(), which are ordered by title (array_combine). With more than one tag, a title can be paired with the wrong ID. The description says so; that is a Joomla issue.
  • Contact list: tags is always [].

Other fixes

  • urls removed from the article list attributes. ArticlesModel::getListQuery() does not select a.urls, so it never appears in a list.
  • articletext in the article request bodies. On PATCH, ApiController::save() fills the stored introtext and fulltext into the request data. Content::bind() splits articletext and then parent::bind() overwrites the split with those values. So articletext has no effect on update, and on create an introtext or fulltext sent with it wins.

CHANGELOG.md has an "Unreleased" section with these changes; info.version is unchanged.

Checks

  • npm run check: format, OpenAPI 3.1 schema and Redocly lint pass. Quality has 0 errors and the same 274 warnings as main.
  • All 1685 examples in the spec still validate against their schemas.

…s render

Checked every GET, POST and PATCH response against the field lists of the API views in joomla-cms
(6.2.0 and 6.3-dev, whose API code is the same):

- id added to the attributes of 104 responses on 64 paths; 68 of them have
  additionalProperties: false, so a real response did not validate.
- created_by, modified_by, tags and (contacts) user_id added as attributes of articles, contacts
  and newsfeeds; Joomla renders them as attributes as well as relationships.
- urls removed from the article list attributes: the list query does not select it.
- articletext: no effect on update; introtext and fulltext win over it on create.
@HermanPeeren
HermanPeeren merged commit adfbd45 into joomla-projects:main Nov 18, 2026
3 checks passed
@HermanPeeren HermanPeeren mentioned this pull request Nov 18, 2026
HermanPeeren added a commit that referenced this pull request Nov 18, 2026
info.version is 6.2.2; CHANGELOG.md has the 6.2.2 section with the changes of #6.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant