Skip to content

Commit

Permalink
Merge 59b6b54 into 373350e
Browse files Browse the repository at this point in the history
  • Loading branch information
mdholloway committed Jul 1, 2019
2 parents 373350e + 59b6b54 commit ca5a7df
Show file tree
Hide file tree
Showing 8 changed files with 371 additions and 3 deletions.
29 changes: 28 additions & 1 deletion config.frontend.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ default_project: &default_project
host: https://citoid-beta.wmflabs.org
recommendation:
host: https://recommendation-api-beta.wmflabs.org
appeditortasks:
host: https://app-editor-tasks.wmflabs.org
purged_cache_control: test_purged_cache_control
# Cache control for purged endpoints allowing short-term client caching
purged_cache_control_client_cache: test_purged_cache_control_with_client_caching
Expand Down Expand Up @@ -98,6 +100,30 @@ wiktionary_project: &wiktionary_project
options: *default_options
/{api:sys}: *default_sys

commons_project: &commons_project
x-modules:
- spec:
paths:
/{api:v1}:
x-modules:
- path: projects/v1/default.wmf.yaml
options: *default_options
- path: projects/proxy.yaml
options: *proxy_options
/{api:sys}: *default_sys

wikidata_project: &wikidata_project
x-modules:
- spec:
paths:
/{api:v1}:
x-modules:
- path: projects/v1/wikidata.wmf.yaml
options: *default_options
- path: projects/proxy.yaml
options: *proxy_options
/{api:sys}: *default_sys

testing_project: &testing_project
x-modules:
- spec:
Expand Down Expand Up @@ -150,7 +176,8 @@ spec_root: &spec_root
/{domain:ru.wikipedia.org}: *wikipedia_project
/{domain:de.wikipedia.org}: *wikipedia_project
/{domain:test2.wikipedia.org}: *wikipedia_project
/{domain:commons.wikimedia.org}: *default_project
/{domain:commons.wikimedia.org}: *commons_project
/{domain:www.wikidata.org}: *wikidata_project

# labs, used for most tests
/{domain:en.wikipedia.beta.wmflabs.org}: *wikipedia_project
Expand Down
29 changes: 28 additions & 1 deletion config.fullstack.test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ default_project: &default_project
host: https://citoid-beta.wmflabs.org
recommendation:
host: https://recommendation-api-beta.wmflabs.org
appeditortasks:
host: https://app-editor-tasks.wmflabs.org
purged_cache_control: test_purged_cache_control
# Cache control for purged endpoints allowing short-term client caching
purged_cache_control_client_cache: test_purged_cache_control_with_client_caching
Expand Down Expand Up @@ -135,6 +137,30 @@ wiktionary_project: &wiktionary_project
options: *proxy_options
/{api:sys}: *default_sys

commons_project: &commons_project
x-modules:
- spec:
paths:
/{api:v1}:
x-modules:
- path: projects/v1/default.wmf.yaml
options: *default_options
- path: projects/proxy.yaml
options: *proxy_options
/{api:sys}: *default_sys

wikidata_project: &wikidata_project
x-modules:
- spec:
paths:
/{api:v1}:
x-modules:
- path: projects/v1/wikidata.wmf.yaml
options: *default_options
- path: projects/proxy.yaml
options: *proxy_options
/{api:sys}: *default_sys

testing_project: &testing_project
x-modules:
- spec:
Expand Down Expand Up @@ -185,7 +211,8 @@ spec_root: &spec_root
/{domain:ru.wikipedia.org}: *wikipedia_project
/{domain:de.wikipedia.org}: *wikipedia_project
/{domain:test2.wikipedia.org}: *wikipedia_project
/{domain:commons.wikimedia.org}: *default_project
/{domain:commons.wikimedia.org}: *commons_project
/{domain:www.wikidata.org}: *wikidata_project

