Page MenuHomePhabricator

Define static OpenAPI specs per API family for RESTbase endpoints
Closed, ResolvedPublic5 Estimated Story Points

Description

Description

RESTbase offers different configurations based on the Wikimedia project family (eg: Wiktionary, Wikipedia). To support API documentation following the RESTbase sunset, we need to have static definitions for each of these configurations, which will then be hosted through MediaWiki and used for API reference documentation.

Conditions of acceptance

  • Define a static OpenAPI spec for each API family.
  • Provide the logic/mapping for which spec should be used with each project family.
  • Review and hand off to MWI for implementation.

Event Timeline

Jgiannelos subscribed.

The source of truth will always be the restbase/deploy or restbase codebases for the detailed definition.

Here are the various permutations of the OpenAPI specs:

There are some access to the AQS 2.0 endpoints (I believe) to the Wikimedia.org domain that is not registered in the API spec, so I assume this somehow a side-effect of migrating things over to REST Gateway cc/ @hnowlan.

Change #1175942 had a related patch set uploaded (by Aaron Schulz; author: Aaron Schulz):

[operations/mediawiki-config@master] Add restbase spec JSON files to which /rest_v1/?spec can be routed

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

aaron updated Other Assignee, added: MSantos.

@MSantos Assigning this to myself since I made the patches for the json files. I do need review/merge though :)

Change #1177515 had a related patch set uploaded (by Aaron Schulz; author: Aaron Schulz):

[operations/puppet@production] [DNM] Route "/api/rest_v1/?spec" requests to the rest gateway

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

Change #1177514 had a related patch set uploaded (by Aaron Schulz; author: Aaron Schulz):

[operations/deployment-charts@master] [DNM] Route old /api/rest_v1/?specs endpoints to static JSON files

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

Change #1190742 had a related patch set uploaded (by Aaron Schulz; author: Aaron Schulz):

[operations/mediawiki-config@master] Switch wgRestSandboxSpecs wmf-restbase entry on testwiki to the static specs

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

Change #1190743 had a related patch set uploaded (by Aaron Schulz; author: Aaron Schulz):

[operations/mediawiki-config@master] Switch wgRestSandboxSpecs wmf-restbase entry to the static specs everywhere

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

Change #1175942 merged by jenkins-bot:

[operations/mediawiki-config@master] Add restbase spec JSON files to which /rest_v1/?spec can be routed

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

