]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-15228 Add missing web service response examples
authorDuarte Meneses <duarte.meneses@sonarsource.com>
Tue, 14 Sep 2021 17:08:21 +0000 (12:08 -0500)
committersonartech <sonartech@sonarsource.com>
Thu, 16 Sep 2021 20:03:31 +0000 (20:03 +0000)
18 files changed:
server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/github/GetGithubClientIdAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/github/ListGithubOrganizationsAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/github/ListGithubRepositoriesAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/CountBindingAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/GetBindingAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ListAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ListDefinitionsAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ValidateAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java
server/sonar-webserver-webapi/src/main/java/org/sonar/server/plugins/ws/DownloadAction.java
server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almintegration/ws/github/example-get_github_client_id.json [new file with mode: 0644]
server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almintegration/ws/github/example-list_github_organizations.json [new file with mode: 0644]
server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almintegration/ws/github/example-list_github_repositories.json [new file with mode: 0644]
server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-count_binding.json [new file with mode: 0644]
server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-get_binding.json [new file with mode: 0644]
server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-list.json [new file with mode: 0644]
server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-list_definitions.json [new file with mode: 0644]
server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-validate.json [new file with mode: 0644]

index a28b6352892dc1cb232a4b71914cf7b18803ce38..dbad48c9545fc471ca121425ee8cd66ad617914e 100644 (file)
@@ -51,6 +51,7 @@ public class GetGithubClientIdAction implements AlmIntegrationsWsAction {
       .setDescription("Get the client id of a Github ALM Integration.")
       .setInternal(true)
       .setSince("8.4")
+      .setResponseExample(getClass().getResource("example-get_github_client_id.json"))
       .setHandler(this);
 
     action.createParam(PARAM_ALM_SETTING)
index 64664859dfc03847aeb67c4e3149275de8b57186..fde8714286b79bd978012b49ba7e482d37b79dbf 100644 (file)
@@ -73,6 +73,7 @@ public class ListGithubOrganizationsAction implements AlmIntegrationsWsAction {
       .setDescription("List GitHub organizations<br/>" +
         "Requires the 'Create Projects' permission")
       .setInternal(true)
+      .setResponseExample(getClass().getResource("example-list_github_organizations.json"))
       .setSince("8.4")
       .setHandler(this);
 
index 1451788e347c228e2a32d00bb29a58f4fc0772d8..ba49260eedfdedc63109e930ad801cecaf1e8bd4 100644 (file)
@@ -79,6 +79,7 @@ public class ListGithubRepositoriesAction implements AlmIntegrationsWsAction {
         "Requires the 'Create Projects' permission")
       .setInternal(true)
       .setSince("8.4")
+      .setResponseExample(getClass().getResource("example-list_github_repositories.json"))
       .setHandler(this);
 
     action.createParam(PARAM_ALM_SETTING)
index 751c3738405e50b86696ab3b738fa2f4587e6ae8..66fb7e35dbcb1850c738c1c375a1600da247d556 100644 (file)
@@ -50,7 +50,7 @@ public class CountBindingAction implements AlmSettingsWsAction {
       .setDescription("Count number of project bound to an ALM setting.<br/>" +
         "Requires the 'Administer System' permission")
       .setSince("8.1")
-      .setResponseExample(getClass().getResource("count_binding-example.json"))
+      .setResponseExample(getClass().getResource("example-count_binding.json"))
       .setHandler(this);
 
     action
index a6a9ba16e8586cf5be906587ec7ea94c61b97995..e07ee4a6da4cb73145a8aaf7df2737a5a4d2b841 100644 (file)
@@ -59,7 +59,7 @@ public class GetBindingAction implements AlmSettingsWsAction {
       .setDescription("Get ALM binding of a given project.<br/>" +
         "Requires the 'Administer' permission on the project")
       .setSince("8.1")
-      .setResponseExample(getClass().getResource("get_binding-example.json"))
+      .setResponseExample(getClass().getResource("example-get_binding.json"))
       .setChangelog(new Change("8.6", "Azure binding now contains the project and repository names"))
       .setChangelog(new Change("8.7", "Azure binding now contains a monorepo flag for monorepo feature in Enterprise Edition and above"))
       .setHandler(this);
index 2b3faff5e6c29522650e94bfafe480bf1449371e..df7081df085500cc2ea6473d36363bdf0f8f80a2 100644 (file)
@@ -62,7 +62,7 @@ public class ListAction implements AlmSettingsWsAction {
       .setDescription("List ALM setting available for a given project, sorted by ALM key<br/>" +
         "Requires the 'Administer project' permission if the '" + PARAM_PROJECT + "' parameter is provided, requires the 'Create Projects' permission otherwise.")
       .setSince("8.1")
-      .setResponseExample(getClass().getResource("list-example.json"))
+      .setResponseExample(getClass().getResource("example-list.json"))
       .setHandler(this);
 
     action
index 0e71eb9633e75756c3402a06c4b79816a617c6b1..91c9aff6300c1ba25c4fb32ae3d9f10eec8d0973 100644 (file)
@@ -64,7 +64,8 @@ public class ListDefinitionsAction implements AlmSettingsWsAction {
       .setChangelog(new Change("8.2", "Field 'URL' added for GitLab definitions"),
         new Change("8.6", "Field 'URL' added for Azure definitions"),
         new Change("8.7", "Fields 'personalAccessToken', 'privateKey', and 'clientSecret' are no longer returned"))
-      .setHandler(this);
+      .setHandler(this)
+      .setResponseExample(getClass().getResource("example-list_definitions.json"));
   }
 
   @Override
index 4e98da5649acbb40ae5d334b253f8c360407bad7..8195eb94a0e9c313007a89e90337d44e2bbbcde0 100644 (file)
@@ -74,6 +74,7 @@ public class ValidateAction implements AlmSettingsWsAction {
       .setDescription("Validate an ALM Setting by checking connectivity and permissions<br/>" +
         "Requires the 'Administer System' permission")
       .setSince("8.6")
+      .setResponseExample(getClass().getResource("example-validate.json"))
       .setHandler(this);
 
     action.createParam(PARAM_KEY)
index 9052aa7750bcbce990cdd57665fee8abd39d3f18..ee8fb08ebc33297ab1666b2bf0a75251e337c13e 100644 (file)
@@ -78,7 +78,7 @@ public class SearchTemplatesAction implements PermissionsWsAction {
     context.createAction("search_templates")
       .setDescription("List permission templates.<br />" +
         "Requires the following permission: 'Administer System'.")
-      .setResponseExample(getClass().getResource("search_templates-example.json"))
+      .setResponseExample(getClass().getResource("search_templates-example-without-views.json"))
       .setSince("5.2")
       .addSearchQuery("defau", "permission template names")
       .setHandler(this);
index c1f5e9661812f9ae413a9c033603592cb50842af..d2093232c60bcc20773a232ecd2ebd8de157f200 100644 (file)
@@ -49,6 +49,7 @@ public class DownloadAction implements PluginsWsAction {
       .setSince("7.2")
       .setDescription("Download plugin JAR, for usage by scanner engine")
       .setInternal(true)
+      .setResponseExample(getClass().getResource("example-download.json"))
       .setHandler(this);
 
     action.createParam(PLUGIN_PARAM)
diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almintegration/ws/github/example-get_github_client_id.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almintegration/ws/github/example-get_github_client_id.json
new file mode 100644 (file)
index 0000000..8bb1646
--- /dev/null
@@ -0,0 +1,3 @@
+{
+  "clientId": "Iv1.3123456789af"
+}
diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almintegration/ws/github/example-list_github_organizations.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almintegration/ws/github/example-list_github_organizations.json
new file mode 100644 (file)
index 0000000..de650a7
--- /dev/null
@@ -0,0 +1 @@
+{"paging":{"pageIndex":1,"pageSize":100,"total":1},"organizations":[{"key":"org1","name":"My organization"}]}
diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almintegration/ws/github/example-list_github_repositories.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almintegration/ws/github/example-list_github_repositories.json
new file mode 100644 (file)
index 0000000..eedbe37
--- /dev/null
@@ -0,0 +1 @@
+{"paging":{"pageIndex":1,"pageSize":30,"total":3},"repositories":[{"id":1,"key":"org/repo1","name":"repo1","url":"https://github.com/org/repo1"},{"id":2,"key":"org/repo2","name":"repo2","url":"https://github.com/org/repo2"},{"id":3,"key":"org/repo3","name":"repo3","url":"https://github.com/org/repo3"}]}
diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-count_binding.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-count_binding.json
new file mode 100644 (file)
index 0000000..52e1367
--- /dev/null
@@ -0,0 +1,4 @@
+{
+  "key": "gh1",
+  "projects": 4
+}
diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-get_binding.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-get_binding.json
new file mode 100644 (file)
index 0000000..e829819
--- /dev/null
@@ -0,0 +1,8 @@
+{
+  "key": "gh1",
+  "alm": "github",
+  "repository": "repo1",
+  "url": "https://api.github.com",
+  "summaryCommentEnabled": true,
+  "monorepo": false
+}
diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-list.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-list.json
new file mode 100644 (file)
index 0000000..638f7df
--- /dev/null
@@ -0,0 +1,9 @@
+{
+  "almSettings": [
+    {
+      "key": "gh1",
+      "alm": "github",
+      "url": "https://api.github.com"
+    }
+  ]
+}
diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-list_definitions.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-list_definitions.json
new file mode 100644 (file)
index 0000000..b84ccc6
--- /dev/null
@@ -0,0 +1,14 @@
+{
+  "github": [
+    {
+      "key": "gh1",
+      "url": "https://api.github.com",
+      "appId": "12345",
+      "clientId": "Iv1.12345c6789az"
+    }
+  ],
+  "azure": [ ],
+  "bitbucket": [ ],
+  "gitlab": [ ],
+  "bitbucketcloud": [ ]
+}
diff --git a/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-validate.json b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-validate.json
new file mode 100644 (file)
index 0000000..4f5e3a4
--- /dev/null
@@ -0,0 +1 @@
+{"errors":[{"msg":"Failed to check permissions with Github, check the configuration"}]}