I am developing rest plugin for jira atlassian and I have this kind of problem. every time I want that my apis are showing up in REST API Browser I need to add empty constructor to my new api in this format
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path("/import-issues")
public class ImportIssuesRestResource {
private ImportIssuesAction importIssuesAction;
public ImportIssuesRestResource() {
}
public ImportIssuesRestResource(final ImportIssuesAction importIssuesAction) {
this.importIssuesAction = importIssuesAction;
}
@GET
@Path("issueNumber")
@Produces(MediaType.APPLICATION_JSON)
public Response getFields() {
return Response.ok().entity(importIssuesAction.getIssueNumber()).build();
}
}
However what I want is something like this
@Scanned
@Path("/import-issues")
public class ImportIssuesRestResource{
private ImportIssuesAction importIssuesAction;
@Inject
public ImportIssuesRestResource(final ImportIssuesAction importIssuesAction) {
this.importIssuesAction = importIssuesAction;
}
@GET
@Path("issueNumber")
@Produces(MediaType.APPLICATION_JSON)
public Response getFields() {
return Response.ok().entity(importIssuesAction.getIssueNumber()).build();
}
}
with injected constructor and @Scanned. I get this error when I am using the second version of code with @Named in ImportIssuesAction. I have tried also @Scanned.
Error creating bean with name 'rest.ImportIssuesRestResource': Unsatisfied dependency expressed through constructor argument with index 0 of type [action.ImportIssuesAction] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
The others custom implemented working api have similar injected constructor and using annotations @Scanned or @Named. I need my api real-time getting information from class. However currently I am getting NullPointerException from empty constructor in rest of my public getter getIssueNumber. When I am using @Named @Inject combination the all of my custom apis are hidden. I have tried also
in atlassian-plugin.xml. In atlassian-plugin I have also CSMT Rest Resources Can somebody help with implementing custom REST API?