Skip to content

Commit

Permalink
mcs: Update endpoint stability information
Browse files Browse the repository at this point in the history
  • Loading branch information
johngian committed Apr 6, 2023
1 parent 451a258 commit 84489b8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
6 changes: 6 additions & 0 deletions test/features/mobileapps.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe('Mobile Content Service', () => {
})
.then((res) => {
assert.deepEqual(res.status, 200);
assert.deepEqual(res.headers.sunset, 'Sat, 01 Jul 2023 00:00:00 GMT');
assert.deepEqual(/^application\/json/.test(res.headers['content-type']), true);
assert.deepEqual(!!res.headers.etag, true);
assert.deepEqual(!!res.body.lead, true);
Expand All @@ -31,6 +32,7 @@ describe('Mobile Content Service', () => {
})
.then((res) => {
assert.deepEqual(res.status, 200);
assert.deepEqual(res.headers.sunset, 'Sat, 01 Jul 2023 00:00:00 GMT');
assert.deepEqual(/^application\/json/.test(res.headers['content-type']), true);
assert.deepEqual(!!res.headers.etag, true);
});
Expand All @@ -42,6 +44,7 @@ describe('Mobile Content Service', () => {
})
.then((res) => {
assert.deepEqual(res.status, 200);
assert.deepEqual(res.headers.sunset, 'Sat, 01 Jul 2023 00:00:00 GMT');
assert.deepEqual(/^application\/json/.test(res.headers['content-type']), true);
assert.deepEqual(!!res.headers.etag, true);
});
Expand All @@ -53,6 +56,7 @@ describe('Mobile Content Service', () => {
})
.then((res) => {
assert.deepEqual(res.status, 200);
assert.deepEqual(res.headers.sunset, 'Sat, 01 Jul 2023 00:00:00 GMT');
assert.deepEqual(/^application\/json/.test(res.headers['content-type']), true);
assert.deepEqual(new RegExp(`^"${pageRev}\/.+"$`).test(res.headers.etag), true);
assert.deepEqual(!!res.body.lead, true);
Expand All @@ -67,6 +71,7 @@ describe('Mobile Content Service', () => {
})
.then((res) => {
assert.deepEqual(res.status, 200);
assert.deepEqual(res.headers.sunset, 'Sat, 01 Jul 2023 00:00:00 GMT');
assert.deepEqual(/^application\/json/.test(res.headers['content-type']), true);
assert.deepEqual(new RegExp(`^"${pageRev}\/.+"$`).test(res.headers.etag), true);
assert.deepEqual(res.body.revision, pageRev);
Expand All @@ -79,6 +84,7 @@ describe('Mobile Content Service', () => {
})
.then((res) => {
assert.deepEqual(res.status, 200);
assert.deepEqual(res.headers.sunset, 'Sat, 01 Jul 2023 00:00:00 GMT');
assert.deepEqual(/^application\/json/.test(res.headers['content-type']), true);
assert.deepEqual(new RegExp(`^"${pageRev}\/.+"$`).test(res.headers.etag), true);
});
Expand Down
9 changes: 9 additions & 0 deletions v1/mobileapps.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ class MobileApps {
return res;
}

_injectDeprecationHeaders(res) {
// Sunset HTTP header spec:
// https://www.rfc-editor.org/rfc/rfc8594.html
res.headers = res.headers || {};
res.headers.sunset = 'Sat, 01 Jul 2023 00:00:00 GMT';
return res;
}

getSections(hyper, req) {
if (mwUtils.isNoCacheRequest(req)) {
return this._fetchFromMCSAndStore(hyper, req)
Expand All @@ -37,6 +45,7 @@ class MobileApps {
return this._fetchFromMCS(hyper, req);
})
.catch({ status: 404 }, () => this._fetchFromMCSAndStore(hyper, req))
.tap(this._injectDeprecationHeaders.bind(this))
.tap(this._injectCacheControl.bind(this));
}

Expand Down
15 changes: 12 additions & 3 deletions v1/mobileapps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ paths:
Retrieve the latest HTML for a page title optimised for viewing with
native mobile applications. Note that the output is split by sections.
Stability: [unstable](https://www.mediawiki.org/wiki/Wikimedia_Product/Wikimedia_Product_Infrastructure_team/API_endpoint_stability_policy#Unstable)
Stability: [deprecated](https://www.mediawiki.org/wiki/API_versioning#Deprecated)
[Here](https://lists.wikimedia.org/hyperkitty/list/mediawiki-api-announce@lists.wikimedia.org/thread/ZBYSZ4VQYIVZFOCEUNCL3ZSSIEECBK6H/) you can find
more information about the endpoint deprecation.
Please follow [wikitech-l](https://lists.wikimedia.org/mailman/listinfo/wikitech-l) or [mediawiki-api-announce](https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce) for announcements of breaking changes.
parameters:
Expand Down Expand Up @@ -147,7 +150,10 @@ paths:
Retrieve the lead section of the latest HTML for a page title optimised
for viewing with native mobile applications.
Stability: [unstable](https://www.mediawiki.org/wiki/Wikimedia_Product/Wikimedia_Product_Infrastructure_team/API_endpoint_stability_policy#Unstable)
Stability: [deprecated](https://www.mediawiki.org/wiki/API_versioning#Deprecated)
[Here](https://lists.wikimedia.org/hyperkitty/list/mediawiki-api-announce@lists.wikimedia.org/thread/ZBYSZ4VQYIVZFOCEUNCL3ZSSIEECBK6H/) you can find
more information about the endpoint deprecation.
Please follow [wikitech-l](https://lists.wikimedia.org/mailman/listinfo/wikitech-l) or [mediawiki-api-announce](https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce) for announcements of breaking changes.
parameters:
Expand Down Expand Up @@ -263,7 +269,10 @@ paths:
a page title optimised for viewing with native mobile applications,
provided as a JSON object containing the sections.
Stability: [unstable](https://www.mediawiki.org/wiki/Wikimedia_Product/Wikimedia_Product_Infrastructure_team/API_endpoint_stability_policy#Unstable)
Stability: [deprecated](https://www.mediawiki.org/wiki/API_versioning#Deprecated)
[Here](https://lists.wikimedia.org/hyperkitty/list/mediawiki-api-announce@lists.wikimedia.org/thread/ZBYSZ4VQYIVZFOCEUNCL3ZSSIEECBK6H/) you can find
more information about the endpoint deprecation.
Please follow [wikitech-l](https://lists.wikimedia.org/mailman/listinfo/wikitech-l) or [mediawiki-api-announce](https://lists.wikimedia.org/mailman/listinfo/mediawiki-api-announce) for announcements of breaking changes.
parameters:
Expand Down

0 comments on commit 84489b8

Please sign in to comment.