Bladeren bron

SONAR-5286 Add parameter "extra_fields" to display actions and transitions in /api/issues/search

tags/4.4-RC1
Julien Lancelot 10 jaren geleden
bovenliggende
commit
2823c99e85

+ 3
- 0
sonar-server/src/main/java/org/sonar/server/issue/ws/IssuesWs.java Bestand weergeven

@@ -111,6 +111,9 @@ public class IssuesWs implements WebService {
action.createParam("assigned")
.setDescription("To retrieve assigned or unassigned issues")
.setBooleanPossibleValues();
action.createParam("extra_fields")
.setDescription("Add some extra fields on each issue. Available since 4.4")
.setPossibleValues("actions", "transitions");
action.createParam("createdAfter")
.setDescription("To retrieve issues created after the given date (inclusive). Format: date or datetime ISO formats")
.setExampleValue("2013-05-01 (or 2013-05-01T13:00:00+0100)");

+ 6
- 0
sonar-server/src/main/resources/org/sonar/server/issue/ws/example-search.json Bestand weergeven

@@ -28,6 +28,12 @@
"htmlText": "foooooo",
"createdAt": "2013-05-13T18:08:34+0200"
}
],
"actions": ["link-to-jira"],
"transitions": [
"unconfirm",
"resolve",
"falsepositive"
]
}
],

+ 1
- 1
sonar-server/src/main/webapp/WEB-INF/app/controllers/api/issues_controller.rb Bestand weergeven

@@ -32,7 +32,7 @@ class Api::IssuesController < Api::ApiController
hash = {
:maxResultsReached => results.maxResultsReached,
:paging => paging_to_hash(results.paging),
:issues => results.issues.map { |issue| Issue.to_hash(issue) },
:issues => results.issues.map { |issue| Issue.to_hash(issue, params[:extra_fields]) },
:components => results.components.map { |component| component_to_hash(component) },
:projects => results.projects.map { |project| component_to_hash(project) },
:rules => results.rules.map { |rule| Rule.to_hash(rule) },

+ 5
- 1
sonar-server/src/main/webapp/WEB-INF/app/models/issue.rb Bestand weergeven

@@ -20,7 +20,7 @@

class Issue

def self.to_hash(issue)
def self.to_hash(issue, extra_params={})
hash = {
:key => issue.key,
:component => issue.componentKey,
@@ -47,6 +47,10 @@ class Issue
if issue.comments.size>0
hash[:comments] = issue.comments.map { |c| comment_to_hash(c) }
end
unless extra_params.blank?
hash[:actions] = Internal.issues.listActions(issue).map { |t| t.key() } if extra_params.include? 'actions'
hash[:transitions] = Internal.issues.listTransitions(issue).map { |t| t.key() } if extra_params.include? 'transitions'
end
hash
end


+ 1
- 1
sonar-server/src/test/java/org/sonar/server/issue/ws/IssuesWsTest.java Bestand weergeven

@@ -89,7 +89,7 @@ public class IssuesWsTest {
assertThat(show.isInternal()).isFalse();
assertThat(show.handler()).isInstanceOf(RailsHandler.class);
assertThat(show.responseExampleAsString()).isNotEmpty();
assertThat(show.params()).hasSize(18);
assertThat(show.params()).hasSize(19);
}

@Test

Laden…
Annuleren
Opslaan