]> source.dussan.org Git - sonarqube.git/commitdiff
add type annotations
authorStas Vilchik <vilchiks@gmail.com>
Mon, 13 Mar 2017 15:18:19 +0000 (16:18 +0100)
committerStas Vilchik <stas-vilchik@users.noreply.github.com>
Tue, 14 Mar 2017 09:39:38 +0000 (10:39 +0100)
server/sonar-web/src/main/js/api/web-api.js

index 5f35ce175b2c4635ea3a472e0780e38dfe24b212..5ccf16624f647cc4a075cb566a30ef49eab19d3a 100644 (file)
  * 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<string>,
+  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<Param>
+};
+
+type Domain = {
+  actions: Array<Action>,
+  description: string,
+  internal: boolean,
+  path: string
+};
+
+export function fetchWebApi (showInternal: boolean = true): Promise<Array<Domain>> {
   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 };