Page MenuHomePhabricator

[SPIKE] Identify OAD properties not supported by MediaWiki REST Framework
Closed, ResolvedPublic3 Estimated Story Points

Description

Lint the MediaWiki REST API OAD and identify which properties expected by the linter aren't currently supported by the MediaWiki REST Framework (can't be added to the OpenAPI description without making a change to the framework).

Document the findings in one or more follow-up tasks.

Context

With the core set of linter rules in place, it's now possible to lint existing OADs, including the description for MediaWiki REST API. Linting this OAD currently results in 1066 issues. To resolve them, we must add the missing information to the OAD. However, we expect that some of the fields required by linter rules aren't currently supported by the MediaWiki REST Framework. To add them, we will need to add such support to the framework, like in T420988, T425428, and T392154. The purpose of this task is to identify such cases and create separate tasks for the fields required by the linter but not supported by the framework.

Conditions of acceptance

  • Lint the MediaWiki REST API description using the most recent version of the linter
  • Identify which fields missing from the OAD aren't supported by the MediaWiki REST Framework
  • Create tasks to add support for these fields to the framework - prioritize tasks that will resolve errors and warnings

Related Objects

Event Timeline

KBach updated the task description. (Show Details)
KineticPelagic subscribed.

As part of my Clinic Duty rotation, I am moving this task to the "To Refine" column of our MWI workboard and assigning "Medium" priority because:

  • An internal MediaWiki team member identified the issue.
  • Doing this spike unblocks the subsequent work to support properties that the MediaWiki REST Framework currently does not support. Without this spike and the subsequent work, there would be a misalignment in that our linter expects certain properties, but the MediaWiki REST Framework does not even support some of those properties.
  • We could look sloppy as an organization if a developer wants to add a property to an OpenAPI description to meet the linter's expectations, but the lack of support from the MediaWiki REST Framework hinders this action.
  • Could be about comparing what we have with the standard industry spec
  • To refine later with Kamil
KBach renamed this task from [SPIKE] Identify important OAD properties not supported by MediaWiki REST Framework to [SPIKE] Identify OAD properties not supported by MediaWiki REST Framework.May 12 2026, 3:52 PM
HCoplin-WMF set the point value for this task to 3.May 14 2026, 3:18 PM
HCoplin-WMF subscribed.

Notes from estimation:

  • https://docs.google.com/spreadsheets/d/1nxGsWvpu_GXD28Fw19A8WWJa5cumWNke2E9m-22Qxu4/edit?gid=0#gid=0 --> Has a list of the fields that we are actually writing rules for; could be helpful for review.
  • Might be easier to run the linter in the terminal instead of the Toolforge version, just to make line number matching easier.
  • The scope is only to enumerate the gaps. They can be documented here, and/or ideally create the follow up tickets for the work.
    • We do not expect the implementer to actually fix all of the framework gaps within this ticket.
  • Further emphasizing that we only want to fix the issues for errors & warnings for now; hints & info are nice to jot down if there's time, but we are unlikely to fix them right now.

Spike report

Ran the Wikimedia Spectral ruleset against the OAD for all four active REST modules:

ModuleOperationsErrorsWarningsInfo/HintsTotal
Default (-)34131273105509
content/v110368232150
site/v12539650
attribution/v0-beta2436646

Framework gaps — errors

These fields are silently dropped or never generated regardless of what is declared in route definition files or handler code.

Errors

operationId not generated (48 errors, all modules)
operationId is missing from the $oasKeys list in SpecBasedModule::makeRouteInfo(). Even if declared in a route .json file, it is silently stripped. The framework also does not auto-generate it. → Existing task: T425428

requestBody.description not supported (14 errors)
Handler::getRequestSpec() builds the requestBody object with only required and content. There is no mechanism — neither from the handler nor from a route .json file — to add a description field. → T427355

Root-level externalDocs not supported (4 errors — one per module)
ModuleSpecHandler::run() only builds openapi, info, servers, paths, components. There is no way to inject externalDocs at the document root. Note: externalDocs at the *operation* level is already supported via $oasKeys. → T427356

info.version = "undefined" for default module (1 error)
For the default module (no .json definition file), getInfoSpec() falls back to the literal string "undefined", which fails semantic version validation. Named modules like content/v1 are unaffected because they declare a version in their definition file. → T427359

Warnings

Root-level tags array not generated (conditional — blocks all per-operation tags)
ModuleSpecHandler::run() never generates the root tags array. The linter requires that when operations use tags, each tag must also be declared in the root array. Since the root array is never generated, using operation-level tags produces linter warnings. → Existing task: T392154

requestBody.content[*].example not supported (32 warnings)
getRequestSpec() never generates example or examples under request body media types. There is no hook for this in the handler base class. The equivalent mechanism for path/query *parameters* (PARAM_EXAMPLE) was added in T420988; the same pattern is needed for request body content. → T427360

responses[200].content[*].example has no standard hook (20 warnings)
generateResponseSpec() builds responses['200'] with schema and headers but no examples. A workaround exists — SitemapHandlerBase overrides generateResponseSpec() entirely — but this duplicates base class logic and is not a general pattern. site/v1 is the only module with response examples today for this reason. → T427361

Path-level summary/description not supported (92 hints)
The limitation is explicitly noted in the source code with an XXX comment in getPathsSpec(). Low priority; T427362