From d6fceade4ea5071ad6a2d4f84a7ffaa0b0873fa7 Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Tue, 14 Sep 2021 12:08:21 -0500 Subject: [PATCH] SONAR-15228 Add missing web service response examples --- .../ws/github/GetGithubClientIdAction.java | 1 + .../ws/github/ListGithubOrganizationsAction.java | 1 + .../ws/github/ListGithubRepositoriesAction.java | 1 + .../server/almsettings/ws/CountBindingAction.java | 2 +- .../server/almsettings/ws/GetBindingAction.java | 2 +- .../sonar/server/almsettings/ws/ListAction.java | 2 +- .../almsettings/ws/ListDefinitionsAction.java | 3 ++- .../server/almsettings/ws/ValidateAction.java | 1 + .../ws/template/SearchTemplatesAction.java | 2 +- .../sonar/server/plugins/ws/DownloadAction.java | 1 + .../ws/github/example-get_github_client_id.json | 3 +++ .../github/example-list_github_organizations.json | 1 + .../github/example-list_github_repositories.json | 1 + .../almsettings/ws/example-count_binding.json | 4 ++++ .../server/almsettings/ws/example-get_binding.json | 8 ++++++++ .../sonar/server/almsettings/ws/example-list.json | 9 +++++++++ .../almsettings/ws/example-list_definitions.json | 14 ++++++++++++++ .../server/almsettings/ws/example-validate.json | 1 + 18 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almintegration/ws/github/example-get_github_client_id.json create mode 100644 server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almintegration/ws/github/example-list_github_organizations.json create mode 100644 server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almintegration/ws/github/example-list_github_repositories.json create mode 100644 server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-count_binding.json create mode 100644 server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-get_binding.json create mode 100644 server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-list.json create mode 100644 server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-list_definitions.json create mode 100644 server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-validate.json diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/github/GetGithubClientIdAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/github/GetGithubClientIdAction.java index a28b6352892..dbad48c9545 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/github/GetGithubClientIdAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/github/GetGithubClientIdAction.java @@ -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) diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/github/ListGithubOrganizationsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/github/ListGithubOrganizationsAction.java index 64664859dfc..fde8714286b 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/github/ListGithubOrganizationsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/github/ListGithubOrganizationsAction.java @@ -73,6 +73,7 @@ public class ListGithubOrganizationsAction implements AlmIntegrationsWsAction { .setDescription("List GitHub organizations
" + "Requires the 'Create Projects' permission") .setInternal(true) + .setResponseExample(getClass().getResource("example-list_github_organizations.json")) .setSince("8.4") .setHandler(this); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/github/ListGithubRepositoriesAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/github/ListGithubRepositoriesAction.java index 1451788e347..ba49260eedf 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/github/ListGithubRepositoriesAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almintegration/ws/github/ListGithubRepositoriesAction.java @@ -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) diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/CountBindingAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/CountBindingAction.java index 751c3738405..66fb7e35dbc 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/CountBindingAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/CountBindingAction.java @@ -50,7 +50,7 @@ public class CountBindingAction implements AlmSettingsWsAction { .setDescription("Count number of project bound to an ALM setting.
" + "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 diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/GetBindingAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/GetBindingAction.java index a6a9ba16e85..e07ee4a6da4 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/GetBindingAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/GetBindingAction.java @@ -59,7 +59,7 @@ public class GetBindingAction implements AlmSettingsWsAction { .setDescription("Get ALM binding of a given project.
" + "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); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ListAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ListAction.java index 2b3faff5e6c..df7081df085 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ListAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ListAction.java @@ -62,7 +62,7 @@ public class ListAction implements AlmSettingsWsAction { .setDescription("List ALM setting available for a given project, sorted by ALM key
" + "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 diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ListDefinitionsAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ListDefinitionsAction.java index 0e71eb9633e..91c9aff6300 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ListDefinitionsAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ListDefinitionsAction.java @@ -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 diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ValidateAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ValidateAction.java index 4e98da5649a..8195eb94a0e 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ValidateAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/almsettings/ws/ValidateAction.java @@ -74,6 +74,7 @@ public class ValidateAction implements AlmSettingsWsAction { .setDescription("Validate an ALM Setting by checking connectivity and permissions
" + "Requires the 'Administer System' permission") .setSince("8.6") + .setResponseExample(getClass().getResource("example-validate.json")) .setHandler(this); action.createParam(PARAM_KEY) diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java index 9052aa7750b..ee8fb08ebc3 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/permission/ws/template/SearchTemplatesAction.java @@ -78,7 +78,7 @@ public class SearchTemplatesAction implements PermissionsWsAction { context.createAction("search_templates") .setDescription("List permission templates.
" + "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); diff --git a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/plugins/ws/DownloadAction.java b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/plugins/ws/DownloadAction.java index c1f5e966181..d2093232c60 100644 --- a/server/sonar-webserver-webapi/src/main/java/org/sonar/server/plugins/ws/DownloadAction.java +++ b/server/sonar-webserver-webapi/src/main/java/org/sonar/server/plugins/ws/DownloadAction.java @@ -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 index 00000000000..8bb1646c197 --- /dev/null +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almintegration/ws/github/example-get_github_client_id.json @@ -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 index 00000000000..de650a7d8ff --- /dev/null +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almintegration/ws/github/example-list_github_organizations.json @@ -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 index 00000000000..eedbe374283 --- /dev/null +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almintegration/ws/github/example-list_github_repositories.json @@ -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 index 00000000000..52e1367de86 --- /dev/null +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-count_binding.json @@ -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 index 00000000000..e829819298d --- /dev/null +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-get_binding.json @@ -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 index 00000000000..638f7dfaf85 --- /dev/null +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-list.json @@ -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 index 00000000000..b84ccc68fad --- /dev/null +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-list_definitions.json @@ -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 index 00000000000..4f5e3a41f78 --- /dev/null +++ b/server/sonar-webserver-webapi/src/main/resources/org/sonar/server/almsettings/ws/example-validate.json @@ -0,0 +1 @@ +{"errors":[{"msg":"Failed to check permissions with Github, check the configuration"}]} -- 2.39.5