From 35d25bbc9d261e7b5585d0fd1d398dff3ab4a176 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 13 Jan 2023 17:38:06 +0300 Subject: Fix OpenAPI generation * Use HandlerMethodArgumentResolver to pass visitor * Hide visitor from OpenAPI definitions * Drop unused AsciiDoc template --- src/main/java/com/juick/www/api/Messages.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/main/java/com/juick/www/api/Messages.java') diff --git a/src/main/java/com/juick/www/api/Messages.java b/src/main/java/com/juick/www/api/Messages.java index e23356a4..fb10d7a7 100644 --- a/src/main/java/com/juick/www/api/Messages.java +++ b/src/main/java/com/juick/www/api/Messages.java @@ -30,6 +30,7 @@ import com.juick.service.MessagesService; import com.juick.service.TagService; import com.juick.service.UserService; import com.juick.service.component.SystemEvent; +import io.swagger.v3.oas.annotations.Parameter; import org.apache.commons.io.IOUtils; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.ApplicationEventPublisher; @@ -68,7 +69,7 @@ public class Messages { // TODO: serialize image urls @GetMapping({"/api/home"}) - public List getHome(@ModelAttribute User visitor, + public List getHome(@Parameter(hidden = true) User visitor, @RequestParam(defaultValue = "0") int before_mid) { int vuid = visitor.getUid(); List mids = messagesService.getMyFeed(vuid, before_mid, true); @@ -78,7 +79,7 @@ public class Messages { } @GetMapping("/api/messages") - public List getMessages(@ModelAttribute User visitor, + public List getMessages(@Parameter(hidden = true) User visitor, @RequestParam(required = false) String uname, @RequestParam(name = "before_mid", defaultValue = "0") Integer before, @RequestParam(required = false, defaultValue = "0") Integer daysback, @@ -136,7 +137,7 @@ public class Messages { } @DeleteMapping("/api/messages") - public CommandResult deleteMessage(@ModelAttribute User visitor, @RequestParam int mid, + public CommandResult deleteMessage(@Parameter(hidden = true) User visitor, @RequestParam int mid, @RequestParam(required = false, defaultValue = "0") int rid) { if (rid > 0) { if (messagesService.deleteReply(visitor.getUid(), mid, rid)) { @@ -150,7 +151,7 @@ public class Messages { } @GetMapping("/api/messages/discussions") - public List getDiscussions(@ModelAttribute User visitor, + public List getDiscussions(@Parameter(hidden = true) User visitor, @RequestParam(required = false, defaultValue = "0") Long to) { List msgs = messagesService.getMessages(visitor, messagesService.getDiscussions(visitor.getUid(), to)); msgs.forEach(m -> m.getUser().setAvatar(webApp.getAvatarUrl(m.getUser()))); @@ -158,7 +159,7 @@ public class Messages { } @GetMapping("/api/thread") - public List getThread(@ModelAttribute User visitor, @RequestParam(defaultValue = "0") int mid, + public List getThread(@Parameter(hidden = true) User visitor, @RequestParam(defaultValue = "0") int mid, @RequestParam(defaultValue = "true") boolean showReplies) { Optional message = messagesService.getMessage(mid); if (message.isPresent()) { @@ -188,7 +189,7 @@ public class Messages { } @GetMapping(value = "/api/thread/mark_read/{mid}-{rid}.gif", produces = MediaType.IMAGE_GIF_VALUE) - public byte[] markThreadRead(@ModelAttribute User visitor, @PathVariable int mid, @PathVariable int rid) + public byte[] markThreadRead(@Parameter(hidden = true) User visitor, @PathVariable int mid, @PathVariable int rid) throws IOException { if (!visitor.isAnonymous()) { messagesService.setLastReadComment(visitor, mid, rid); -- cgit v1.2.3