Page MenuHomePhabricator
Paste P8180

cxserver api spec - openapi 3.0 valid
ActivePublic

Authored by santhosh on Mar 12 2019, 7:19 AM.
Referenced Files
F28372787: raw.txt
Mar 12 2019, 7:19 AM
Subscribers
openapi: 3.0.1
info:
title: Content translation service
description: Content translation service for translating mediawiki pages between
languages.
termsOfService: https://wikimediafoundation.org/wiki/Terms_of_Use
contact:
name: the Wikimedia Language team
url: https://www.mediawiki.org/wiki/Wikimedia_Language_engineering
license:
name: GPL-2.0+
url: http://opensource.org/licenses/GPL-2.0
version: 0.2.2
servers:
- url: /
paths:
/robots.txt:
get:
tags:
- Root
description: Gets robots.txt
responses:
200:
description: OK
content:
text/plain:
schema:
type: string
x-amples:
- title: robots.txt check
request: {}
response:
status: 200
/:
get:
tags:
- Root
description: The root service end-point
responses:
200:
description: OK
content: {}
404:
description: root with wrong query param
content: {}
x-amples:
- title: root with no query params
request: {}
response:
status: 404
- title: spec from root
request:
query:
spec: true
response:
status: 200
- title: root with wrong query param
request:
query:
fooo: true
response:
status: 404
/v1/page/{language}/{title}:
get:
tags:
- Page content
description: Fetches segmented mediawiki page
parameters:
- name: language
in: path
description: The language code or the domain of the wiki
required: true
schema:
type: string
- name: title
in: path
description: The page title
required: true
schema:
type: string
- name: revision
in: query
description: The page revision id
required: false
schema:
type: string
responses:
200:
description: Page fetched successfully
content:
application/json:
schema:
type: string
404:
description: Page not found
content: {}
x-amples:
- title: Fetch enwiki Oxygen page
request:
params:
language: en
title: Oxygen
revision: 702870951
response:
status: 200
headers:
content-type: application/json
/v1/dictionary/{word}/{from}/{to}:
get:
tags:
- Dictionary
description: Fetches the dictionary meaning of a word.
parameters:
- name: word
in: path
description: The word to lookup
required: true
schema:
type: string
- name: from
in: path
description: The source language code
required: true
schema:
type: string
- name: to
in: path
description: The target language code
required: true
schema:
type: string
- name: provider
in: query
description: The dictionary provider id
required: false
schema:
type: string
enum:
- JsonDict
- Dictd
responses:
200:
description: Dictionary meaning of a word fetched successfully
content:
application/json:
schema:
type: string
404:
description: Word not found in the dictionary
content: {}
x-amples:
- title: Fetch dictionary meaning with a given provider
request:
params:
word: water
from: en
to: es
provider: JsonDict
response:
status: 200
body:
source: water
translations:
- phrase: /.+/
sources:
- fd-eng-spa
headers:
content-type: application/json
- title: Fetch dictionary meaning without specifying a provider
request:
params:
word: water
from: en
to: es
response:
status: 200
body:
source: water
translations:
- phrase: /.+/
sources:
- fd-eng-spa
headers:
content-type: application/json
/v1/mt/{from}/{to}:
post:
tags:
- Machine translation
description: Fetches the machine translation. Some providers require an authorization
header and it is forbidden to use them outside the Content Translation tool.
parameters:
- name: from
in: path
description: The source language code
required: true
schema:
type: string
- name: to
in: path
description: The target language code
required: true
schema:
type: string
- name: provider
in: query
description: The machine translation provider id
required: false
schema:
type: string
enum:
- Apertium
- Matxin
responses:
200:
description: Machine translation fetched successfully
content:
application/json:
schema:
type: string
500:
description: Internal error
content: {}
requestBody:
content:
application/x-www-form-urlencoded:
schema:
required:
- html
properties:
html:
type: string
description: The HTML or plaintext content to translate
x-textarea: true
required: true
x-ample:
- title: Machine translate an HTML fragment using TestClient.
request:
params:
from: en
to: qqq
provider: TestClient
body:
html: <p><a href='Oxygen'>Oxygen</a> is a chemical element with symbol
O and <a href='Atomic number'>atomic number</a> 8.</p>
response:
status: 200
body:
contents: /.+/
headers:
content-type: application/json
/v1/list/pair/{from}/{to}:
get:
tags:
- Tools
description: Lists the tools for a given language pair
parameters:
- name: from
in: path
description: The source language code
required: true
schema:
type: string
- name: to
in: path
description: The target language code
required: true
schema:
type: string
responses:
200:
description: Machine translation fetched successfully
content:
application/json:
schema:
type: string
500:
description: Internal error
content: {}
x-amples:
- title: Get the tools between two language pairs
request:
params:
from: en
to: es
response:
status: 200
headers:
content-type: application/json
/v1/list/languagepairs:
get:
tags:
- Languages
- Service information
description: Lists the language pairs supported by the server
responses:
200:
description: List of all language pairs
content:
application/json:
schema:
type: string
x-amples:
- title: Get all the language pairs
response:
status: 200
headers:
content-type: application/json
/v1/list/{tool}:
get:
tags:
- Tools
- Service information
description: Lists all language pairs that tool supports. If language pairs
are given, list the providers for the tool in that language pair.
parameters:
- name: tool
in: path
description: The tool name
required: true
schema:
type: string
enum:
- mt
- dictionary
- name: from
in: query
description: The source language code
required: false
schema:
type: string
- name: to
in: query
description: The target language code
required: false
schema:
type: string
responses:
200:
description: List of all language pairs
content:
application/json:
schema:
type: string
x-amples:
- title: Get the MT tool between two language pairs
request:
params:
from: en
to: es
tool: mt
response:
status: 200
headers:
content-type: application/json
/v2/page/{sourcelanguage}/{targetlanguage}/{title}:
get:
tags:
- Page content
description: Fetches segmented mediawiki page
parameters:
- name: sourcelanguage
in: path
description: The language code or the domain of the source wiki
required: true
schema:
type: string
- name: targetlanguage
in: path
description: The language code or the domain of the target wiki
required: true
schema:
type: string
- name: title
in: path
description: The page title
required: true
schema:
type: string
- name: revision
in: query
description: The page revision id
required: true
schema:
type: string
responses:
200:
description: Successfully fetched the segmented mediawiki page
content:
application/json:
schema:
type: string
x-amples:
- title: Fetch enwiki Oxygen page
request:
params:
sourcelanguage: en
targetlanguage: es
title: Pickling
revision: 825871454
response:
status: 200
headers:
content-type: application/json
/v2/translate/{from}/{to}:
post:
tags:
- Machine translation
description: Translate the given content from source language to target language.
Also adapt the content for the target language wiki. Some machine translation
providers require an authorization header and it is forbidden to use them
outside the Content Translation tool.
parameters:
- name: from
in: path
description: The source language code
required: true
schema:
type: string
- name: to
in: path
description: The target language code
required: true
schema:
type: string
- name: provider
in: query
description: The machine translation provider id
required: false
schema:
type: string
enum:
- Apertium
- Matxin
requestBody:
content:
application/x-www-form-urlencoded:
schema:
required:
- html
properties:
html:
type: string
description: The HTML content to translate
x-textarea: true
required: true
responses:
200:
description: OK
content: {}
500:
description: Error
content: {}
x-amples:
- title: Machine translate an HTML fragment using TestClient, adapt the links
to target language wiki.
request:
params:
from: en
to: qqq
provider: TestClient
body:
html: <p><a rel="mw:WikiLink" href='Oxygen'>Oxygen</a> is a chemical element
with symbol O and <a rel="mw:WikiLink" href='Atomic number'>atomic number</a>
8.</p>
response:
status: 200
body:
contents: /.+/
headers:
content-type: application/json
/_info:
get:
tags:
- Service information
description: Gets information about the service
responses:
200:
description: OK
content: {}
x-amples:
- title: retrieve service info
request: {}
response:
status: 200
headers:
content-type: application/json
body:
name: /.+/
description: /.+/
version: /.+/
home: /.+/
/_info/name:
get:
tags:
- Service information
description: Gets the name of the service
responses:
200:
description: OK
content: {}
x-amples:
- title: retrieve service name
request: {}
response:
status: 200
headers:
content-type: application/json
body:
name: /.+/
/_info/version:
get:
tags:
- Service information
description: Gets the running version of the service
responses:
200:
description: OK
content: {}
x-amples:
- title: retrieve service version
request: {}
response:
status: 200
headers:
content-type: application/json
body:
version: /.+/
/_info/home:
get:
tags:
- Service information
description: Redirects to the home page
responses:
301:
description: OK
content: {}
x-amples:
- title: redirect to the home page
request: {}
response:
status: 301
components: {}
x-default-params:
domain: en.wikipedia.org