Skip to content

Request defaults: what the webservices do with an omitted field - #9

Open
HermanPeeren wants to merge 2 commits into
joomla-projects:mainfrom
HermanPeeren:fix/request-defaults
Open

HermanPeeren wants to merge 2 commits into
joomla-projects:mainfrom
HermanPeeren:fix/request-defaults

Conversation

@HermanPeeren

Copy link
Copy Markdown
Collaborator

The request bodies took their default values from the administrator forms. The webservices do not apply those, so several defaults were wrong. Checked on a Joomla 6.2 site (by creating items without the field) and against the install SQL of joomla-cms 6.2-dev.

Create (POST): an omitted field gets the default of its database column.

Field Was Is Where
state / published 1 0 (unpublished) articles, banners, banner clients, categories, contacts, fields, field groups, content languages, menu items, modules, newsfeeds, tags
track_impressions, track_clicks 0 -1 (use the client default / the global setting) banners, banner clients
numarticles 5 1 newsfeeds

For articles, the description limits this to sites with workflows disabled, which is what was tested.

published of a redirect is now required: its column has no default, so saving without it fails with "Field 'published' doesn't have a default value". The example includes it.

Update (PATCH): an omitted field keeps its stored value (ApiController::save() loads it, and the application configuration merges the current configuration). The default of the 131 top-level properties of PATCH request bodies is removed, so that generated clients and "Try it out" do not send it and overwrite the stored value. The form default stays in x-joomla-form.default.

Article list: list[ordering] and list[direction] had no description. They now list the accepted columns. A value that is not a filter field of the model is ignored; the filter fields author_id, category_id, level, tag, published and stage are no columns of the query and give an internal server error (500). Omitted, the list is ordered by id (or by the featured ordering when filter[featured] is 1), descending; an invalid direction gives ascending.

npm run check passes. After the change, creating each item without the defaulted fields returns exactly the defaults in the spec, for every field the response contains.

Checked on a Joomla 6.2 site and against the install SQL of joomla-cms 6.2-dev:

- POST: the webservices do not apply the defaults of the administrator forms; an omitted field gets the
  default of its database column. state/published is 0, not 1 (articles, banners, banner clients,
  categories, contacts, fields, field groups, content languages, menu items, modules, newsfeeds, tags);
  track_impressions/track_clicks of banners and banner clients are -1, not 0; numarticles of newsfeeds is 1,
  not 5.
- POST /v1/redirects: published is required, as its column has no default.
- PATCH: an omitted field keeps its stored value, so the default of the 131 top-level properties of PATCH
  request bodies is removed. The form default stays in x-joomla-form.default.
- GET /v1/content/articles: list[ordering] and list[direction] are described.
@HermanPeeren HermanPeeren added the accepted-breaking-change A breaking change that corrects the spec to match Joomla label Nov 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accepted-breaking-change A breaking change that corrects the spec to match Joomla

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant