diff --git a/pom.xml b/pom.xml index 1f71ff54680e341561654a0abac5efe036278e7a..9d6856e37ee15b51f9eb0215ff06b69a7201c559 100644 --- a/pom.xml +++ b/pom.xml @@ -299,6 +299,11 @@ <version>1.5.5</version> <scope>runtime</scope> </dependency> + <dependency> + <groupId>io.swagger</groupId> + <artifactId>swagger-annotations</artifactId> + <version>1.5.2</version> + </dependency> </dependencies> <build> @@ -400,6 +405,38 @@ <artifactId>maven-war-plugin</artifactId> <version>2.6</version> </plugin> + <plugin> + <groupId>com.github.kongchen</groupId> + <artifactId>swagger-maven-plugin</artifactId> + <version>3.1.0</version> + <configuration> + <apiSources> + <apiSource> + <springmvc>true</springmvc> + <locations>de.thm.arsnova.controller;de.thm.arsnova.entities</locations> + <schemes>http,https</schemes> + <basePath>/api</basePath> + <info> + <title>ARSnova API Documentation</title> + <version>${project.version}</version> + <description>This is the documentation of the ARSnova API</description> + <contact> + <email>info@arsnova.eu</email> + </contact> + </info> + <swaggerDirectory>${project.build.directory}/classes</swaggerDirectory> + </apiSource> + </apiSources> + </configuration> + <executions> + <execution> + <phase>compile</phase> + <goals> + <goal>generate</goal> + </goals> + </execution> + </executions> + </plugin> </plugins> </build> diff --git a/src/main/java/de/thm/arsnova/config/ExtraConfig.java b/src/main/java/de/thm/arsnova/config/ExtraConfig.java index c6966dc1f9a93650af922f06eb60280235a3f5b3..e1848c7c67ed8b1c16bd38ccfb04835b475e6bfe 100644 --- a/src/main/java/de/thm/arsnova/config/ExtraConfig.java +++ b/src/main/java/de/thm/arsnova/config/ExtraConfig.java @@ -30,6 +30,10 @@ import org.springframework.core.env.Environment; import org.springframework.core.io.ClassPathResource; import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.context.annotation.Import; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; import de.thm.arsnova.connector.client.ConnectorClient; import de.thm.arsnova.connector.client.ConnectorClientImpl; @@ -37,12 +41,14 @@ import de.thm.arsnova.socket.ARSnovaSocket; import de.thm.arsnova.socket.ARSnovaSocketIOServer; import de.thm.arsnova.ImageUtils; + /** * Loads property file and configures non-security related beans and components. */ +@EnableWebMvc @Configuration @EnableCaching -public class ExtraConfig { +public class ExtraConfig extends WebMvcConfigurerAdapter { @Autowired private Environment env; diff --git a/src/main/java/de/thm/arsnova/controller/AbstractController.java b/src/main/java/de/thm/arsnova/controller/AbstractController.java index bdb2d8f7eb724935efa44e643ef44611b98bb254..7871273b56417843fa1a3ccc10a6950c0fc19fe0 100644 --- a/src/main/java/de/thm/arsnova/controller/AbstractController.java +++ b/src/main/java/de/thm/arsnova/controller/AbstractController.java @@ -23,4 +23,12 @@ package de.thm.arsnova.controller; public class AbstractController { protected static final String X_DEPRECATED_API = "X-Deprecated-API"; protected static final String X_FORWARDED = "X-Forwarded"; + protected static final String HTML_STATUS_200 = "OK"; + protected static final String HTML_STATUS_201 = "Created"; + protected static final String HTML_STATUS_204 = "No Content"; + protected static final String HTML_STATUS_400 = "Bad request"; + protected static final String HTML_STATUS_403 = "Forbidden"; + protected static final String HTML_STATUS_404 = "Not Found"; + protected static final String HTML_STATUS_501 = "Not Implemented"; + protected static final String HTML_STATUS_503 = "Service Unavailable"; } diff --git a/src/main/java/de/thm/arsnova/controller/AudienceQuestionController.java b/src/main/java/de/thm/arsnova/controller/AudienceQuestionController.java index 660c4538134e08bb8686e97853a48d64eae4ac5f..2f60da21dd009c4e363e9321aab34b89a72d8b24 100644 --- a/src/main/java/de/thm/arsnova/controller/AudienceQuestionController.java +++ b/src/main/java/de/thm/arsnova/controller/AudienceQuestionController.java @@ -31,6 +31,12 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; + import de.thm.arsnova.entities.InterposedReadingCount; import de.thm.arsnova.entities.transport.InterposedQuestion; import de.thm.arsnova.exceptions.BadRequestException; @@ -43,6 +49,7 @@ import de.thm.arsnova.web.Pagination; */ @RestController @RequestMapping("/audiencequestion") +@Api(value = "/audiencequestion", description = "the Audience Question API") public class AudienceQuestionController extends PaginationController { public static final Logger LOGGER = LoggerFactory.getLogger(AudienceQuestionController.class); @@ -50,34 +57,49 @@ public class AudienceQuestionController extends PaginationController { @Autowired private IQuestionService questionService; + @ApiOperation(value = "Count all the questions in current session", + nickname = "getAudienceQuestionCount") @RequestMapping(value = "/count", method = RequestMethod.GET) @DeprecatedApi - public int getInterposedCount(@RequestParam final String sessionkey) { + @Deprecated + public int getInterposedCount(@ApiParam(value="Session-Key from current session", required=true) @RequestParam final String sessionkey) { return questionService.getInterposedCount(sessionkey); } + @ApiOperation(value = "count all unread interposed questions", + nickname = "getUnreadInterposedCount") @RequestMapping(value = "/readcount", method = RequestMethod.GET) @DeprecatedApi - public InterposedReadingCount getUnreadInterposedCount(@RequestParam("sessionkey") final String sessionkey, String user) { + @Deprecated + public InterposedReadingCount getUnreadInterposedCount(@ApiParam(value = "Session-Key from current session", required = true) @RequestParam("sessionkey") final String sessionkey, String user) { return questionService.getInterposedReadingCount(sessionkey, user); } + @ApiOperation(value = "Retrieves all Interposed Questions for a Session", + nickname = "getInterposedQuestions") @RequestMapping(value = "/", method = RequestMethod.GET) @Pagination - public List<InterposedQuestion> getInterposedQuestions(@RequestParam final String sessionkey) { + public List<InterposedQuestion> getInterposedQuestions(@ApiParam(value = "Session-Key from current session", required = true) @RequestParam final String sessionkey) { return InterposedQuestion.fromList(questionService.getInterposedQuestions(sessionkey, offset, limit)); } + @ApiOperation(value = "Retrieves an InterposedQuestion", + nickname = "getInterposedQuestion") @RequestMapping(value = "/{questionId}", method = RequestMethod.GET) - public InterposedQuestion getInterposedQuestion(@PathVariable final String questionId) { + public InterposedQuestion getInterposedQuestion(@ApiParam(value = "ID of the question that needs to be deleted", required = true) @PathVariable final String questionId) { return new InterposedQuestion(questionService.readInterposedQuestion(questionId)); } + @ApiOperation(value = "Creates a new Interposed Question for a Session and returns the InterposedQuestion's data", + nickname = "postInterposedQuestion") + @ApiResponses(value = { + @ApiResponse(code = 400, message = HTML_STATUS_400) + }) @RequestMapping(value = "/", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public void postInterposedQuestion( - @RequestParam final String sessionkey, - @RequestBody final de.thm.arsnova.entities.InterposedQuestion question + @ApiParam(value="Session-Key from current session", required=true) @RequestParam final String sessionkey, + @ApiParam(value="the body from the new question", required=true) @RequestBody final de.thm.arsnova.entities.InterposedQuestion question ) { if (questionService.saveQuestion(question)) { return; @@ -86,8 +108,10 @@ public class AudienceQuestionController extends PaginationController { throw new BadRequestException(); } + @ApiOperation(value = "Deletes an InterposedQuestion", + nickname = "deleteInterposedQuestion") @RequestMapping(value = "/{questionId}", method = RequestMethod.DELETE) - public void deleteInterposedQuestion(@PathVariable final String questionId) { + public void deleteInterposedQuestion(@ApiParam(value = "ID of the question that needs to be deleted", required=true) @PathVariable final String questionId) { questionService.deleteInterposedQuestion(questionId); } } diff --git a/src/main/java/de/thm/arsnova/controller/CourseController.java b/src/main/java/de/thm/arsnova/controller/CourseController.java index a7104db07fade0def1f882ebf2393addddbec869..e79f77496c73b4dc22bd05da0edd6f798eac0b10 100644 --- a/src/main/java/de/thm/arsnova/controller/CourseController.java +++ b/src/main/java/de/thm/arsnova/controller/CourseController.java @@ -30,6 +30,11 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; import de.thm.arsnova.connector.client.ConnectorClient; import de.thm.arsnova.connector.model.Course; @@ -55,6 +60,7 @@ public class CourseController extends AbstractController { @RequestMapping(value = "/mycourses", method = RequestMethod.GET) public List<Course> myCourses( + @ApiParam(value="sort my courses by name", required=true) @RequestParam(value = "sortby", defaultValue = "name") final String sortby ) { diff --git a/src/main/java/de/thm/arsnova/controller/FeedbackController.java b/src/main/java/de/thm/arsnova/controller/FeedbackController.java index cee5de523fc42842e7e586063bd0f0d2240edba3..98827df3cec5ba9b08236b41d1f5a8e3f91ecc14 100644 --- a/src/main/java/de/thm/arsnova/controller/FeedbackController.java +++ b/src/main/java/de/thm/arsnova/controller/FeedbackController.java @@ -28,6 +28,11 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; + import de.thm.arsnova.entities.Feedback; import de.thm.arsnova.entities.User; import de.thm.arsnova.exceptions.NotFoundException; @@ -53,12 +58,14 @@ public class FeedbackController extends AbstractController { private IUserService userService; @DeprecatedApi + @Deprecated @RequestMapping(value = "/session/{sessionkey}/feedback", method = RequestMethod.GET) public Feedback getFeedback(@PathVariable final String sessionkey) { return feedbackService.getFeedback(sessionkey); } @DeprecatedApi + @Deprecated @RequestMapping(value = "/session/{sessionkey}/myfeedback", method = RequestMethod.GET) public Integer getMyFeedback(@PathVariable final String sessionkey) { Integer value = feedbackService.getMyFeedback(sessionkey, userService.getCurrentUser()); @@ -69,24 +76,28 @@ public class FeedbackController extends AbstractController { } @DeprecatedApi + @Deprecated @RequestMapping(value = "/session/{sessionkey}/feedbackcount", method = RequestMethod.GET) public int getFeedbackCount(@PathVariable final String sessionkey) { return feedbackService.getFeedbackCount(sessionkey); } @DeprecatedApi + @Deprecated @RequestMapping(value = "/session/{sessionkey}/roundedaveragefeedback", method = RequestMethod.GET) public long getAverageFeedbackRounded(@PathVariable final String sessionkey) { return feedbackService.getAverageFeedbackRounded(sessionkey); } @DeprecatedApi + @Deprecated @RequestMapping(value = "/session/{sessionkey}/averagefeedback", method = RequestMethod.GET) public double getAverageFeedback(@PathVariable final String sessionkey) { return feedbackService.getAverageFeedback(sessionkey); } @DeprecatedApi + @Deprecated @RequestMapping(value = "/session/{sessionkey}/feedback", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public Feedback postFeedback( diff --git a/src/main/java/de/thm/arsnova/controller/LecturerQuestionController.java b/src/main/java/de/thm/arsnova/controller/LecturerQuestionController.java index 9a63ae7177d02f1814c74d575b265f7db8bd297f..fe8fcedc0b220198e75a9b62ce77bbaf61f460d7 100644 --- a/src/main/java/de/thm/arsnova/controller/LecturerQuestionController.java +++ b/src/main/java/de/thm/arsnova/controller/LecturerQuestionController.java @@ -35,6 +35,11 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; + import de.thm.arsnova.PaginationListDecorator; import de.thm.arsnova.entities.Answer; import de.thm.arsnova.entities.Question; @@ -51,6 +56,7 @@ import de.thm.arsnova.web.Pagination; */ @RestController @RequestMapping("/lecturerquestion") +@Api(value = "/lecturerquestion", description = "Operations for Lecture Questions") public class LecturerQuestionController extends PaginationController { public static final Logger LOGGER = LoggerFactory.getLogger(LecturerQuestionController.class); @@ -58,6 +64,11 @@ public class LecturerQuestionController extends PaginationController { @Autowired private IQuestionService questionService; + @ApiOperation(value = "Get question with provided question Id", + nickname = "getQuestion") + @ApiResponses(value = { + @ApiResponse(code = 404, message = HTML_STATUS_404) + }) @RequestMapping(value = "/{questionId}", method = RequestMethod.GET) public Question getQuestion(@PathVariable final String questionId) { final Question question = questionService.getQuestion(questionId); @@ -68,6 +79,11 @@ public class LecturerQuestionController extends PaginationController { throw new NotFoundException(); } + @ApiOperation(value = "Post provided question", + nickname = "postQuestion") + @ApiResponses(value = { + @ApiResponse(code = 400, message = HTML_STATUS_400) + }) @RequestMapping(value = "/", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) public Question postQuestion(@RequestBody final Question question) { @@ -77,6 +93,11 @@ public class LecturerQuestionController extends PaginationController { throw new BadRequestException(); } + @ApiOperation(value = "Update the question, identified by provided id, with the provided question in the Request Body", + nickname = "updateQuestion") + @ApiResponses(value = { + @ApiResponse(code = 400, message = HTML_STATUS_400) + }) @RequestMapping(value = "/{questionId}", method = RequestMethod.PUT) public Question updateQuestion( @PathVariable final String questionId, @@ -89,6 +110,8 @@ public class LecturerQuestionController extends PaginationController { } } + @ApiOperation(value = "Start new Pi Round on question, identified by provided id, with an optional time", + nickname = "startPiRound") @RequestMapping(value = "/{questionId}/questionimage", method = RequestMethod.GET) public String getQuestionImage( @PathVariable final String questionId, @@ -116,6 +139,8 @@ public class LecturerQuestionController extends PaginationController { } @RequestMapping(value = "/{questionId}/canceldelayedpiround", method = RequestMethod.POST) + @ApiOperation(value = "Cancel Pi Round on question, identified by provided id", + nickname = "cancelPiRound") public void cancelPiRound( @PathVariable final String questionId ) { @@ -123,12 +148,16 @@ public class LecturerQuestionController extends PaginationController { } @RequestMapping(value = "/{questionId}/resetpiroundstate", method = RequestMethod.POST) + @ApiOperation(value = "Reset Pi Round on question, identified by provided id", + nickname = "resetPiQuestion") public void resetPiQuestion( @PathVariable final String questionId ) { questionService.resetPiRoundState(questionId); } + @ApiOperation(value = "Set voting admission on question, identified by provided id", + nickname = "setVotingAdmission") @RequestMapping(value = "/{questionId}/disablevote", method = RequestMethod.POST) public void setVotingAdmission( @PathVariable final String questionId, @@ -143,6 +172,8 @@ public class LecturerQuestionController extends PaginationController { questionService.setVotingAdmission(questionId, disable); } + @ApiOperation(value = "Set voting admission for all questions", + nickname = "setVotingAdmissionForAllQuestions") @RequestMapping(value = "/disablevote", method = RequestMethod.POST) public void setVotingAdmissionForAllQuestions( @RequestParam final String sessionkey, @@ -168,6 +199,8 @@ public class LecturerQuestionController extends PaginationController { } } + @ApiOperation(value = "Publish a question, identified by provided id and question in Request Body.", + nickname = "publishQuestion") @RequestMapping(value = "/{questionId}/publish", method = RequestMethod.POST) public void publishQuestion( @PathVariable final String questionId, @@ -180,6 +213,8 @@ public class LecturerQuestionController extends PaginationController { questionService.update(question); } + @ApiOperation(value = "Publish all questions", + nickname = "publishAllQuestions") @RequestMapping(value = "/publish", method = RequestMethod.POST) public void publishAllQuestions( @RequestParam final String sessionkey, @@ -205,6 +240,8 @@ public class LecturerQuestionController extends PaginationController { } } + @ApiOperation(value = "Publish statistics from question with provided id", + nickname = "publishStatistics") @RequestMapping(value = "/{questionId}/publishstatistics", method = RequestMethod.POST) public void publishStatistics( @PathVariable final String questionId, @@ -217,6 +254,8 @@ public class LecturerQuestionController extends PaginationController { questionService.update(question); } + @ApiOperation(value = "Publish correct answer from question with provided id", + nickname = "publishCorrectAnswer") @RequestMapping(value = "/{questionId}/publishcorrectanswer", method = RequestMethod.POST) public void publishCorrectAnswer( @PathVariable final String questionId, @@ -229,6 +268,8 @@ public class LecturerQuestionController extends PaginationController { questionService.update(question); } + @ApiOperation(value = "Get skill questions", + nickname = "getSkillQuestions") @RequestMapping(value = "/", method = RequestMethod.GET) @Pagination public List<Question> getSkillQuestions( @@ -259,6 +300,8 @@ public class LecturerQuestionController extends PaginationController { return new PaginationListDecorator<Question>(questions, offset, limit); } + @ApiOperation(value = "Delete skill questions", + nickname = "deleteSkillQuestions") @RequestMapping(value = { "/" }, method = RequestMethod.DELETE) public void deleteSkillQuestions( @RequestParam final String sessionkey, @@ -278,7 +321,10 @@ public class LecturerQuestionController extends PaginationController { } } + @ApiOperation(value = "Get the amount of skill questions by the sessionkey", + nickname = "getSkillQuestionCount") @DeprecatedApi + @Deprecated @RequestMapping(value = "/count", method = RequestMethod.GET) public int getSkillQuestionCount( @RequestParam final String sessionkey, @@ -297,6 +343,8 @@ public class LecturerQuestionController extends PaginationController { } } + @ApiOperation(value = "Delete answers and questions", + nickname = "deleteAnswersAndQuestion") @RequestMapping(value = "/{questionId}", method = RequestMethod.DELETE) public void deleteAnswersAndQuestion( @PathVariable final String questionId @@ -304,7 +352,10 @@ public class LecturerQuestionController extends PaginationController { questionService.deleteQuestion(questionId); } + @ApiOperation(value = "Get unanswered skill question ID by provided session ID", + nickname = "getUnAnsweredSkillQuestionIds") @DeprecatedApi + @Deprecated @RequestMapping(value = "/unanswered", method = RequestMethod.GET) public List<String> getUnAnsweredSkillQuestionIds( @RequestParam final String sessionkey, @@ -341,7 +392,10 @@ public class LecturerQuestionController extends PaginationController { * @throws ForbiddenException * if not logged in */ + @ApiOperation(value = "Get my answer for a question, identified by provided question ID", + nickname = "getMyAnswer") @DeprecatedApi + @Deprecated @RequestMapping(value = "/{questionId}/myanswer", method = RequestMethod.GET) public Answer getMyAnswer( @PathVariable final String questionId, @@ -373,6 +427,8 @@ public class LecturerQuestionController extends PaginationController { * @throws ForbiddenException * if not logged in */ + @ApiOperation(value = "Get answers for a question, identified by provided question ID", + nickname = "getAnswers") @RequestMapping(value = "/{questionId}/answer/", method = RequestMethod.GET) public List<Answer> getAnswers( @PathVariable final String questionId, @@ -399,6 +455,8 @@ public class LecturerQuestionController extends PaginationController { return answers; } + @ApiOperation(value = "Save answer, provided in the Request Body, for a question, identified by provided question ID", + nickname = "saveAnswer") @RequestMapping(value = "/{questionId}/answer/", method = RequestMethod.POST) public Answer saveAnswer( @PathVariable final String questionId, @@ -408,6 +466,8 @@ public class LecturerQuestionController extends PaginationController { return questionService.saveAnswer(questionId, answer); } + @ApiOperation(value = "Update answer, provided in Request Body, identified by question ID and answer ID", + nickname = "updateAnswer") @RequestMapping(value = "/{questionId}/answer/{answerId}", method = RequestMethod.PUT) public Answer updateAnswer( @PathVariable final String questionId, @@ -418,6 +478,8 @@ public class LecturerQuestionController extends PaginationController { return questionService.updateAnswer(answer); } + @ApiOperation(value = "Get Image, identified by question ID and answer ID", + nickname = "getImage") @RequestMapping(value = "/{questionId}/answer/{answerId}/image", method = RequestMethod.GET) public String getImage( @PathVariable final String questionId, @@ -428,6 +490,8 @@ public class LecturerQuestionController extends PaginationController { return questionService.getImage(questionId, answerId); } + @ApiOperation(value = "Delete answer, identified by question ID and answer ID", + nickname = "deleteAnswer") @RequestMapping(value = "/{questionId}/answer/{answerId}", method = RequestMethod.DELETE) public void deleteAnswer( @PathVariable final String questionId, @@ -437,6 +501,8 @@ public class LecturerQuestionController extends PaginationController { questionService.deleteAnswer(questionId, answerId); } + @ApiOperation(value = "Delete answers from a question, identified by question ID", + nickname = "deleteAnswers") @RequestMapping(value = "/{questionId}/answer/", method = RequestMethod.DELETE) public void deleteAnswers( @PathVariable final String questionId, @@ -445,6 +511,8 @@ public class LecturerQuestionController extends PaginationController { questionService.deleteAnswers(questionId); } + @ApiOperation(value = "Delete all answers and questions from a session, identified by sessionkey", + nickname = "deleteAllQuestionsAnswers") @RequestMapping(value = "/answers", method = RequestMethod.DELETE) public void deleteAllQuestionsAnswers( @RequestParam final String sessionkey, @@ -474,12 +542,17 @@ public class LecturerQuestionController extends PaginationController { * @throws ForbiddenException * if not logged in */ + @ApiOperation(value = "Get the amount of answers for a question, identified by question ID", + nickname = "getAnswerCount") @DeprecatedApi + @Deprecated @RequestMapping(value = "/{questionId}/answercount", method = RequestMethod.GET) public int getAnswerCount(@PathVariable final String questionId) { return questionService.getAnswerCount(questionId); } + @ApiOperation(value = "Get the amount of answers for a question, identified by the question ID", + nickname = "getAllAnswerCount") @RequestMapping(value = "/{questionId}/allroundanswercount", method = RequestMethod.GET) public List<Integer> getAllAnswerCount(@PathVariable final String questionId) { return Arrays.asList( @@ -488,11 +561,15 @@ public class LecturerQuestionController extends PaginationController { ); } + @ApiOperation(value = "Get the total amount of answers by a question, identified by the question ID", + nickname = "getTotalAnswerCountByQuestion") @RequestMapping(value = "/{questionId}/totalanswercount", method = RequestMethod.GET) public int getTotalAnswerCountByQuestion(@PathVariable final String questionId) { return questionService.getTotalAnswerCountByQuestion(questionId); } + @ApiOperation(value = "Get the amount of answers and abstention answers by a question, identified by the question ID", + nickname = "getAnswerAndAbstentionCount") @RequestMapping(value = "/{questionId}/answerandabstentioncount", method = RequestMethod.GET) public List<Integer> getAnswerAndAbstentionCount(@PathVariable final String questionId) { List<Integer> list = Arrays.asList( @@ -503,19 +580,27 @@ public class LecturerQuestionController extends PaginationController { return list; } + @ApiOperation(value = "Get all Freetext answers by a question, identified by the question ID", + nickname = "getFreetextAnswers") @RequestMapping(value = "/{questionId}/freetextanswer/", method = RequestMethod.GET) @Pagination public List<Answer> getFreetextAnswers(@PathVariable final String questionId) { return questionService.getFreetextAnswers(questionId, offset, limit); } + @ApiOperation(value = "Get my answers of an session, identified by the sessionkey", + nickname = "getMyAnswers") @DeprecatedApi + @Deprecated @RequestMapping(value = "/myanswers", method = RequestMethod.GET) public List<Answer> getMyAnswers(@RequestParam final String sessionkey) { return questionService.getMyAnswers(sessionkey); } + @ApiOperation(value = "Get the total amount of answers of an session, identified by the sessionkey", + nickname = "getTotalAnswerCount") @DeprecatedApi + @Deprecated @RequestMapping(value = "/answercount", method = RequestMethod.GET) public int getTotalAnswerCount( @RequestParam final String sessionkey, @@ -534,8 +619,8 @@ public class LecturerQuestionController extends PaginationController { @RequestMapping(value = "/subjectsort", method = RequestMethod.POST) public void setSubjectSortOrder( @RequestParam(required = true) final String sessionkey, - @RequestParam(required = true) final String sorttype, - @RequestParam(required = true) final String ispreparation, + @RequestParam(required = true) final String sorttype, + @RequestParam(required = true) final String ispreparation, @RequestBody String[] sortOrder ) { try { @@ -567,7 +652,7 @@ public class LecturerQuestionController extends PaginationController { throw new BadRequestException(); } } - + @RequestMapping(value = "/questionsort", method = RequestMethod.GET) public String getQuestionSortType( @RequestParam(required = true) final String sessionkey, diff --git a/src/main/java/de/thm/arsnova/controller/SessionController.java b/src/main/java/de/thm/arsnova/controller/SessionController.java index 5dd16d2aa0f72390e054a0d4effe6019eb6285b2..7b9e1bdb321671eca85ba7ec1ef9ed4e7edd45a0 100644 --- a/src/main/java/de/thm/arsnova/controller/SessionController.java +++ b/src/main/java/de/thm/arsnova/controller/SessionController.java @@ -36,6 +36,12 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; + import de.thm.arsnova.connector.model.Course; import de.thm.arsnova.entities.Session; import de.thm.arsnova.entities.SessionFeature; @@ -57,6 +63,7 @@ import de.thm.arsnova.web.Pagination; */ @RestController @RequestMapping("/session") +@Api(value = "/session", description = "the Session Controller API") public class SessionController extends PaginationController { public static final Logger LOGGER = LoggerFactory.getLogger(SessionController.class); @@ -67,25 +74,40 @@ public class SessionController extends PaginationController { @Autowired private IUserService userService; + @ApiOperation(value = "join a session", + nickname = "joinSession") + @DeprecatedApi + @Deprecated @RequestMapping(value = "/{sessionkey}", method = RequestMethod.GET) - public Session joinSession(@PathVariable final String sessionkey) { + public Session joinSession(@ApiParam(value = "Session-Key from current session", required = true) @PathVariable final String sessionkey) { return Session.anonymizedCopy(sessionService.getSession(sessionkey)); } + @ApiOperation(value = "deletes a session", + nickname = "deleteSession") @RequestMapping(value = "/{sessionkey}", method = RequestMethod.DELETE) - public void deleteSession(@PathVariable final String sessionkey) { + public void deleteSession(@ApiParam(value = "Session-Key from current session", required = true) @PathVariable final String sessionkey) { sessionService.deleteSession(sessionkey); } + @ApiOperation(value = "count active users", + nickname = "countActiveUsers") @DeprecatedApi + @Deprecated @RequestMapping(value = "/{sessionkey}/activeusercount", method = RequestMethod.GET) - public int countActiveUsers(@PathVariable final String sessionkey) { + public int countActiveUsers(@ApiParam(value = "Session-Key from current session", required = true) @PathVariable final String sessionkey) { return sessionService.activeUsers(sessionkey); } + @ApiOperation(value = "Creates a new Session and returns the Session's data", + nickname = "postNewSession") + @ApiResponses(value = { + @ApiResponse(code = 201, message = HTML_STATUS_201), + @ApiResponse(code = 503, message = HTML_STATUS_503) + }) @RequestMapping(value = "/", method = RequestMethod.POST) @ResponseStatus(HttpStatus.CREATED) - public Session postNewSession(@RequestBody final Session session, final HttpServletResponse response) { + public Session postNewSession(@ApiParam(value = "current session", required = true) @RequestBody final Session session, @ApiParam(value = "http servlet response", required = true) final HttpServletResponse response) { if (session != null && session.isCourseSession()) { final List<Course> courses = new ArrayList<Course>(); final Course course = new Course(); @@ -109,20 +131,28 @@ public class SessionController extends PaginationController { return newSession; } + @ApiOperation(value = "updates a session", + nickname = "postNewSession") @RequestMapping(value = "/{sessionkey}", method = RequestMethod.PUT) public Session updateSession( - @PathVariable final String sessionkey, - @RequestBody final Session session + @ApiParam(value = "session-key from current session", required = true) @PathVariable final String sessionkey, + @ApiParam(value = "current session", required = true) @RequestBody final Session session ) { return sessionService.updateSession(sessionkey, session); } + @ApiOperation(value = "Retrieves a list of Sessions", + nickname = "getSessions") + @ApiResponses(value = { + @ApiResponse(code = 204, message = HTML_STATUS_204), + @ApiResponse(code = 501, message = HTML_STATUS_501) + }) @RequestMapping(value = "/", method = RequestMethod.GET) @Pagination public List<Session> getSessions( - @RequestParam(value = "ownedonly", defaultValue = "false") final boolean ownedOnly, - @RequestParam(value = "visitedonly", defaultValue = "false") final boolean visitedOnly, - @RequestParam(value = "sortby", defaultValue = "name") final String sortby, + @ApiParam(value="ownedOnly", required=true) @RequestParam(value = "ownedonly", defaultValue = "false") final boolean ownedOnly, + @ApiParam(value="visitedOnly", required=true) @RequestParam(value = "visitedonly", defaultValue = "false") final boolean visitedOnly, + @ApiParam(value="sortby", required=true) @RequestParam(value = "sortby", defaultValue = "name") final String sortby, final HttpServletResponse response ) { List<Session> sessions = null; @@ -161,12 +191,17 @@ public class SessionController extends PaginationController { * @param response * @return */ + @ApiOperation(value = "Retrieves a Session", + nickname = "getMySessions") + @ApiResponses(value = { + @ApiResponse(code = 204, message = HTML_STATUS_204) + }) @RequestMapping(value = "/", method = RequestMethod.GET, params = "statusonly=true") @Pagination public List<SessionInfo> getMySessions( - @RequestParam(value = "visitedonly", defaultValue = "false") final boolean visitedOnly, - @RequestParam(value = "sortby", defaultValue = "name") final String sortby, - final HttpServletResponse response + @ApiParam(value = "visitedOnly", required = true) @RequestParam(value = "visitedonly", defaultValue = "false") final boolean visitedOnly, + @ApiParam(value = "sort by", required = false) @RequestParam(value = "sortby", defaultValue = "name") final String sortby, + @ApiParam(value = "http servlet response", required = true) final HttpServletResponse response ) { List<SessionInfo> sessions; if (!visitedOnly) { @@ -188,9 +223,14 @@ public class SessionController extends PaginationController { return sessions; } + @ApiOperation(value = "Retrieves all public pool sessions for the current user", + nickname = "getMyPublicPoolSessions") + @ApiResponses(value = { + @ApiResponse(code = 204, message = HTML_STATUS_204) + }) @RequestMapping(value = "/publicpool", method = RequestMethod.GET, params = "statusonly=true") public List<SessionInfo> getMyPublicPoolSessions( - final HttpServletResponse response + @ApiParam(value = "http servlet response", required = true) final HttpServletResponse response ) { List<SessionInfo> sessions = sessionService.getMyPublicPoolSessionsInfo(); @@ -202,9 +242,14 @@ public class SessionController extends PaginationController { return sessions; } + @ApiOperation(value = "Retrieves all public pool sessions", + nickname = "getMyPublicPoolSessions") + @ApiResponses(value = { + @ApiResponse(code = 204, message = HTML_STATUS_204) + }) @RequestMapping(value = "/publicpool", method = RequestMethod.GET) public List<SessionInfo> getPublicPoolSessions( - final HttpServletResponse response + @ApiParam(value = "http servlet response", required = true) final HttpServletResponse response ) { List<SessionInfo> sessions = sessionService.getPublicPoolSessionsInfo(); @@ -216,19 +261,26 @@ public class SessionController extends PaginationController { return sessions; } + @ApiOperation(value = "imports a session", + nickname = "importSession") @RequestMapping(value = "/import", method = RequestMethod.POST) public SessionInfo importSession( - @RequestBody final ImportExportSession session, - final HttpServletResponse response + @ApiParam(value = "current session", required = true) @RequestBody final ImportExportSession session, + @ApiParam(value = "http servlet response", required = true) final HttpServletResponse response ) { return sessionService.importSession(session); } + @ApiOperation(value = "Locks or unlocks a Session", + nickname = "lockSession") + @ApiResponses(value = { + @ApiResponse(code = 404, message = HTML_STATUS_404) + }) @RequestMapping(value = "/{sessionkey}/lock", method = RequestMethod.POST) public Session lockSession( - @PathVariable final String sessionkey, - @RequestParam(required = false) final Boolean lock, - final HttpServletResponse response + @ApiParam(value = "session-key from current session", required = true) @PathVariable final String sessionkey, + @ApiParam(value="lock", required=true) @RequestParam(required = false) final Boolean lock, + @ApiParam(value = "http servlet response", required = true) final HttpServletResponse response ) { if (lock != null) { return sessionService.setActive(sessionkey, lock); @@ -237,39 +289,47 @@ public class SessionController extends PaginationController { return null; } + @ApiOperation(value = "retrieves a value for the learning progress", + nickname = "learningProgress") @RequestMapping(value = "/{sessionkey}/learningprogress", method = RequestMethod.GET) public LearningProgressValues learningProgress( - @PathVariable final String sessionkey, - @RequestParam(value = "type", defaultValue = "questions") final String progressType, - @RequestParam(value = "questionVariant", required = false) final String questionVariant, - final HttpServletResponse response + @ApiParam(value = "session-key from current session", required = true) @PathVariable final String sessionkey, + @ApiParam(value = "progress type", required = false) @RequestParam(value = "type", defaultValue = "questions") final String progressType, + @ApiParam(value = "question variant", required = false) @RequestParam(value = "questionVariant", required = false) final String questionVariant, + @ApiParam(value = "http servlet response", required = true) final HttpServletResponse response ) { return sessionService.getLearningProgress(sessionkey, progressType, questionVariant); } + @ApiOperation(value = "retrieves a value for the learning progress for the current user", + nickname = "myLearningProgress") @RequestMapping(value = "/{sessionkey}/mylearningprogress", method = RequestMethod.GET) public LearningProgressValues myLearningProgress( - @PathVariable final String sessionkey, + @ApiParam(value = "session-key from current session", required = true) @PathVariable final String sessionkey, @RequestParam(value = "type", defaultValue = "questions") final String progressType, @RequestParam(value = "questionVariant", required = false) final String questionVariant, - final HttpServletResponse response + @ApiParam(value = "http servlet response", required = true) final HttpServletResponse response ) { return sessionService.getMyLearningProgress(sessionkey, progressType, questionVariant); } + @ApiOperation(value = "retrieves all session features", + nickname = "sessionFeatures") @RequestMapping(value = "/{sessionkey}/features", method = RequestMethod.GET) public SessionFeature sessionFeatures( - @PathVariable final String sessionkey, - final HttpServletResponse response + @ApiParam(value = "session-key from current session", required = true) @PathVariable final String sessionkey, + @ApiParam(value = "http servlet response", required = true) final HttpServletResponse response ) { return sessionService.getSessionFeatures(sessionkey); } @RequestMapping(value = "/{sessionkey}/features", method = RequestMethod.PUT) + @ApiOperation(value = "change all session features", + nickname = "changeSessionFeatures") public SessionFeature changeSessionFeatures( - @PathVariable final String sessionkey, - @RequestBody final SessionFeature features, - final HttpServletResponse response + @ApiParam(value = "session-key from current session", required = true) @PathVariable final String sessionkey, + @ApiParam(value = "session feature", required = true) @RequestBody final SessionFeature features, + @ApiParam(value = "http servlet response", required = true) final HttpServletResponse response ) { return sessionService.changeSessionFeatures(sessionkey, features); } diff --git a/src/main/java/de/thm/arsnova/controller/SocketController.java b/src/main/java/de/thm/arsnova/controller/SocketController.java index 64a58710ff65f74e4a79c52d916c09a672bb9702..e6de3faf268b93db54a2e391234fc47cd1732ec9 100644 --- a/src/main/java/de/thm/arsnova/controller/SocketController.java +++ b/src/main/java/de/thm/arsnova/controller/SocketController.java @@ -32,6 +32,12 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import io.swagger.annotations.ApiResponse; +import io.swagger.annotations.ApiResponses; + import de.thm.arsnova.entities.User; import de.thm.arsnova.services.IUserService; import de.thm.arsnova.services.UserSessionService; @@ -42,6 +48,7 @@ import de.thm.arsnova.socket.ARSnovaSocket; */ @RestController @RequestMapping("/socket") +@Api(value = "/socket", description = "the Socket API") public class SocketController extends AbstractController { @Autowired @@ -55,8 +62,15 @@ public class SocketController extends AbstractController { private static final Logger LOGGER = LoggerFactory.getLogger(SocketController.class); + @ApiOperation(value = "requested to assign Websocket session", + nickname = "authorize") + @ApiResponses(value = { + @ApiResponse(code = 204, message = HTML_STATUS_204), + @ApiResponse(code = 400, message = HTML_STATUS_400), + @ApiResponse(code = 403, message = HTML_STATUS_403) + }) @RequestMapping(method = RequestMethod.POST, value = "/assign") - public void authorize(@RequestBody final Map<String, String> sessionMap, final HttpServletResponse response) { + public void authorize(@ApiParam(value="sessionMap", required=true) @RequestBody final Map<String, String> sessionMap, @ApiParam(value="response", required=true) final HttpServletResponse response) { String socketid = sessionMap.get("session"); if (null == socketid) { LOGGER.debug("Expected property 'session' missing", socketid); @@ -74,6 +88,8 @@ public class SocketController extends AbstractController { response.setStatus(HttpStatus.NO_CONTENT.value()); } + @ApiOperation(value = "retrieves a socket url", + nickname = "getSocketUrl") @RequestMapping(value = "/url", method = RequestMethod.GET) public String getSocketUrl(final HttpServletRequest request) { StringBuilder url = new StringBuilder(); diff --git a/src/main/java/de/thm/arsnova/controller/StatisticsController.java b/src/main/java/de/thm/arsnova/controller/StatisticsController.java index 0acfb9d613a77685849d272adb1c799602f06757..b1216c1056ba60f8fd0df2309fc5f24bec64358f 100644 --- a/src/main/java/de/thm/arsnova/controller/StatisticsController.java +++ b/src/main/java/de/thm/arsnova/controller/StatisticsController.java @@ -22,6 +22,9 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; + import de.thm.arsnova.entities.Statistics; import de.thm.arsnova.services.IStatisticsService; import de.thm.arsnova.web.CacheControl; @@ -31,30 +34,42 @@ import de.thm.arsnova.web.DeprecatedApi; * Allows retrieval of several statistics such as the number of active users. */ @RestController +@Api(value = "/statistics", description = "the Statistic API") public class StatisticsController extends AbstractController { @Autowired private IStatisticsService statisticsService; + @ApiOperation(value = "Retrieves global statistics", + nickname = "getStatistics") @RequestMapping(method = RequestMethod.GET, value = "/statistics") @CacheControl(maxAge = 60, policy = CacheControl.Policy.PUBLIC) public Statistics getStatistics() { return statisticsService.getStatistics(); } + @ApiOperation(value = "Retrieves the amount of all active users", + nickname = "countActiveUsers") @DeprecatedApi + @Deprecated @RequestMapping(method = RequestMethod.GET, value = "/statistics/activeusercount", produces = "text/plain") public String countActiveUsers() { return Integer.toString(statisticsService.getStatistics().getActiveUsers()); } + @ApiOperation(value = "Retrieves the amount of all currently logged in users", + nickname = "countLoggedInUsers") @DeprecatedApi + @Deprecated @RequestMapping(method = RequestMethod.GET, value = "/statistics/loggedinusercount", produces = "text/plain") public String countLoggedInUsers() { return Integer.toString(statisticsService.getStatistics().getLoggedinUsers()); } + @ApiOperation(value = "Retrieves the total amount of all sessions", + nickname = "countSessions") @DeprecatedApi + @Deprecated @RequestMapping(method = RequestMethod.GET, value = "/statistics/sessioncount", produces = "text/plain") public String countSessions() { return Integer.toString(statisticsService.getStatistics().getOpenSessions() diff --git a/src/main/java/de/thm/arsnova/entities/Answer.java b/src/main/java/de/thm/arsnova/entities/Answer.java index 4aa859228e8b3c1ec0351586b0661f7e2c144c08..82ea05d7c7b605a9b7096e59c9cfdaf300fa65e2 100644 --- a/src/main/java/de/thm/arsnova/entities/Answer.java +++ b/src/main/java/de/thm/arsnova/entities/Answer.java @@ -18,12 +18,15 @@ package de.thm.arsnova.entities; import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; /** * Both a regular (single choice, evaluation, etc.) as well as a freetext answer. * * This class has additional fields to transport generated answer statistics. */ +@ApiModel(value = "Answer", description = "the Answer API") public class Answer { private String _id; @@ -50,6 +53,7 @@ public class Answer { this.type = "skill_question_answer"; } + @ApiModelProperty(required = true, value = "used to display _id") public final String get_id() { return _id; } @@ -58,6 +62,7 @@ public class Answer { this._id = _id; } + @ApiModelProperty(required = true, value = "used to display _rev") public final String get_rev() { return _rev; } @@ -66,6 +71,7 @@ public class Answer { this._rev = _rev; } + @ApiModelProperty(required = true, value = "used to display type") public final String getType() { return type; } @@ -74,6 +80,7 @@ public class Answer { this.type = type; } + @ApiModelProperty(required = true, value = "used to display session id") public final String getSessionId() { return sessionId; } @@ -82,6 +89,7 @@ public class Answer { this.sessionId = sessionId; } + @ApiModelProperty(required = true, value = "used to display question id") public final String getQuestionId() { return questionId; } @@ -90,6 +98,7 @@ public class Answer { this.questionId = questionId; } + @ApiModelProperty(required = true, value = "used to display answer text") public final String getAnswerText() { return answerText; } @@ -98,6 +107,7 @@ public class Answer { this.answerText = answerText; } + @ApiModelProperty(required = true, value = "used to display answer subject") public final String getAnswerSubject() { return answerSubject; } @@ -106,6 +116,7 @@ public class Answer { this.answerSubject = answerSubject; } + @ApiModelProperty(required = true, value = "used to displaypi round ") public int getPiRound() { return piRound; } @@ -117,11 +128,13 @@ public class Answer { /* TODO: use JsonViews instead of JsonIgnore when supported by Spring (4.1) * http://wiki.fasterxml.com/JacksonJsonViews * https://jira.spring.io/browse/SPR-7156 */ + @ApiModelProperty(required = true, value = "used to display user") @JsonIgnore public final String getUser() { return user; } + @ApiModelProperty(required = true, value = "used to display answer image") @JsonIgnore public String getAnswerImage() { return answerImage; @@ -131,6 +144,7 @@ public class Answer { this.answerImage = answerImage; } + @ApiModelProperty(required = true, value = "used to display answer thumbnail image") public String getAnswerThumbnailImage() { return answerThumbnailImage; } @@ -143,6 +157,7 @@ public class Answer { this.user = user; } + @ApiModelProperty(required = true, value = "used to display timestamp") public long getTimestamp() { return timestamp; } @@ -151,6 +166,7 @@ public class Answer { this.timestamp = timestamp; } + @ApiModelProperty(required = true, value = "read") public boolean isRead() { return read; } @@ -159,6 +175,7 @@ public class Answer { this.read = read; } + @ApiModelProperty(required = true, value = "used to display answer count") public final int getAnswerCount() { return answerCount; } @@ -167,6 +184,7 @@ public class Answer { this.answerCount = answerCount; } + @ApiModelProperty(required = true, value = "used to display abstention") public boolean isAbstention() { return abstention; } @@ -175,6 +193,7 @@ public class Answer { this.abstention = abstention; } + @ApiModelProperty(required = true, value = "used to display abtention count ") public int getAbstentionCount() { return abstentionCount; } @@ -183,6 +202,7 @@ public class Answer { this.abstentionCount = abstentionCount; } + @ApiModelProperty(required = true, value = "used to display question variant") public String getQuestionVariant() { return questionVariant; } @@ -191,6 +211,7 @@ public class Answer { this.questionVariant = questionVariant; } + @ApiModelProperty(required = true, value = "used to display question value") public int getQuestionValue() { return questionValue; } diff --git a/src/main/java/de/thm/arsnova/entities/InterposedQuestion.java b/src/main/java/de/thm/arsnova/entities/InterposedQuestion.java index 807297687f75ca4a27db0eb14b8db347de43f943..3faf7f5162697316c1a8151b2888bc9bae2bb1a2 100644 --- a/src/main/java/de/thm/arsnova/entities/InterposedQuestion.java +++ b/src/main/java/de/thm/arsnova/entities/InterposedQuestion.java @@ -18,10 +18,13 @@ package de.thm.arsnova.entities; import com.fasterxml.jackson.annotation.JsonIgnore; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; /** * A question the user is asking the teacher. Also known as feedback or audience question. */ +@ApiModel(value = "audiencequestion", description = "the Interposed Question API") public class InterposedQuestion { private String _id; @@ -39,48 +42,63 @@ public class InterposedQuestion { private boolean read; private String creator; + @ApiModelProperty(required = true, value = "used to display question id") public String get_id() { return _id; } public void set_id(String _id) { this._id = _id; } + + @ApiModelProperty(required = true, value = "used to display rev") public String get_rev() { return _rev; } public void set_rev(String _rev) { this._rev = _rev; } + + @ApiModelProperty(required = true, value = "is read") public boolean isRead() { return read; } public void setRead(boolean read) { this.read = read; } + + @ApiModelProperty(required = true, value = "used to display The type") public String getType() { return type; } public void setType(String type) { this.type = type; } + + @ApiModelProperty(required = true, value = "used to display Subject") public String getSubject() { return subject; } public void setSubject(String subject) { this.subject = subject; } + + @ApiModelProperty(required = true, value = "used to display Text") public String getText() { return text; } public void setText(String text) { this.text = text; } + + @ApiModelProperty(required = true, value = "used to display Session id") public String getSessionId() { return sessionId; } public void setSessionId(String sessionId) { this.sessionId = sessionId; } + + @ApiModelProperty(required = true, value = "used to display Timetamp") public long getTimestamp() { return timestamp; } diff --git a/src/main/java/de/thm/arsnova/entities/InterposedReadingCount.java b/src/main/java/de/thm/arsnova/entities/InterposedReadingCount.java index 179cc1b4b6796e0354832e84d5982f91be4a5803..ce1af78977b86dc347fd51ff452b02e3249d6432 100644 --- a/src/main/java/de/thm/arsnova/entities/InterposedReadingCount.java +++ b/src/main/java/de/thm/arsnova/entities/InterposedReadingCount.java @@ -17,9 +17,13 @@ */ package de.thm.arsnova.entities; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + /** * Wrapper class for counting read and unread interposed questions for a session or a single user. */ +@ApiModel(value = "audiencequestion/readcount", description = "the Interposed reading count API") public class InterposedReadingCount { private int read; @@ -35,6 +39,7 @@ public class InterposedReadingCount { this.unread = 0; } + @ApiModelProperty(required = true, value = "used to display read interposed questions") public int getRead() { return read; } @@ -43,6 +48,7 @@ public class InterposedReadingCount { this.read = read; } + @ApiModelProperty(required = true, value = "used to display unread interposed questions") public int getUnread() { return unread; } @@ -51,6 +57,7 @@ public class InterposedReadingCount { this.unread = unread; } + @ApiModelProperty(required = true, value = "used to display Total questions") public int getTotal() { return getRead() + getUnread(); } diff --git a/src/main/java/de/thm/arsnova/entities/LearningProgressOptions.java b/src/main/java/de/thm/arsnova/entities/LearningProgressOptions.java index fcde16cf3731b929d4102ecd74832cbe68b2fc91..4d079d306e4a84abca5d0b90459b46e71b65a13e 100644 --- a/src/main/java/de/thm/arsnova/entities/LearningProgressOptions.java +++ b/src/main/java/de/thm/arsnova/entities/LearningProgressOptions.java @@ -17,9 +17,12 @@ */ package de.thm.arsnova.entities; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; /** * A session's settings regarding the calculation of the learning progress. */ +@ApiModel(value = "learning progress options", description = "the learning progress API") public class LearningProgressOptions { private String type = "questions"; @@ -34,6 +37,7 @@ public class LearningProgressOptions { public LearningProgressOptions() {} + @ApiModelProperty(required = true, value = "used to display the Type") public String getType() { return type; } @@ -42,6 +46,7 @@ public class LearningProgressOptions { this.type = learningProgressType; } + @ApiModelProperty(required = true, value = "used to display question variant") public String getQuestionVariant() { return questionVariant; } diff --git a/src/main/java/de/thm/arsnova/entities/PossibleAnswer.java b/src/main/java/de/thm/arsnova/entities/PossibleAnswer.java index f66842389ae8a3e8383503960f58522a4f531ded..d88132232578e619e8dd38147c0c94ee3f09da71 100644 --- a/src/main/java/de/thm/arsnova/entities/PossibleAnswer.java +++ b/src/main/java/de/thm/arsnova/entities/PossibleAnswer.java @@ -17,9 +17,13 @@ */ package de.thm.arsnova.entities; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + /** * This class represents an answer option of a question. */ +@ApiModel(value = "session/answer", description = "the Possible Answer API") public class PossibleAnswer { private String id; @@ -27,6 +31,7 @@ public class PossibleAnswer { private boolean correct; private int value; + @ApiModelProperty(required = true, value = "used to display id") public String getId() { return this.id; } @@ -35,6 +40,7 @@ public class PossibleAnswer { this.id = id; } + @ApiModelProperty(required = true, value = "used to display text") public String getText() { return text; } @@ -43,6 +49,7 @@ public class PossibleAnswer { this.text = text; } + @ApiModelProperty(required = true, value = "correct") public boolean isCorrect() { return correct; } @@ -51,6 +58,7 @@ public class PossibleAnswer { this.correct = correct; } + @ApiModelProperty(required = true, value = "used to display value") public int getValue() { return value; } diff --git a/src/main/java/de/thm/arsnova/entities/Question.java b/src/main/java/de/thm/arsnova/entities/Question.java index 8b1a8fd3193987625d68454b0eee9fffacaf9af7..ce32f26ec174fcc9608a50d470ab36819d26610b 100644 --- a/src/main/java/de/thm/arsnova/entities/Question.java +++ b/src/main/java/de/thm/arsnova/entities/Question.java @@ -19,10 +19,13 @@ package de.thm.arsnova.entities; import java.util.Date; import java.util.List; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; /** * A question the teacher is asking. */ +@ApiModel(value = "lecturerquestion", description = "the Question API") public class Question { private String type; @@ -80,6 +83,7 @@ public class Question { private String hint; private String solution; + @ApiModelProperty(required = true, value = "used to display type") public final String getType() { return type; } @@ -88,6 +92,7 @@ public class Question { this.type = type; } + @ApiModelProperty(required = true, value = "used to display the question type") public final String getQuestionType() { return questionType; } @@ -96,6 +101,7 @@ public class Question { this.questionType = questionType; } + @ApiModelProperty(required = true, value = "used to display question variant") public final String getQuestionVariant() { return questionVariant; } @@ -104,6 +110,7 @@ public class Question { this.questionVariant = questionVariant; } + @ApiModelProperty(required = true, value = "used to display subject") public final String getSubject() { return subject; } @@ -112,6 +119,7 @@ public class Question { this.subject = subject; } + @ApiModelProperty(required = true, value = "used to display text") public final String getText() { return text; } @@ -120,6 +128,7 @@ public class Question { this.text = text; } + @ApiModelProperty(required = true, value = "active") public final boolean isActive() { return active; } @@ -128,6 +137,7 @@ public class Question { this.active = active; } + @ApiModelProperty(required = true, value = "used to display released for") public final String getReleasedFor() { return releasedFor; } @@ -136,6 +146,7 @@ public class Question { this.releasedFor = releasedFor; } + @ApiModelProperty(required = true, value = "used to display possible answers") public final List<PossibleAnswer> getPossibleAnswers() { return possibleAnswers; } @@ -144,6 +155,7 @@ public class Question { this.possibleAnswers = possibleAnswers; } + @ApiModelProperty(required = true, value = "no correct") public final boolean isNoCorrect() { return noCorrect; } @@ -152,6 +164,7 @@ public class Question { this.noCorrect = noCorrect; } + @ApiModelProperty(required = true, value = "used to display session id") public final String getSessionId() { return sessionId; } @@ -160,6 +173,7 @@ public class Question { this.sessionId = sessionId; } + @ApiModelProperty(required = true, value = "used to display session id") public final String getSession() { return sessionId; } @@ -168,6 +182,7 @@ public class Question { sessionId = session; } + @ApiModelProperty(required = true, value = "used to display session keyword") public final String getSessionKeyword() { return sessionKeyword; } @@ -176,6 +191,7 @@ public class Question { sessionKeyword = keyword; } + @ApiModelProperty(required = true, value = "used to display timestamp") public final long getTimestamp() { return timestamp; } @@ -184,6 +200,7 @@ public class Question { this.timestamp = timestamp; } + @ApiModelProperty(required = true, value = "used to display number") public final int getNumber() { return number; } @@ -192,10 +209,12 @@ public class Question { this.number = number; } + @ApiModelProperty(required = true, value = "used to display duration") public final int getDuration() { return duration; } + @ApiModelProperty(required = true, value = "used to display image Question") public final boolean isImageQuestion() { return imageQuestion; } @@ -208,6 +227,7 @@ public class Question { this.duration = duration; } + @ApiModelProperty(required = true, value = "used to display pi Round") public int getPiRound() { return piRound; } @@ -216,6 +236,7 @@ public class Question { this.piRound = piRound; } + @ApiModelProperty(required = true, value = "used to display pi round end time") public long getPiRoundEndTime() { return piRoundEndTime; } @@ -224,6 +245,7 @@ public class Question { this.piRoundEndTime = piRoundEndTime; } + @ApiModelProperty(required = true, value = "used to display pi round start time") public long getPiRoundStartTime() { return piRoundStartTime; } @@ -232,6 +254,7 @@ public class Question { this.piRoundStartTime = piRoundStartTime; } + @ApiModelProperty(required = true, value = "piRoundActive ") public boolean isPiRoundActive() { return piRoundActive; } @@ -240,6 +263,7 @@ public class Question { this.piRoundActive = piRoundActive; } + @ApiModelProperty(required = true, value = "piRoundFinished ") public boolean isPiRoundFinished() { return piRoundFinished; } @@ -248,6 +272,7 @@ public class Question { this.piRoundFinished = piRoundFinished; } + @ApiModelProperty(required = true, value = "used to display showStatistic") public boolean isShowStatistic() { return showStatistic; } @@ -256,6 +281,7 @@ public class Question { this.showStatistic = showStatistic; } + @ApiModelProperty(required = true, value = "used to display cvIsColored") public boolean getCvIsColored() { return cvIsColored; } @@ -264,6 +290,7 @@ public class Question { this.cvIsColored = cvIsColored; } + @ApiModelProperty(required = true, value = "used to display showAnswer") public boolean isShowAnswer() { return showAnswer; } @@ -272,6 +299,7 @@ public class Question { this.showAnswer = showAnswer; } + @ApiModelProperty(required = true, value = "used to display abstention") public boolean isAbstention() { return abstention; } @@ -280,6 +308,7 @@ public class Question { this.abstention = abstention; } + @ApiModelProperty(required = true, value = "used to display _id") public final String get_id() { return _id; } @@ -288,6 +317,7 @@ public class Question { this._id = _id; } + @ApiModelProperty(required = true, value = "used to display _rev") public final String get_rev() { return _rev; } @@ -296,6 +326,7 @@ public class Question { this._rev = _rev; } + @ApiModelProperty(required = true, value = "used to display image") public String getImage() { return image; } @@ -304,6 +335,7 @@ public class Question { this.image = image; } + @ApiModelProperty(required = true, value = "used to display fcImage") public String getFcImage() { return fcImage; } @@ -312,6 +344,7 @@ public class Question { this.fcImage = fcImage; } + @ApiModelProperty(required = true, value = "used to display gridSize") public int getGridSize() { return gridSize; } @@ -320,6 +353,7 @@ public class Question { this.gridSize = gridSize; } + @ApiModelProperty(required = true, value = "used to display offsetX") public int getOffsetX() { return offsetX; } @@ -328,6 +362,7 @@ public class Question { this.offsetX = offsetX; } + @ApiModelProperty(required = true, value = "used to display offsetY") public int getOffsetY() { return offsetY; } @@ -336,6 +371,7 @@ public class Question { this.offsetY = offsetY; } + @ApiModelProperty(required = true, value = "used to display zoomLvl") public int getZoomLvl() { return zoomLvl; } @@ -344,6 +380,7 @@ public class Question { this.zoomLvl = zoomLvl; } + @ApiModelProperty(required = true, value = "used to display gridOffsetX") public int getGridOffsetX() { return gridOffsetX; } @@ -352,6 +389,7 @@ public class Question { this.gridOffsetX = gridOffsetX; } + @ApiModelProperty(required = true, value = "used to display gridOffsetY") public int getGridOffsetY() { return gridOffsetY; } @@ -360,6 +398,7 @@ public class Question { this.gridOffsetY = gridOffsetY; } + @ApiModelProperty(required = true, value = "used to display grid zoom lvl") public int getGridZoomLvl() { return gridZoomLvl; } @@ -368,6 +407,7 @@ public class Question { this.gridZoomLvl = gridZoomLvl; } + @ApiModelProperty(required = true, value = "used to display grid size X") public int getGridSizeX() { return gridSizeX; } @@ -376,6 +416,7 @@ public class Question { this.gridSizeX = gridSizeX; } + @ApiModelProperty(required = true, value = "used to display grid size Y ") public int getGridSizeY() { return gridSizeY; } @@ -384,6 +425,7 @@ public class Question { this.gridSizeY = gridSizeY; } + @ApiModelProperty(required = true, value = "grid is hidden") public boolean getGridIsHidden() { return gridIsHidden; } @@ -392,6 +434,7 @@ public class Question { this.gridIsHidden = gridIsHidden; } + @ApiModelProperty(required = true, value = "used to display image rotation") public int getImgRotation() { return imgRotation; } @@ -400,6 +443,7 @@ public class Question { this.imgRotation = imgRotation; } + @ApiModelProperty(required = true, value = "used to display toggel fields left") public boolean getToggleFieldsLeft() { return toggleFieldsLeft; } @@ -408,6 +452,7 @@ public class Question { this.toggleFieldsLeft = toggleFieldsLeft; } + @ApiModelProperty(required = true, value = "used to display number clickable fields") public int getNumClickableFields() { return numClickableFields; } @@ -416,6 +461,7 @@ public class Question { this.numClickableFields = numClickableFields; } + @ApiModelProperty(required = true, value = "used to display threshold correct answers") public int getThresholdCorrectAnswers() { return thresholdCorrectAnswers; } @@ -424,6 +470,7 @@ public class Question { this.thresholdCorrectAnswers = thresholdCorrectAnswers; } + @ApiModelProperty(required = true, value = "used to display grid line color") public String getGridLineColor() { return gridLineColor; } @@ -432,6 +479,7 @@ public class Question { this.gridLineColor = gridLineColor; } + @ApiModelProperty(required = true, value = "used to display number of dots") public int getNumberOfDots() { return numberOfDots; } @@ -440,6 +488,7 @@ public class Question { this.numberOfDots = numberOfDots; } + @ApiModelProperty(required = true, value = "used to display the grid type") public String getGridType() { return gridType; } @@ -452,6 +501,7 @@ public class Question { this.scaleFactor = scaleFactor; } + @ApiModelProperty(required = true, value = "used to display scale factor") public String getScaleFactor() { return this.scaleFactor; } @@ -460,10 +510,12 @@ public class Question { this.gridScaleFactor = scaleFactor; } + @ApiModelProperty(required = true, value = "used to display grid scale factor") public String getGridScaleFactor() { return this.gridScaleFactor; } + @ApiModelProperty(required = true, value = "enabled text nswer") public boolean isTextAnswerEnabled() { return this.textAnswerEnabled; } @@ -472,6 +524,7 @@ public class Question { this.textAnswerEnabled = textAnswerEnabled; } + @ApiModelProperty(required = true, value = "voting disabled") public boolean isVotingDisabled() { return votingDisabled; } diff --git a/src/main/java/de/thm/arsnova/entities/Session.java b/src/main/java/de/thm/arsnova/entities/Session.java index 5994c219a56becb9d3775e41b3ed8c551e8f6799..28e286abbd4e45950cdd8de6bec8ab25eb3fd8d4 100644 --- a/src/main/java/de/thm/arsnova/entities/Session.java +++ b/src/main/java/de/thm/arsnova/entities/Session.java @@ -19,12 +19,15 @@ package de.thm.arsnova.entities; import java.io.Serializable; import java.util.List; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import com.fasterxml.jackson.annotation.JsonIgnore; /** * Represents an ARSnova session. */ +@ApiModel(value = "session", description = "the Session API") public class Session implements Serializable { private static final long serialVersionUID = 1L; @@ -93,6 +96,7 @@ public class Session implements Serializable { return copy; } + @ApiModelProperty(required = true, value = "used to display the Type") public String getType() { return type; } @@ -101,6 +105,7 @@ public class Session implements Serializable { this.type = type; } + @ApiModelProperty(required = true, value = "used to display name") public String getName() { return name; } @@ -109,6 +114,7 @@ public class Session implements Serializable { this.name = name; } + @ApiModelProperty(required = true, value = "used to display short name") public String getShortName() { return shortName; } @@ -117,6 +123,7 @@ public class Session implements Serializable { this.shortName = shortName; } + @ApiModelProperty(required = true, value = "used to display keyword") public String getKeyword() { return keyword; } @@ -125,6 +132,7 @@ public class Session implements Serializable { this.keyword = keyword; } + @ApiModelProperty(required = true, value = "used to display creator") public String getCreator() { return creator; } @@ -133,6 +141,7 @@ public class Session implements Serializable { this.creator = creator; } + @ApiModelProperty(required = true, value = "is active") public boolean isActive() { return active; } @@ -141,6 +150,7 @@ public class Session implements Serializable { this.active = active; } + @ApiModelProperty(required = true, value = "used to display the last owner activity") public long getLastOwnerActivity() { return lastOwnerActivity; } @@ -153,6 +163,7 @@ public class Session implements Serializable { _id = id; } + @ApiModelProperty(required = true, value = "used to display id") public String get_id() { return _id; } @@ -161,6 +172,7 @@ public class Session implements Serializable { _rev = rev; } + @ApiModelProperty(required = true, value = "used to display rev") public String get_rev() { return _rev; } @@ -169,6 +181,7 @@ public class Session implements Serializable { _conflicts = conflicts; } + @ApiModelProperty(required = true, value = "used to display conflicts") public List<String> get_conflicts() { return _conflicts; } @@ -177,6 +190,7 @@ public class Session implements Serializable { return user.getUsername().equals(creator); } + @ApiModelProperty(required = true, value = "used to display course type") public String getCourseType() { return courseType; } @@ -185,6 +199,7 @@ public class Session implements Serializable { this.courseType = courseType; } + @ApiModelProperty(required = true, value = "used to display coures id") public String getCourseId() { return courseId; } @@ -198,6 +213,7 @@ public class Session implements Serializable { return getCourseId() != null && !getCourseId().isEmpty(); } + @ApiModelProperty(required = true, value = "used to display the creation time") public long getCreationTime() { return creationTime; } @@ -206,6 +222,7 @@ public class Session implements Serializable { this.creationTime = creationTime; } + @ApiModelProperty(required = true, value = "used to display learnin progress options") public LearningProgressOptions getLearningProgressOptions() { return learningProgressOptions; } @@ -214,6 +231,7 @@ public class Session implements Serializable { this.learningProgressOptions = learningProgressOptions; } + @ApiModelProperty(required = true, value = "used to display features") public SessionFeature getFeatures() { return features; } @@ -222,6 +240,7 @@ public class Session implements Serializable { this.features = features; } + @ApiModelProperty(required = true, value = "used to display author name") public String getPpAuthorName() { return ppAuthorName; } @@ -230,6 +249,7 @@ public class Session implements Serializable { this.ppAuthorName = ppAuthorName; } + @ApiModelProperty(required = true, value = "used to display author mail") public String getPpAuthorMail() { return ppAuthorMail; } @@ -238,6 +258,7 @@ public class Session implements Serializable { this.ppAuthorMail = ppAuthorMail; } + @ApiModelProperty(required = true, value = "used to display university") public String getPpUniversity() { return ppUniversity; } @@ -246,6 +267,7 @@ public class Session implements Serializable { this.ppUniversity = ppUniversity; } + @ApiModelProperty(required = true, value = "used to display logo") public String getPpLogo() { return ppLogo; } @@ -254,6 +276,7 @@ public class Session implements Serializable { this.ppLogo = ppLogo; } + @ApiModelProperty(required = true, value = "used to display subject") public String getPpSubject() { return ppSubject; } @@ -262,6 +285,7 @@ public class Session implements Serializable { this.ppSubject = ppSubject; } + @ApiModelProperty(required = true, value = "used to display license") public String getPpLicense() { return ppLicense; } @@ -270,6 +294,7 @@ public class Session implements Serializable { this.ppLicense = ppLicense; } + @ApiModelProperty(required = true, value = "used to display description") public String getPpDescription() { return ppDescription; } @@ -278,6 +303,7 @@ public class Session implements Serializable { this.ppDescription = ppDescription; } + @ApiModelProperty(required = true, value = "used to display faculty") public String getPpFaculty() { return ppFaculty; } @@ -286,6 +312,7 @@ public class Session implements Serializable { this.ppFaculty = ppFaculty; } + @ApiModelProperty(required = true, value = "used to display level") public String getPpLevel() { return ppLevel; } @@ -294,6 +321,7 @@ public class Session implements Serializable { this.ppLevel = ppLevel; } + @ApiModelProperty(required = true, value = "used to display the session type") public String getSessionType() { return sessionType; } diff --git a/src/main/java/de/thm/arsnova/entities/SessionFeature.java b/src/main/java/de/thm/arsnova/entities/SessionFeature.java index a09cb402d659bdecad172534b14e1711322bfa07..bc564f816622528885be9f4f680cc30d74575f47 100644 --- a/src/main/java/de/thm/arsnova/entities/SessionFeature.java +++ b/src/main/java/de/thm/arsnova/entities/SessionFeature.java @@ -16,10 +16,13 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ package de.thm.arsnova.entities; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; /** * Contains fields that describe which specific feature is activated for a session. */ +@ApiModel(value = "session feature", description = "the Session feature API") public class SessionFeature { private boolean jitt = true; @@ -51,6 +54,7 @@ public class SessionFeature { this.lecture = lecture; } + @ApiModelProperty(required = true, value = "jitt") public boolean isJitt() { return jitt; } @@ -59,6 +63,7 @@ public class SessionFeature { this.jitt = jitt; } + @ApiModelProperty(required = true, value = "feedback") public boolean isFeedback() { return feedback; } @@ -67,6 +72,7 @@ public class SessionFeature { this.feedback = feedback; } + @ApiModelProperty(required = true, value = "interposed") public boolean isInterposed() { return interposed; } @@ -75,6 +81,7 @@ public class SessionFeature { this.interposed = interposed; } + @ApiModelProperty(required = true, value = "pi") public boolean isPi() { return pi; } @@ -83,6 +90,7 @@ public class SessionFeature { this.pi = pi; } + @ApiModelProperty(required = true, value = "learning progress") public boolean isLearningProgress() { return learningProgress; } diff --git a/src/main/java/de/thm/arsnova/entities/SessionInfo.java b/src/main/java/de/thm/arsnova/entities/SessionInfo.java index 9ef283b9fef1168f5ba27f729d00ef3132af8a66..d3cd0d5b14aa59db615f8b0f8ed18c6aa09d5966 100644 --- a/src/main/java/de/thm/arsnova/entities/SessionInfo.java +++ b/src/main/java/de/thm/arsnova/entities/SessionInfo.java @@ -19,11 +19,14 @@ package de.thm.arsnova.entities; import java.util.ArrayList; import java.util.List; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; /** * Summary information of a specific session. For example, this is used to display list entries of 'my sessions' as well * as 'my visited sessions'. */ +@ApiModel(value = "session/import", description = "the session info API") public class SessionInfo { private String name; @@ -64,6 +67,7 @@ public class SessionInfo { return infos; } + @ApiModelProperty(required = true, value = "used to display name") public String getName() { return name; } @@ -72,6 +76,7 @@ public class SessionInfo { this.name = name; } + @ApiModelProperty(required = true, value = "used to display short name") public String getShortName() { return shortName; } @@ -80,6 +85,7 @@ public class SessionInfo { this.shortName = shortName; } + @ApiModelProperty(required = true, value = "used to display keyword") public String getKeyword() { return keyword; } @@ -88,6 +94,7 @@ public class SessionInfo { this.keyword = keyword; } + @ApiModelProperty(required = true, value = "active") public boolean isActive() { return active; } @@ -96,6 +103,7 @@ public class SessionInfo { this.active = active; } + @ApiModelProperty(required = true, value = "used to display the course type") public String getCourseType() { return courseType; } @@ -104,6 +112,7 @@ public class SessionInfo { this.courseType = courseType; } + @ApiModelProperty(required = true, value = "used to display the session type") public String getSessionType() { return sessionType; } @@ -112,6 +121,7 @@ public class SessionInfo { this.sessionType = sessionType; } + @ApiModelProperty(required = true, value = "used to display level") public String getPpLevel() { return ppLevel; } @@ -120,6 +130,7 @@ public class SessionInfo { this.ppLevel = ppLevel; } + @ApiModelProperty(required = true, value = "used to display subject") public String getPpSubject() { return ppSubject; } @@ -128,6 +139,7 @@ public class SessionInfo { this.ppSubject = ppSubject; } + @ApiModelProperty(required = true, value = "used to display questions number") public int getNumQuestions() { return numQuestions; } @@ -136,6 +148,7 @@ public class SessionInfo { this.numQuestions = numQuestions; } + @ApiModelProperty(required = true, value = "used to display answers number") public int getNumAnswers() { return numAnswers; } @@ -144,6 +157,7 @@ public class SessionInfo { this.numAnswers = numAnswers; } + @ApiModelProperty(required = true, value = "used to display interposed number") public int getNumInterposed() { return numInterposed; } @@ -152,6 +166,7 @@ public class SessionInfo { this.numInterposed = numInterposed; } + @ApiModelProperty(required = true, value = "used to display unanswered number") public int getNumUnanswered() { return numUnanswered; } @@ -160,6 +175,7 @@ public class SessionInfo { this.numUnanswered = numUnanswered; } + @ApiModelProperty(required = true, value = "used to display creation time") public long getCreationTime() { return creationTime; } @@ -168,6 +184,7 @@ public class SessionInfo { this.creationTime = creationTime; } + @ApiModelProperty(required = true, value = "used to display unread interposed number") public int getNumUnredInterposed() { return numUnredInterposed; } diff --git a/src/main/java/de/thm/arsnova/entities/Statistics.java b/src/main/java/de/thm/arsnova/entities/Statistics.java index 919e24234e66edd820141109befed3efce615cbf..c64ee252f1d4505e512138e728d34a805669537d 100644 --- a/src/main/java/de/thm/arsnova/entities/Statistics.java +++ b/src/main/java/de/thm/arsnova/entities/Statistics.java @@ -17,9 +17,13 @@ */ package de.thm.arsnova.entities; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + /** * Collection of several statistics about ARSnova. */ +@ApiModel(value = "statistics", description = "the Statistic API") public class Statistics { private int answers; @@ -34,6 +38,7 @@ public class Statistics { private int interposedQuestions; private int conceptQuestions; + @ApiModelProperty(required = true, value = "used to display Answers") public int getAnswers() { return answers; } @@ -42,6 +47,7 @@ public class Statistics { this.answers = answers; } + @ApiModelProperty(required = true, value = "used to display Lecture Questions") public int getLectureQuestions() { return lectureQuestions; } @@ -50,6 +56,7 @@ public class Statistics { this.lectureQuestions = questions; } + @ApiModelProperty(required = true, value = "used to display prepartion Questions") public int getPreparationQuestions() { return preparationQuestions; } @@ -58,10 +65,12 @@ public class Statistics { this.preparationQuestions = questions; } + @ApiModelProperty(required = true, value = "used to display Questions") public int getQuestions() { return getLectureQuestions() + getPreparationQuestions(); } + @ApiModelProperty(required = true, value = "used to display open Sessions") public int getOpenSessions() { return openSessions; } @@ -70,6 +79,7 @@ public class Statistics { this.openSessions = openSessions; } + @ApiModelProperty(required = true, value = "used to display closed Sessions") public int getClosedSessions() { return closedSessions; } @@ -78,10 +88,12 @@ public class Statistics { this.closedSessions = closedSessions; } + @ApiModelProperty(required = true, value = "used to display Sessions") public int getSessions() { return getOpenSessions() + getClosedSessions(); } + @ApiModelProperty(required = true, value = "used to display Active Users") public int getActiveUsers() { return activeUsers; } @@ -90,6 +102,7 @@ public class Statistics { this.activeUsers = activeUsers; } + @ApiModelProperty(required = true, value = "used to display logged in Users") public int getLoggedinUsers() { return loggedinUsers; } @@ -98,6 +111,7 @@ public class Statistics { this.loggedinUsers = loggedinUsers; } + @ApiModelProperty(required = true, value = "used to display interposed Questions") public int getInterposedQuestions() { return interposedQuestions; } @@ -106,6 +120,7 @@ public class Statistics { this.interposedQuestions = interposedQuestions; } + @ApiModelProperty(required = true, value = "used to display creators") public int getCreators() { return creators; } @@ -114,6 +129,7 @@ public class Statistics { this.creators = creators; } + @ApiModelProperty(required = true, value = "used to display concept Questions") public int getConceptQuestions() { return conceptQuestions; } @@ -122,6 +138,7 @@ public class Statistics { this.conceptQuestions = conceptQuestions; } + @ApiModelProperty(required = true, value = "used to display active Students") public int getActiveStudents() { return activeStudents; } diff --git a/src/main/java/de/thm/arsnova/entities/transport/Answer.java b/src/main/java/de/thm/arsnova/entities/transport/Answer.java index dcc884721952a184478406e279105901fad17a6e..1d208f60c10d91f849e13821a264a16906a19ef7 100644 --- a/src/main/java/de/thm/arsnova/entities/transport/Answer.java +++ b/src/main/java/de/thm/arsnova/entities/transport/Answer.java @@ -20,6 +20,8 @@ package de.thm.arsnova.entities.transport; import java.util.Date; import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; import de.thm.arsnova.entities.Question; import de.thm.arsnova.entities.User; @@ -28,6 +30,7 @@ import de.thm.arsnova.entities.User; * A user's answer to a question. */ @JsonInclude(JsonInclude.Include.NON_DEFAULT) +@ApiModel(value = "session/answer", description = "the Answer API") public class Answer { private String answerSubject; @@ -38,6 +41,7 @@ public class Answer { private boolean abstention; + @ApiModelProperty(required = true, value = "used to display text answer") public String getAnswerText() { return answerText; } @@ -46,6 +50,7 @@ public class Answer { this.answerText = answerText; } + @ApiModelProperty(required = true, value = "used to display subject answer") public String getAnswerSubject() { return answerSubject; } @@ -54,6 +59,7 @@ public class Answer { this.answerSubject = answerSubject; } + @ApiModelProperty(required = true, value = "abstention") public boolean isAbstention() { return abstention; } @@ -87,6 +93,7 @@ public class Answer { return theAnswer; } + @ApiModelProperty(required = true, value = "used to display image answer") public String getAnswerImage() { return answerImage; } diff --git a/src/main/java/de/thm/arsnova/entities/transport/ImportExportSession.java b/src/main/java/de/thm/arsnova/entities/transport/ImportExportSession.java index 6ce7606c3936805e48c42fbc2f60b31721382277..a1c63621cdef8413f32acd9f7d6c5a7f15865718 100644 --- a/src/main/java/de/thm/arsnova/entities/transport/ImportExportSession.java +++ b/src/main/java/de/thm/arsnova/entities/transport/ImportExportSession.java @@ -23,10 +23,13 @@ import java.util.List; import de.thm.arsnova.entities.Question; import de.thm.arsnova.entities.Session; import de.thm.arsnova.entities.User; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; /** * This class is used to allow the import and export of a session. */ +@ApiModel(value = "session/import and export", description = "the import export session API") public class ImportExportSession { private ImportExportSesssion session; @@ -35,6 +38,7 @@ public class ImportExportSession { private List<InterposedQuestion> feedbackQuestions; + @ApiModelProperty(required = true, value = "used to display session") public ImportExportSesssion getSession() { return session; } @@ -43,6 +47,7 @@ public class ImportExportSession { this.session = session; } + @ApiModelProperty(required = true, value = "used to display questions") public List<ImportExportQuestion> getQuestions() { return questions; } @@ -51,6 +56,7 @@ public class ImportExportSession { this.questions = questions; } + @ApiModelProperty(required = true, value = "used to display questions feedback") public List<InterposedQuestion> getFeedbackQuestions() { return feedbackQuestions; } @@ -94,6 +100,7 @@ public class ImportExportSession { private List<Answer> answers; + @ApiModelProperty(required = true, value = " used to display answers") public List<Answer> getAnswers() { return answers; } @@ -113,6 +120,7 @@ public class ImportExportSession { private PublicPool publicPool; + @ApiModelProperty(required = true, value = "used to display short name") public String getName() { return name; } @@ -121,6 +129,7 @@ public class ImportExportSession { this.name = name; } + @ApiModelProperty(required = true, value = "used to display short name") public String getShortName() { return shortName; } @@ -129,6 +138,7 @@ public class ImportExportSession { this.shortName = shortName; } + @ApiModelProperty(required = true, value = "active") public boolean isActive() { return active; } @@ -137,6 +147,7 @@ public class ImportExportSession { this.active = active; } + @ApiModelProperty(required = true, value = "used to display public pool") public PublicPool getPublicPool() { return publicPool; } @@ -170,6 +181,7 @@ public class ImportExportSession { private String shortName; + @ApiModelProperty(required = true, value = "used to display author name") public String getPpAuthorName() { return ppAuthorName; } @@ -178,6 +190,7 @@ public class ImportExportSession { this.ppAuthorName = ppAuthorName; } + @ApiModelProperty(required = true, value = "used to display author mail") public String getPpAuthorMail() { return ppAuthorMail; } @@ -186,6 +199,7 @@ public class ImportExportSession { this.ppAuthorMail = ppAuthorMail; } + @ApiModelProperty(required = true, value = "used to display university") public String getPpUniversity() { return ppUniversity; } @@ -194,6 +208,7 @@ public class ImportExportSession { this.ppUniversity = ppUniversity; } + @ApiModelProperty(required = true, value = "used to display logo") public String getPpLogo() { return ppLogo; } @@ -202,6 +217,7 @@ public class ImportExportSession { this.ppLogo = ppLogo; } + @ApiModelProperty(required = true, value = "used to display subject") public String getPpSubject() { return ppSubject; } @@ -210,6 +226,7 @@ public class ImportExportSession { this.ppSubject = ppSubject; } + @ApiModelProperty(required = true, value = "used to display license") public String getPpLicense() { return ppLicense; } @@ -218,6 +235,7 @@ public class ImportExportSession { this.ppLicense = ppLicense; } + @ApiModelProperty(required = true, value = "used to display level") public String getPpLevel() { return ppLevel; } @@ -226,6 +244,7 @@ public class ImportExportSession { this.ppLevel = ppLevel; } + @ApiModelProperty(required = true, value = "used to display description") public String getPpDescription() { return ppDescription; } @@ -234,6 +253,7 @@ public class ImportExportSession { this.ppDescription = ppDescription; } + @ApiModelProperty(required = true, value = "used to display faculty") public String getPpFaculty() { return ppFaculty; } @@ -242,6 +262,7 @@ public class ImportExportSession { this.ppFaculty = ppFaculty; } + @ApiModelProperty(required = true, value = "used to display name") public String getName() { return name; } @@ -250,6 +271,7 @@ public class ImportExportSession { this.name = name; } + @ApiModelProperty(required = true, value = "used to display short name") public String getShortName() { return shortName; } diff --git a/src/main/java/de/thm/arsnova/entities/transport/InterposedQuestion.java b/src/main/java/de/thm/arsnova/entities/transport/InterposedQuestion.java index 7cf960a08c356ee6d68854fc7974fb30553db37f..0e06242348c300f229eadde4509c663e01ba2285 100644 --- a/src/main/java/de/thm/arsnova/entities/transport/InterposedQuestion.java +++ b/src/main/java/de/thm/arsnova/entities/transport/InterposedQuestion.java @@ -19,10 +19,13 @@ package de.thm.arsnova.entities.transport; import java.util.ArrayList; import java.util.List; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; /** * A question a student is asking. Also known as feedback or audience question. */ +@ApiModel(value = "audiencequestion/{questionId}", description = "the Interposed Question API") public class InterposedQuestion { private String id; @@ -49,6 +52,7 @@ public class InterposedQuestion { public InterposedQuestion() {} + @ApiModelProperty(required = true, value = "used to display Id") public String getId() { return id; } @@ -57,6 +61,7 @@ public class InterposedQuestion { this.id = id; } + @ApiModelProperty(required = true, value = "used to display Subject") public String getSubject() { return subject; } @@ -65,6 +70,7 @@ public class InterposedQuestion { this.subject = subject; } + @ApiModelProperty(required = true, value = "used to display Text") public String getText() { return text; } @@ -73,6 +79,7 @@ public class InterposedQuestion { this.text = text; } + @ApiModelProperty(required = true, value = "used to display Timetamp") public long getTimestamp() { return timestamp; } @@ -81,6 +88,7 @@ public class InterposedQuestion { this.timestamp = timestamp; } + @ApiModelProperty(required = true, value = "is read") public boolean isRead() { return read; } diff --git a/src/main/java/de/thm/arsnova/entities/transport/LearningProgressValues.java b/src/main/java/de/thm/arsnova/entities/transport/LearningProgressValues.java index f7245143ddc06a500e1b61ded31d3d2a5755d974..be157e366afcdaa1169b76b63d72a865e91f0a36 100644 --- a/src/main/java/de/thm/arsnova/entities/transport/LearningProgressValues.java +++ b/src/main/java/de/thm/arsnova/entities/transport/LearningProgressValues.java @@ -17,9 +17,13 @@ */ package de.thm.arsnova.entities.transport; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + /** * The calculated learning progress along with meta-data. */ +@ApiModel(value = "session/{sessionkey}/learningprogress", description = "the learning progress API") public class LearningProgressValues { private int courseProgress; @@ -34,6 +38,7 @@ public class LearningProgressValues { private int numUsers; + @ApiModelProperty(required = true, value = "used to display course progress") public int getCourseProgress() { return courseProgress; } @@ -42,6 +47,7 @@ public class LearningProgressValues { this.courseProgress = courseProgress; } + @ApiModelProperty(required = true, value = "used to display my progress") public int getMyProgress() { return myProgress; } @@ -50,6 +56,7 @@ public class LearningProgressValues { this.myProgress = myProgress; } + @ApiModelProperty(required = true, value = "used to display questions number") public int getNumQuestions() { return numQuestions; } @@ -74,6 +81,7 @@ public class LearningProgressValues { this.denominator = denominator; } + @ApiModelProperty(required = true, value = "used to display user number") public int getNumUsers() { return numUsers; } diff --git a/src/main/webapp/WEB-INF/spring/arsnova-servlet.xml b/src/main/webapp/WEB-INF/spring/arsnova-servlet.xml index c9c760e7c93c970c2c33bc6e15566d1762bae87e..5c9e2a49f688740b5c25869976345f991ff9a3d9 100644 --- a/src/main/webapp/WEB-INF/spring/arsnova-servlet.xml +++ b/src/main/webapp/WEB-INF/spring/arsnova-servlet.xml @@ -26,6 +26,9 @@ <aop:aspectj-autoproxy /> + <!-- Enables swgger ui--> + <mvc:resources mapping="swagger.json" location="classpath:/"/> + <bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" p:ignoreUnresolvablePlaceholders="false" p:ignoreResourceNotFound="true"> diff --git a/src/test/java/de/thm/arsnova/services/FeedbackServiceTest.java b/src/test/java/de/thm/arsnova/services/FeedbackServiceTest.java index c09ff45cef73cbbf1be2989759364204d5ba6b78..90428ee02c4932b83f09d6578748e10f40d3c1e9 100644 --- a/src/test/java/de/thm/arsnova/services/FeedbackServiceTest.java +++ b/src/test/java/de/thm/arsnova/services/FeedbackServiceTest.java @@ -29,12 +29,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; import de.thm.arsnova.dao.StubDatabaseDao; import de.thm.arsnova.entities.TestUser; import de.thm.arsnova.exceptions.NoContentException; import de.thm.arsnova.exceptions.NotFoundException; +@WebAppConfiguration @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "file:src/main/webapp/WEB-INF/spring/arsnova-servlet.xml", diff --git a/src/test/java/de/thm/arsnova/services/QuestionServiceTest.java b/src/test/java/de/thm/arsnova/services/QuestionServiceTest.java index a843bd1131a986566f2c0d4f2f342b6f08060cd9..d7d987780343aa6dd7b9a1faae28fd85257cd50b 100644 --- a/src/test/java/de/thm/arsnova/services/QuestionServiceTest.java +++ b/src/test/java/de/thm/arsnova/services/QuestionServiceTest.java @@ -38,12 +38,14 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; +import org.springframework.test.context.web.WebAppConfiguration; import de.thm.arsnova.dao.StubDatabaseDao; import de.thm.arsnova.entities.InterposedQuestion; import de.thm.arsnova.entities.Question; import de.thm.arsnova.exceptions.NotFoundException; +@WebAppConfiguration @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "file:src/main/webapp/WEB-INF/spring/arsnova-servlet.xml", diff --git a/src/test/java/de/thm/arsnova/services/SessionServiceTest.java b/src/test/java/de/thm/arsnova/services/SessionServiceTest.java index daa924e7cae2cb728acc8cb68dca76b2c0a752c6..df5f35c80606e170e487ffdf19ac423f6ec86e1c 100644 --- a/src/test/java/de/thm/arsnova/services/SessionServiceTest.java +++ b/src/test/java/de/thm/arsnova/services/SessionServiceTest.java @@ -46,12 +46,14 @@ import org.springframework.test.context.ActiveProfiles; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.util.ReflectionTestUtils; +import org.springframework.test.context.web.WebAppConfiguration; import de.thm.arsnova.dao.IDatabaseDao; import de.thm.arsnova.dao.StubDatabaseDao; import de.thm.arsnova.entities.Session; import de.thm.arsnova.exceptions.NotFoundException; +@WebAppConfiguration @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = { "file:src/main/webapp/WEB-INF/spring/arsnova-servlet.xml",