BearND has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/338289 )
Change subject: WIP: On this day: add swagger spec
......................................................................
WIP: On this day: add swagger spec
Plus minor refactor of URI strings in test since they started getting
long.
Change-Id: Ie06a30afb5433b0068c00be86a4c5bf860a9d09b
---
M spec.yaml
M test/features/app/spec.js
2 files changed, 165 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/services/mobileapps
refs/changes/89/338289/1
diff --git a/spec.yaml b/spec.yaml
index 82b10af..81d591a 100644
--- a/spec.yaml
+++ b/spec.yaml
@@ -98,6 +98,119 @@
caption_HTML: /.+/
countries: [ /.+/ ]
+ # from routes/on-this-day.js
+ /{domain}/v1/feed/onthisday/{type}/{mm}/{dd}:
+ get:
+ tags:
+ - Feed
+ description: |
+ Provides events that historically happened on the provided day and
month.
+ Supported types of events are:
+ - All: all of the following
+ - Selected: a list of a few selected anniversaries which happen on
the provided day and month; often the entries are curated for the current year
+ - Births: a list of birthdays which happened on the provided day and
month
+ - Deaths: a list of deaths which happened on the provided day and
month
+ - Holidays: a list of fixed holidays celebrated on the provided day
and month
+ - Events: a list of significant events which happened on the provided
day and month and which are not covered by the other types yet
+ produces:
+ - application/json
+ parameters:
+ - name: type
+ in: path
+ description: "type of events"
+ type: string
+ required: true
+ enum:
+ - all
+ - selected
+ - births
+ - deaths
+ - holidays
+ - events
+ - name: mm
+ in: path
+ description: "Month events are requested for, 0-padded"
+ type: string
+ required: true
+ minimum: "01"
+ maximum: "12"
+ - name: dd
+ in: path
+ description: "Day of the month the most-read articles are requested
for"
+ type: string
+ required: true
+ minimum: "01"
+ maximum: "31"
+ responses:
+ '200':
+ description: Annual events listed on this wiki for the requested
month and day
+ schema:
+ $ref: '#/definitions/onthisdayResponse'
+ '404':
+ description: No data found for the requested date
+ schema:
+ $ref: '#/definitions/problem'
+ '501':
+ description: Unsupported language
+ schema:
+ $ref: '#/definitions/problem'
+ default:
+ description: Error
+ schema:
+ $ref: '#/definitions/problem'
+ x-amples:
+ - title: retrieve all events on January 15
+ request:
+ params:
+ type: "all"
+ mm: "01"
+ dd: "15"
+ response:
+ status: 200
+ headers:
+ content-type: application/json
+ body:
+ selected:
+ - text: /.+/
+ year: /.+/
+ pages:
+ - $merge: [ /.+/ ]
+ events:
+ - text: /.+/
+ year: /.+/
+ pages:
+ - $merge: [ /.+/ ]
+ births:
+ - text: /.+/
+ year: /.+/
+ pages:
+ - $merge: [ /.+/ ]
+ deaths:
+ - text: /.+/
+ year: /.+/
+ pages:
+ - $merge: [ /.+/ ]
+ holidays:
+ - text: /.+/
+ pages:
+ - $merge: [ /.+/ ]
+ - title: retrieve the selected anniversaries for January 15
+ request:
+ params:
+ type: "selected"
+ mm: "01"
+ dd: "15"
+ response:
+ status: 200
+ headers:
+ content-type: application/json
+ body:
+ selected:
+ - text: /.+/
+ year: /.+/
+ pages:
+ - $merge: [ /.+/ ]
+
# from routes/featured.js
/{domain}/v1/page/featured/{yyyy}/{mm}/{dd}:
get:
@@ -659,6 +772,41 @@
- date
- articles
+ onthisdayList:
+ type: array
+ items:
+ type: object
+ properties:
+ text:
+ type: string
+ description: Short description of the event
+ pages:
+ type: array
+ description: List of pages related to the event
+ items:
+ $ref: '#/definitions/article_summary_merge_link'
+
+ onthisdayResponse:
+ type: object
+ description: Lists of events which happened on the provided day and month
+ properties:
+ births:
+ description: A list of birthdays which happened on the provided day
and month
+ $ref: '#/definitions/onthisdayList'
+ deaths:
+ description: A list of deaths which happened on the provided day and
month
+ $ref: '#/definitions/onthisdayList'
+ events:
+ description: A list of significant events which happened on the
provided day and month and which are not covered by the other types yet
+ $ref: '#/definitions/onthisdayList'
+ holidays:
+ description: A list of fixed holidays celebrated on the provided day
and month
+ $ref: '#/definitions/onthisdayList'
+ selected:
+ description: A list of a few selected anniversaries which occur on the
provided day and month; often the entries are curated for the current year
+ $ref: '#/definitions/onthisdayList'
+ additionalProperties: false
+
news_item:
type: object
properties:
diff --git a/test/features/app/spec.js b/test/features/app/spec.js
index fd89576..e482ffe 100644
--- a/test/features/app/spec.js
+++ b/test/features/app/spec.js
@@ -11,9 +11,11 @@
const fs = require('fs');
const Ajv = require('ajv');
+const baseUri = `${server.config.uri}en.wikipedia.org/v1/`;
const d1 = new Date();
const d2 = new Date(Date.now() - 2 * dateUtil.ONE_DAY);
const dateStr1 = `${d1.getUTCFullYear()}/${pad(d1.getUTCMonth() +
1)}/${pad(d1.getUTCDate())}`;
+const monthDayStr1 = `${pad(d1.getUTCMonth() + 1)}/${pad(d1.getUTCDate())}`;
const dateStr2 = `${d2.getUTCFullYear()}/${pad(d2.getUTCMonth() +
1)}/${pad(d2.getUTCDate())}`;
@@ -318,33 +320,38 @@
// Valid non-aggregated requests
it('featured article response should conform to schema', () => {
- const uri =
`${server.config.uri}en.wikipedia.org/v1/page/featured/${dateStr1}`;
+ const uri = `${baseUri}page/featured/${dateStr1}`;
return assertValidSchema(uri,
'#/definitions/article_summary_merge_link');
});
it('featured image response should conform to schema', () => {
- const uri =
`${server.config.uri}en.wikipedia.org/v1/media/image/featured/${dateStr1}`;
+ const uri = `${baseUri}media/image/featured/${dateStr1}`;
return assertValidSchema(uri, '#/definitions/image');
});
it('most-read response should conform to schema', () => {
- const uri =
`${server.config.uri}en.wikipedia.org/v1/page/most-read/${dateStr2}`;
+ const uri = `${baseUri}page/most-read/${dateStr2}`;
return assertValidSchema(uri, '#/definitions/mostread');
});
it('news response should conform to schema', () => {
- const uri = `${server.config.uri}en.wikipedia.org/v1/page/news`;
+ const uri = `${baseUri}page/news`;
return assertValidSchema(uri, '#/definitions/news');
});
it('random response should conform to schema', () => {
- const uri =
`${server.config.uri}en.wikipedia.org/v1/page/random/title`;
+ const uri = `${baseUri}page/random/title`;
return assertValidSchema(uri, '#/definitions/random');
});
it('announcements should conform to schema', () => {
- const uri =
`${server.config.uri}en.wikipedia.org/v1/feed/announcements`;
+ const uri = `${baseUri}feed/announcements`;
return assertValidSchema(uri, '#/definitions/announcements');
+ });
+
+ it('onthisday response should conform to schema', () => {
+ const uri = `${baseUri}feed/onthisday/all/${monthDayStr1}`;
+ return assertValidSchema(uri, '#/definitions/onthisdayResponse');
});
// Bad requests return empty response for aggregated=true
@@ -355,12 +362,12 @@
});
it('featured image response should conform to schema (invalid date,
agg=true)', () => {
- const uri =
`${server.config.uri}en.wikipedia.org/v1/media/image/featured/2004/01/01`;
+ const uri = `${baseUri}media/image/featured/2004/01/01`;
return assertValidSchemaAggregated(uri);
});
it('most-read response should conform to schema (invalid date,
agg=true)', () => {
- const uri =
`${server.config.uri}en.wikipedia.org/v1/page/most-read/2004/01/01`;
+ const uri = `${baseUri}page/most-read/2004/01/01`;
return assertValidSchemaAggregated(uri);
});
@@ -376,12 +383,12 @@
});
it('featured image request should fail for invalid date when
!agg=true', () => {
- const uri =
`${server.config.uri}en.wikipedia.org/v1/media/image/featured/2004/01/01`;
+ const uri = `${baseUri}media/image/featured/2004/01/01`;
return assertBadRequest(uri);
});
it('most-read request should fail for invalid date when !agg=true', ()
=> {
- const uri =
`${server.config.uri}en.wikipedia.org/v1/page/most-read/2004/01/01`;
+ const uri = `${baseUri}page/most-read/2004/01/01`;
return assertBadRequest(uri);
});
--
To view, visit https://gerrit.wikimedia.org/r/338289
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie06a30afb5433b0068c00be86a4c5bf860a9d09b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/mobileapps
Gerrit-Branch: master
Gerrit-Owner: BearND <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits