Page MenuHomePhabricator

Add summaries to endpoints in the MediaWiki REST API OpenAPI spec
Closed, ResolvedPublic5 Estimated Story Points

Description

Add a paths.[path].[method].summary field for each endpoint in the MediaWiki REST API OpenAPI spec with a short endpoint name. Endpoint names can be sourced from h3 headings in the MediaWiki REST API reference.

Background

In REST API documentation, it is essential for each endpoint to have a short name that can be used in navigation to helps readers differentiate between endpoints easily. The OpenAPI 'Operation Object' allows these short-hand descriptions to be populated in the summary field, along with longer form descriptions in the description field.

For example, consider these two endpoints from the Analytics API

  • GET /edited-pages/aggregate/{project}/{editor-type}/{page-type}/{activity-level}/{granularity}/{start}/{end}
  • GET /edited-pages/new/{project}/{editor-type}/{page-type}/{granularity}/{start}/{end}

These paths are not easy for readers to understand and differentiate, so they can't be used in endpoint navigation. Instead, the OpenAPI spec for this API includes a summary for each endpoint:

  • Get number of edited pages
  • Get number of new pages

When considering SwaggerUI specifically, the summary field is what adds the human friendly text to the collapsed accordion view, whereas the description is intended to be slightly longer form and is only visible if you expand the accordion. We want to add the summaries to improve clarity around what each endpoint is for, without folks needing to expand the accordion every time.

You can see that these summaries are much easier to understand and form a key part of readers' ability to navigate between endpoints.

Other Summary examples can be found in the RESTbase specs.
RESTbase example:

image (11).png (74×474 px, 7 KB)

MW REST current state (missing the summary):

image (12).png (74×928 px, 8 KB)

Implementation details

If you look in our spec, the description is populated, but the summary is not (see spec screenshot). We want to add the summary to every MW REST API endpoint, which basically means everything that we own under /v1.

image (10).png (210×376 px, 16 KB)

Reference: Summaries are listed as "endpoint names" in the list of essential elements of REST API documentation on mediawiki.org. In the screenshot below, the orange box represents what we should add as the summary, vs the green box which reflects what is currently used for the description.

image (13).png (287×928 px, 68 KB)

Summaries should be added to every MW REST API endpoint that MWI owns. That applies to every endpoint under the main /v1 route when looking at the REST Sandbox. A specific list of endpoints is below:

  • GET /v1/page/{title}/history
  • GET /v1/page/{title}/history/counts/{type}
  • GET /v1/revision/{from}/compare/{to}
  • GET /v1/revision/{id}
  • GET /v1/revision/{id}/html
  • GET /v1/revision/{id}/with_html
  • GET /v1/revision/{id}/bare
  • GET /v1/search
  • GET /v1/search/page
  • GET /v1/search/title
  • GET /v1/page/{title}/links/language
  • GET /v1/page/{title}
  • PUT /v1/page/{title}
  • GET /v1/page/{title}/bare
  • GET /v1/page/{title}/html
  • GET /v1/page/{title}/with_html
  • GET /v1/page/{title}/links/media
  • GET /v1/file/{title}
  • POST /v1/page
  • POST /v1/transform/wikitext/to/html/{title}/{revision}
  • POST /v1/transform/html/to/wikitext/{title}/{revision}
  • GET /v1/transform/wikitext/to/lint/{title}/{revision}
  • POST /v1/transform/wikitext/to/lint/{title}/{revision}
  • POST /v1/transform/wikitext/to/html
  • POST /v1/transform/wikitext/to/html/
  • POST /v1/transform/html/to/wikitext
  • POST /v1/transform/html/to/wikitext/
  • POST /v1/transform/wikitext/to/lint
  • POST /v1/transform/wikitext/to/lint/
  • POST /v1/transform/wikitext/to/html/{title}
  • POST /v1/transform/wikitext/to/html/{title}/
  • POST /v1/transform/html/to/wikitext/{title}
  • POST /v1/transform/html/to/wikitext/{title}/
  • GET /v1/transform/wikitext/to/lint/{title}
  • POST /v1/transform/wikitext/to/lint/{title}
  • GET /v1/transform/wikitext/to/lint/{title}/
  • POST /v1/transform/wikitext/to/lint/{title}/

Details

Related Changes in Gerrit:

Event Timeline

(Moving this discussion over from Slack)

Agreed that summaries would be a very nice addition.And in fact, they're already supported in the MW REST API infrastructure: localizeJsonPairs is intentionally agnostic to field name. As long as the field name starts with our LOCALIZATION_PREFIX, it'll Just Work®. (We coded this portion of spec generation specifically with summaries in mind.)

The reason there aren't any yet is that summaries are an OpenAPI 3.1.0 thing, and our current validation library doesn't support that. Notice that our generated specs are 3.0.0. At some point, we can resolve that, whether by changing libraries, adding support for 3.1.0+ to the library we're using, or getting really lucky and someone else adding it to the library without us having to do anything. Adding it ourselves might be a nice little Code Jam/Hackathon project.

Additional context is in the phab task where we initially selected this library, including some alternatives that we could check back on to see their current status: T376339: Create schema validator method

The reason there aren't any yet is that summaries are an OpenAPI 3.1.0 thing

If my understanding is correct, path summaries have been available in OpenAPI since v2.0, so I wonder if this is a limitation with the library itself.

Took a closer look. @apaskulin is correct that summary fields existed for endpoints much earlier than I said.

Summary fields were not part of the Info object describing the overall spec in 3.0.0:
https://spec.openapis.org/oas/v3.0.0.html#info-object

They first appear in 3.1.0:
https://spec.openapis.org/oas/v3.1.0.html#info-object

I had previously looked a summary fields in the context of the info block of MW REST API module definition files, saw they didn't exist at that level in 3.0.0, and incorrectly extrapolated that they also didn't exist on endpoints in earlier versions.

However, they do. Adding an x-i18n-summary field to and endpoint works fine, and appears in the sandbox. I'm very happy to be wrong.

daniel moved this task from Incoming (Needs Triage) to Bugs & Chores on the MW-Interfaces-Team board.
HCoplin-WMF raised the priority of this task from Low to Medium.Aug 21 2025, 3:35 PM
HCoplin-WMF updated the task description. (Show Details)
HCoplin-WMF set the point value for this task to 5.

Change #1183742 had a related patch set uploaded (by Fgoodwin; author: Fgoodwin):

[mediawiki/core@master] Add summaries to endpoints in REST API

https://gerrit.wikimedia.org/r/1183742

Change #1183742 merged by jenkins-bot:

[mediawiki/core@master] Add summaries to endpoints in REST API

https://gerrit.wikimedia.org/r/1183742