Fatal error: OpenApiUi element must implement all methods from ElementInterface in Drupal 10

Created on 7 July 2025, 4 months ago

Problem/Motivation

The OpenApiUi render element class in the OpenAPI UI module implements the ElementInterface, but does not provide implementations for all required methods. This leads to a fatal error when the element is invoked in Drupal 10.x:

Fatal error: Class Drupal\openapi_ui\Element\OpenApiUi contains 8 abstract methods and must therefore be declared abstract or implement the remaining methods (Drupal\Core\Render\Element\ElementInterface::initializeInternalStorage, Drupal\Core\Render\Element\ElementInterface::toRenderable, Drupal\Core\Render\Element\ElementInterface::getChildren, ...) in modules/contrib/openapi_ui/src/Element/OpenApiUi.php on line 59

This breaks pages using #type => 'openapi_ui' and makes the module incompatible with Drupal 10+ unless the class is updated.

Steps to reproduce

  1. Install the OpenAPI UI module on a Drupal 10 site
  2. Use the #type => 'openapi_ui' element in a form or render array
  3. Visit the page where the render element is expected to appear

Observe a fatal error due to missing method implementations in OpenApiUi.

Proposed resolution

  • Implement all required methods from ElementInterface in OpenApiUi
  • Alternatively, extend RenderElementBase which already provides default implementations (preferred if targeting Drupal 10.3+)
  • Ensure toRenderable() returns a render array by reference, as required

Remaining tasks

  • Update
🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇮🇳India kalpanajaiswal

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024