# labs, used for most tests
/{domain:en.wikipedia.beta.wmflabs.org}: *wikipedia_project
Expand Down
2 changes: 2 additions & 0 deletions projects/v1/default.wmf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,3 +96,5 @@ paths:
- path: v1/javascript.yaml
options:
host: '{{options.mobileapps.host}}'
- path: v1/recommend-caption.yaml
options: '{{options.appeditortasks}}'
2 changes: 2 additions & 0 deletions projects/v1/wikidata.wmf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,6 @@ paths:
x-modules:
- path: v1/lists.js
options: '{{options.lists}}'
- path: v1/recommend-description.yaml
options: '{{options.appeditortasks}}'

8 changes: 8 additions & 0 deletions test/features/specification/monitoring.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,14 @@ describe('Monitoring tests', function() {
{
domain: 'en.wiktionary.org',
specURI: `${server.config.baseURL('en.wiktionary.org')}/?spec`
},
{
domain: 'www.wikidata.org',
specURI: `${server.config.baseURL('www.wikidata.org')}/?spec`
},
{
domain: 'commons.wikimedia.org',
specURI: `${server.config.baseURL('commons.wikimedia.org')}/?spec`
}],
(options) => {
return preq.get(options.specURI)
Expand Down
145 changes: 145 additions & 0 deletions v1/recommend-caption.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
info:
version: 1.0.0
title: Recommendation API
description: Recommendation API
termsOfService: https://github.com/wikimedia/restbase
license:
name: Apache license, v2
url: https://www.apache.org/licenses/LICENSE-2.0
tags:
- name: Recommendation
description: contribution recommendations
paths:
/recommendation/caption/addition/{target}:
get:
tags:
- Recommendation
summary: Recommend files missing a caption (label) in the target language
parameters:
- name: target
in: path
description: The target wiki language code for suggestions
required: true
schema:
type: string
responses:
200:
description: list of candidates for caption addition
content:
application/json:
schema:
$ref: '#/components/schemas/caption_recommendation_result'
default:
description: Error
content:
application/problem+json:
schema:
$ref: '#/components/schemas/problem'
x-request-handler:
- get_from_backend:
request:
uri: '{{options.host}}/{{domain}}/v1/caption/addition/{target}'
x-amples:
- title: Caption addition suggestions
request:
params:
domain: commons.wikimedia.org
target: zh
response:
status: 200
headers:
content-type: application/json
body:
- pageid: /.+/
ns: 6
title: /.+/
mime: /image.*/
structured:
captions: /.+/
x-monitor: true

/recommendation/caption/translation/from/{source}/to/{target}:
get:
tags:
- Recommendation
summary: Recommend files with a caption (label) in the source language but missing one in the target language
parameters:
- name: source
in: path
description: The source wiki language code for suggestions
required: true
schema:
type: string
- name: target
in: path
description: The target wiki language code for suggestions
required: true
schema:
type: string
responses:
200:
description: list of candidates for caption translation
content:
application/json:
schema:
$ref: '#/components/schemas/caption_recommendation_result'
default:
description: Error
content:
application/problem+json:
schema:
$ref: '#/components/schemas/problem'
x-request-handler:
- get_from_backend:
request:
uri: '{{options.host}}/{{domain}}/v1/caption/translation/from/{source}/to/{target}'
x-amples:
- title: Caption translation suggestions
request:
params:
domain: commons.wikimedia.org
source: en
target: zh
response:
status: 200
headers:
content-type: application/json
body:
- pageid: /.+/
ns: 6
title: /.+/
mime: /image.*/
structured:
captions: /.+/
x-monitor: true

components:
schemas:
caption_recommendation_result:
type: array
description: list of candidates for caption addition or translation
items:
type: object
properties:
pageid:
type: integer
description: wiki page id
ns:
type: integer
description: numeric page namespace (should always be 6)
title:
type: string
description: page title (with namespace prefix)
mime:
type: string
description: the MIME type of the file
structured:
type: object
description: structured data from Structured Data on Commons
properties:
captions:
type: object
description: captions, by language, from Structured Data on Commons
globalusage:
type: object
description: pages using this image on the source or target wiki, by language
Loading

0 comments on commit ca5a7df

Please sign in to comment.