From: Stas Vilchik Date: Mon, 13 Mar 2017 15:18:19 +0000 (+0100) Subject: add type annotations X-Git-Tag: 6.4-RC1~767 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c3358eec573fb6fbc171843f0b4fcb9fe51f139c;p=sonarqube.git add type annotations --- diff --git a/server/sonar-web/src/main/js/api/web-api.js b/server/sonar-web/src/main/js/api/web-api.js index 5f35ce175b2..5ccf16624f6 100644 --- a/server/sonar-web/src/main/js/api/web-api.js +++ b/server/sonar-web/src/main/js/api/web-api.js @@ -17,11 +17,47 @@ * along with this program; if not, write to the Free Software Foundation, * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ +// @flow import { getJSON } from '../helpers/request'; -export function fetchWebApi (showInternal = true) { +type Param = { + key: string, + defaultValue?: string, + description: string, + deprecatedKey?: string, + deprecatedKeySince?: string, + deprecatedSince?: string, + exampleValue?: string, + internal: boolean, + possibleValues?: Array, + required: boolean +}; + +type Action = { + key: string, + description: string, + deprecatedSince?: string, + since?: string, + internal: boolean, + post: boolean, + hasResponseExample: boolean, + changelog: Array<{ + version: string, + description: string + }>, + params?: Array +}; + +type Domain = { + actions: Array, + description: string, + internal: boolean, + path: string +}; + +export function fetchWebApi (showInternal: boolean = true): Promise> { const url = '/api/webservices/list'; - const data = { 'include_internals': showInternal }; + const data = { include_internals: showInternal }; return getJSON(url, data).then(r => r.webServices.map(domain => { const internal = !domain.actions.find(action => !action.internal); @@ -30,7 +66,7 @@ export function fetchWebApi (showInternal = true) { })); } -export function fetchResponseExample (domain, action) { +export function fetchResponseExample (domain: string, action: string): Promise<{ example: string }> { const url = '/api/webservices/response_example'; const data = { controller: domain, action };