Skip to content
Snippets Groups Projects
Commit 4394b4d7 authored by Mirco Nasuti's avatar Mirco Nasuti
Browse files

progress in Swagger sync

parent 73e2ebc3
No related branches found
No related tags found
No related merge requests found
......@@ -4,8 +4,7 @@ This is the MIP implementation.
## Usage
Run `mvn clean`, `mvn package` and `java -jar target/*.jar` to compile and run a demo.
To use it, you need to configure some URLs and register an openid client on the HBP platform.
Build the project with `./build` and run it with `./run`.
## API Documentation using Swagger (Springfox)
......@@ -13,8 +12,8 @@ The API documentation is available at `<BASE URL>/swagger-ui.html`. A JSON versi
## TODO
* "Dockerize" the project;
* Sync backend with hand written Swagger specs;
* Externalize configuration (DB parameters, security enabled/disabled, ...)
* Sync backend with hand written Swagger specs (see Maintenance section below);
* Implement logout;
* Update frontend (add introduction page, hide header/footer when not logged in, remove mock authors).
......
......@@ -35,7 +35,7 @@ public class ArticlesApi {
@RequestMapping(value = "", produces = {"application/json"}, method = RequestMethod.GET)
public ResponseEntity<List<Article>> getArticles(
@ApiParam(value = "Only ask own articles") @RequestParam(value = "own", required = false) Boolean own,
@ApiParam(value = "Only ask results matching status") @RequestParam(value = "status", required = false) String status,
@ApiParam(value = "Only ask results matching status", allowableValues = "{values=[draft, published, closed]}") @RequestParam(value = "status", required = false) String status,
@ApiParam(value = "Only ask articles from own team") @RequestParam(value = "team", required = false) Boolean team,
@ApiParam(value = "Only ask valid articles") @RequestParam(value = "valid", required = false) Boolean valid) throws NotFoundException {
......
......@@ -124,7 +124,7 @@ public class ModelsApi {
@RequestMapping(value = "/{slug}", produces = {"application/json"}, method = RequestMethod.PUT)
public ResponseEntity<Void> updateAModel(
@ApiParam(value = "slug", required = true) @PathVariable("slug") String slug,
@ApiParam(value = "Model to update", required = true) Model model) throws NotFoundException {
@RequestBody @ApiParam(value = "Model to update", required = true) Model model) throws NotFoundException {
// do some magic!
return new ResponseEntity<Void>(HttpStatus.OK);
}
......
package org.hbp.mip.controllers;
import io.swagger.annotations.*;
import org.hbp.mip.model.Statistics;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.List;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
@Controller
@RequestMapping(value = "/stats", produces = {APPLICATION_JSON_VALUE})
@Api(value = "/stats", description = "the stats API")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-20T14:47:53.152Z")
public class StatsApi {
@ApiOperation(value = "Get the statistics for a group or a variable", notes = "", response = Statistics.class, responseContainer = "List")
@ApiResponses(value = {
@ApiResponse(code = 200, message = "Found"),
@ApiResponse(code = 404, message = "Not found") })
@RequestMapping(value = "/{code}",
produces = { "application/json" },
method = RequestMethod.GET)
public ResponseEntity<List<Statistics>> getTheStatisticsForAGroupOrAVariable(
@ApiParam(value = "code of the group or variable",required=true ) @PathVariable("code") String code
)
throws NotFoundException {
// do some magic!
return new ResponseEntity<List<Statistics>>(HttpStatus.OK);
}
}
......@@ -78,7 +78,7 @@ public class VariablesApi {
@ApiResponse(code = 404, message = "Not found")})
@RequestMapping(value = "/{code}", produces = {"application/json"}, method = RequestMethod.GET)
public ResponseEntity<Variable> getAVariable(
@ApiParam(value = "code ( multiple codes are allowed, separeted by \",\" )", required = true) @PathVariable("code") String code) throws NotFoundException {
@ApiParam(value = "code of the variable ( multiple codes are allowed, separated by \",\" )", required = true) @PathVariable("code") String code) throws NotFoundException {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
org.hibernate.Query query = session.createQuery("from Variable where code= :code");
......
package org.hbp.mip.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.Objects;
@ApiModel(description = "")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.SpringMVCServerCodegen", date = "2016-01-20T14:47:53.152Z")
public class Statistics {
public enum DataTypeEnum {
SummaryStatistics, DatasetStatistics,
};
private DataTypeEnum dataType = null;
/**
* Type of the data
**/
@ApiModelProperty(required = true, value = "Type of the data")
@JsonProperty("dataType")
public DataTypeEnum getDataType() {
return dataType;
}
public void setDataType(DataTypeEnum dataType) {
this.dataType = dataType;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
Statistics statistics = (Statistics) o;
return Objects.equals(dataType, statistics.dataType);
}
@Override
public int hashCode() {
return Objects.hash(dataType);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class Statistics {\n");
sb.append(" dataType: ").append(dataType).append("\n");
sb.append("}\n");
return sb.toString();
}
}
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