Issue #3472584: Add missing request body schemas to openapi.yml

Twelve POST and PATCH operations in openapi.yml had no requestBody. Eight of them receive one; four do not.

The eight are the form/* operations. They receive form-encoded data, not JSON, because Drupal's Form API reads these values from the request's parameter bag. Two shared request bodies cover them:

  • ComponentInstanceFormGeneration — the three PATCH operations that generate a component instance form. Documents form_canvas_tree, form_canvas_props, form_canvas_selected, latestUndoRedoActionId and ajaxPageState.
  • DrupalAjaxFormSubmission — the five POST operations that receive Drupal AJAX form submissions. Declares both application/x-www-form-urlencoded and multipart/form-data, because Drupal switches to multipart for forms containing a file input. Its schema documents the Form API and AJAX bookkeeping fields and allows additional properties, since the form's own fields are determined at run time.

The remaining four read no request body: the two Page Region operations always respond 410 Gone, and the two CLI push signals carry no data. Each now states that in a comment.

ApiRequestValidator validates live requests against this file, kernel tests included. Request::create() sets neither a Content-Type header nor a raw body for PATCH requests, so three kernel test call sites now use a new RequestTrait::createFormEncodedRequest() helper to send what real clients send.

OpenApiSpecValidationTest::testRequestsComplyWithSpecification() adds 13 cases covering these request shapes. It is the only PHP coverage for the five AJAX submission operations, which are otherwise exercised only by Cypress.

Testing instructions

  • ddev xb-openapi reports the description is valid, with no new warnings.
  • ddev xb-phpunit tests/src/Unit/OpenApiSpecValidationTest.php passes.
  • ddev xb-phpunit tests/src/Unit/DxRouteConsistencyTest.php passes.
  • ddev xb-phpunit tests/src/Kernel/Plugin/Canvas/ComponentSource/JsComponentEvolutionTest.php passes. Reverting only the createFormEncodedRequest() call site makes 18 assertions fail.
  • ddev xb-phpunit tests/src/Kernel/ComponentInstanceFormTest.php passes. On core 11.5-dev it fails in setUp() for unrelated reasons: the canvas.component.sdc.canvas_test_sdc.image config is absent.
  • Cypress form suites pass, for example entity-form-field-types-test.cy.js and media-library-entity-form.cy.js.
  • Reverting only openapi.yml makes two OpenApiSpecValidationTest cases fail, confirming the new request bodies are enforced.

AI use

Written with Claude Code (claude-opus-5) under human review

Merge request reports

Loading