Mentioned in SAL (#wikimedia-operations) [2025-10-07T20:48:42Z] <aaron@deploy2002> Started scap sync-world: Backport for [[gerrit:1175942|Add restbase spec JSON files to which /rest_v1/?spec can be routed (T397203 T396805)]]

Mentioned in SAL (#wikimedia-operations) [2025-10-07T20:53:06Z] <aaron@deploy2002> aaron: Backport for [[gerrit:1175942|Add restbase spec JSON files to which /rest_v1/?spec can be routed (T397203 T396805)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-10-07T20:58:49Z] <aaron@deploy2002> Finished scap sync-world: Backport for [[gerrit:1175942|Add restbase spec JSON files to which /rest_v1/?spec can be routed (T397203 T396805)]] (duration: 10m 13s)

Change #1177514 merged by jenkins-bot:

[operations/deployment-charts@master] Route old /api/rest_v1/?specs endpoints to static JSON files

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

Change #1196875 had a related patch set uploaded (by Clément Goubert; author: Clément Goubert):

[operations/deployment-charts@master] Route old /api/rest_v1/?specs endpoints to static JSON files

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

Change #1196875 merged by jenkins-bot:

[operations/deployment-charts@master] Route old /api/rest_v1/?specs endpoints to static JSON files

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

Quoting my own post from the wrong task

I merged this in staging this morning, and for some yet unknown reason, the regexes are not matching and envoy returns 404s because of no route match.
We will investigate further.

cgoubert@deploy2002:~$ curl -v -k -H 'Host: wikimedia.org' https://staging.svc.eqiad.wmnet:4113/wikimedia.org/v1/?spec 
[...]
> GET /wikimedia.org/v1/?spec HTTP/1.1
> Host: wikimedia.org
> User-Agent: curl/7.74.0
> Accept: */*
> 
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* old SSL session ID is stale, removing
* Mark bundle as not supporting multiuse
< HTTP/1.1 404 Not Found
< content-length: 42
< content-type: application/json
< content-security-policy: default-src 'none'; frame-ancestors 'none'
< date: Fri, 17 Oct 2025 09:34:48 GMT
< server: envoy
< 
{"httpReason":"Not Found","httpCode":404}
[2025-10-17 09:29:39.342][35][debug][conn_handler] [source/common/listener_manager/active_tcp_listener.cc:160] [Tags: "ConnectionId":"2"] new 
connection from 10.2.2.69:58598
[2025-10-17 09:29:39.387][35][debug][http] [source/common/http/conn_manager_impl.cc:393] [Tags: "ConnectionId":"2"] new stream
[2025-10-17 09:29:39.387][35][debug][http] [source/common/http/conn_manager_impl.cc:1192] [Tags: "ConnectionId":"2","StreamId":"17662462863721
800510"] request headers complete (end_stream=true):
':authority', 'wikimedia.org'
':path', '/wikimedia.org/v1/?spec'
':method', 'GET'
'user-agent', 'curl/7.74.0'
'accept', '*/*'

[2025-10-17 09:29:39.387][35][debug][http] [source/common/http/conn_manager_impl.cc:1175] [Tags: "ConnectionId":"2","StreamId":"17662462863721800510"] request end stream
[2025-10-17 09:29:39.387][35][debug][connection] [./source/common/network/connection_impl.h:98] [Tags: "ConnectionId":"2"] current connecting state: false
[2025-10-17 09:29:39.388][35][debug][router] [source/common/router/config_impl.cc:1856] route was resolved but final route list did not match incoming request
[2025-10-17 09:29:39.388][35][debug][router] [source/common/router/router.cc:446] [Tags: "ConnectionId":"2","StreamId":"17662462863721800510"] no route match for URL '/wikimedia.org/v1/?spec'
[2025-10-17 09:29:39.388][35][debug][http] [source/common/http/filter_manager.cc:1015] [Tags: "ConnectionId":"2","StreamId":"17662462863721800510"] Preparing local reply with details route_not_found
[2025-10-17 09:29:39.388][35][debug][http] [source/common/http/filter_manager.cc:1057] [Tags: "ConnectionId":"2","StreamId":"17662462863721800510"] Executing sending local reply.
[2025-10-17 09:29:39.388][35][debug][lua] [source/extensions/filters/common/lua/lua.cc:39] coroutine finished
[2025-10-17 09:29:39.388][35][debug][http] [source/common/http/conn_manager_impl.cc:1869] [Tags: "ConnectionId":"2","StreamId":"17662462863721800510"] encoding headers via codec (end_stream=false):
':status', '404'
'content-length', '42'
'content-type', 'application/json'
'content-security-policy', 'default-src 'none'; frame-ancestors 'none''
'date', 'Fri, 17 Oct 2025 09:29:39 GMT'
'server', 'envoy'

After fixing the route matching, we are correctly catching and redirecting in staging, however:

for host in wikimedia.org www.wikidata.org test.wikidata.org commons.wikimedia.org test-commons.wikimedia.org en.wikipedia.org en.wiktionary.org en.wikivoyage.org wikisource.org; do echo $host; curl -k -H "Host: ${host}" https://staging.svc.eqiad.wmnet:4113/wikimedia.org/v1/?spec -s -w "%{http_code}\n" -o /dev/null; done
wikimedia.org
301
www.wikidata.org
200
test.wikidata.org
200
commons.wikimedia.org
200
test-commons.wikimedia.org
200
en.wikipedia.org
200
en.wiktionary.org
200
en.wikivoyage.org
200
wikisource.org
200

It works for all but wikimedia.org, which if I remember correctly is a bit of a "special" wiki, with multiple redirects etc.

I'll deploy to the production rest-gateway since nothing points these paths there at the moment, but this will need to get investigated.

So...it looks like mediawiki-config needs some tweaks under docroot. wikimedia.org redirects to www.wikimedia.org which has the wwwportal docroot, not the wikimedia one. I think I'll just make an api/restbase_specs dir under wwwportal and move rest_v1-wikimedia.json there.

Change #1198405 had a related patch set uploaded (by Aaron Schulz; author: Aaron Schulz):

[operations/mediawiki-config@master] Move rest_v1-wikimedia.json under the wwwportal directory

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

Change #1198406 had a related patch set uploaded (by Aaron Schulz; author: Aaron Schulz):

[operations/deployment-charts@master] restgateway: update spec-json-wikimedia to use www prefix

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

Change #1198405 merged by jenkins-bot:

[operations/mediawiki-config@master] Move rest_v1-wikimedia.json under the wwwportal directory

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

Mentioned in SAL (#wikimedia-operations) [2025-10-27T20:48:45Z] <aaron@deploy2002> Started scap sync-world: Backport for [[gerrit:1198405|Move rest_v1-wikimedia.json under the wwwportal directory (T396805)]]

Mentioned in SAL (#wikimedia-operations) [2025-10-27T20:52:32Z] <aaron@deploy2002> aaron: Backport for [[gerrit:1198405|Move rest_v1-wikimedia.json under the wwwportal directory (T396805)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-10-27T21:01:08Z] <aaron@deploy2002> Finished scap sync-world: Backport for [[gerrit:1198405|Move rest_v1-wikimedia.json under the wwwportal directory (T396805)]] (duration: 12m 22s)

Change #1177515 merged by Clément Goubert:

[operations/puppet@production] Route "/api/rest_v1/?spec" requests to the rest gateway

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

I had to revert the ATS patch, as it is the gateway-check.lua script is not able to route based on GET uri args, only the path.
I'll try to think of an elegant-ish way to handle this tomorrow.

Change #1199886 had a related patch set uploaded (by Aaron Schulz; author: Aaron Schulz):

[operations/puppet@production] Route "/api/rest_v1/" requests with "?spec" query to the rest gateway

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

Change #1200441 had a related patch set uploaded (by Aaron Schulz; author: Aaron Schulz):

[operations/mediawiki-config@master] Add a wgRestSandboxSpecs entry for wikimedia.org (math) specs

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

Change #1199886 merged by Clément Goubert:

[operations/puppet@production] Route "/api/rest_v1/" requests with "?spec" query to the rest gateway

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

Change #1190742 merged by jenkins-bot:

[operations/mediawiki-config@master] Set wgRestSandboxSpecs['wmf-restbase'] on testwiki to use the static specs

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

Mentioned in SAL (#wikimedia-operations) [2025-11-03T21:08:09Z] <aaron@deploy2002> Started scap sync-world: Backport for [[gerrit:1190742|Set wgRestSandboxSpecs['wmf-restbase'] on testwiki to use the static specs (T396805)]]

Mentioned in SAL (#wikimedia-operations) [2025-11-03T21:10:19Z] <aaron@deploy2002> aaron: Backport for [[gerrit:1190742|Set wgRestSandboxSpecs['wmf-restbase'] on testwiki to use the static specs (T396805)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-11-03T21:15:25Z] <aaron@deploy2002> Finished scap sync-world: Backport for [[gerrit:1190742|Set wgRestSandboxSpecs['wmf-restbase'] on testwiki to use the static specs (T396805)]] (duration: 07m 16s)

Change #1190743 merged by jenkins-bot:

[operations/mediawiki-config@master] Set wgRestSandboxSpecs['wmf-restbase'] to use the static specs everywhere

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

Mentioned in SAL (#wikimedia-operations) [2025-11-03T21:18:03Z] <aaron@deploy2002> Started scap sync-world: Backport for [[gerrit:1190743|Set wgRestSandboxSpecs['wmf-restbase'] to use the static specs everywhere (T396805)]]

Mentioned in SAL (#wikimedia-operations) [2025-11-03T21:20:16Z] <aaron@deploy2002> aaron: Backport for [[gerrit:1190743|Set wgRestSandboxSpecs['wmf-restbase'] to use the static specs everywhere (T396805)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-11-03T21:25:35Z] <aaron@deploy2002> Finished scap sync-world: Backport for [[gerrit:1190743|Set wgRestSandboxSpecs['wmf-restbase'] to use the static specs everywhere (T396805)]] (duration: 07m 31s)

Change #1198406 merged by jenkins-bot:

[operations/deployment-charts@master] restgateway: update spec-json-wikimedia to use www prefix

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

Change #1200441 merged by jenkins-bot:

[operations/mediawiki-config@master] Add a wgRestSandboxSpecs entry for wikimedia.org (math) specs

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

Mentioned in SAL (#wikimedia-operations) [2025-11-04T22:45:34Z] <aaron@deploy2002> Started scap sync-world: Backport for [[gerrit:1200441|Add a wgRestSandboxSpecs entry for wikimedia.org (math) specs (T396805)]]

Mentioned in SAL (#wikimedia-operations) [2025-11-04T22:47:54Z] <aaron@deploy2002> aaron: Backport for [[gerrit:1200441|Add a wgRestSandboxSpecs entry for wikimedia.org (math) specs (T396805)]] synced to the testservers (see https://wikitech.wikimedia.org/wiki/Mwdebug). Changes can now be verified there.

Mentioned in SAL (#wikimedia-operations) [2025-11-04T22:53:22Z] <aaron@deploy2002> Finished scap sync-world: Backport for [[gerrit:1200441|Add a wgRestSandboxSpecs entry for wikimedia.org (math) specs (T396805)]] (duration: 07m 48s)

aaron triaged this task as Medium priority.
aaron set the point value for this task to 5.
aaron updated the task description. (Show Details)

Change #1202323 had a related patch set uploaded (by Aaron Schulz; author: Aaron Schulz):

[operations/deployment-charts@master] restgateway: make spec-json-wikimedia catch non-www domain too

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

Change #1202323 abandoned by Aaron Schulz:

[operations/deployment-charts@master] restgateway: make spec-json-wikimedia catch non-www domain too

Reason:

Going with https://gerrit.wikimedia.org/r/c/operations/puppet/+/1190754

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