Commit 7c29d090 authored by Mat's avatar Mat

API documentation for Swagger

parent fe0c2a08
......@@ -88,6 +88,11 @@
<artifactId>poi-ooxml</artifactId>
<version>3.15-beta1</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
</dependencies>
<build>
<plugins>
......@@ -108,4 +113,4 @@
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
</project>
......@@ -2,13 +2,19 @@ package searchitect.common.view;
import javax.xml.bind.annotation.XmlRootElement;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* UserAuthRequest - json object used to pass credentials for authentication
*
*/
@XmlRootElement
@ApiModel(value="User credentials")
public class UserAuthRequest {
@ApiModelProperty(value = "The username")
private String username;
@ApiModelProperty(value = "The password")
private String password;
public UserAuthRequest(String username, String password) {
......
......@@ -3,6 +3,10 @@ package searchitect.controller;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import searchitect.util.UrlBuilderService;
import java.security.Principal;
......@@ -42,17 +46,36 @@ public class CheckController {
}
@ApiOperation(value = "Checks if a SE backend is online")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "A welcome message from the backend."),
@ApiResponse(code = 403, message = ""),
@ApiResponse(code = 404, message = ""),
})
@RequestMapping(value="/checkbackend/{b_id}", method = RequestMethod.GET)
public String checkSebackend(@PathVariable ("b_id") String backendName) {
public String checkSebackend(
@ApiParam(value="Name of the backend to check")
@PathVariable ("b_id")
String backendName
) {
String url = urlBuilder.getTargetUrl(backendName, "", "", "");
String response = restTemplate.getForObject(url, String.class);
return response;
}
@ApiOperation(value = "Checks if a SE backend is online for an authenticated user")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "A welcome message from the backend."),
@ApiResponse(code = 403, message = ""),
@ApiResponse(code = 404, message = ""),
})
@RequestMapping(value = "/checkauthbackend/{b_id}", method = RequestMethod.GET)
public ResponseEntity<String> checkAuthenticated(@AuthenticationPrincipal Principal principal, @PathVariable ("b_id") String backendName) {
public ResponseEntity<String> checkAuthenticated(
@AuthenticationPrincipal Principal principal,
@ApiParam(value="Name of the backend to check")
@PathVariable ("b_id")
String backendName) {
String url = urlBuilder.getTargetUrl(backendName, "", "", "");
String response = restTemplate.getForObject(url, String.class);
String name = principal.getName();
......
......@@ -24,6 +24,9 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import searchitect.model.UserEDB;
import searchitect.common.exception.SearchitectException;
import searchitect.model.UserAccount;
......@@ -32,6 +35,7 @@ import searchitect.service.UserAccountRepository;
import searchitect.util.UrlBuilderService;
@RestController
@Api(tags = {"Manage SE repositories on the available backends"})
public class RepositoryController {
private final EDBRepository eDBRepository;
......@@ -95,9 +99,15 @@ public class RepositoryController {
* @param backendName
* @return
*/
@ApiOperation(value = "Create a new repository in a backend")
@RequestMapping(value = "/backend/{b_id}/repository", method = RequestMethod.POST)
public ResponseEntity<String> forwardSetup(@AuthenticationPrincipal Principal principal,
@RequestBody String postData, @PathVariable("b_id") String backendName) {
@ApiParam(value="Data to forward to the backend")
@RequestBody
String postData,
@PathVariable("b_id")
String backendName
) {
try {
String targetUrl = this.urlBuilder.getTargetUrl(backendName, "repository", "", "");
String response = postResponseStringFromBackend(postData, targetUrl);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment