diff options
author | Vitaly Takmazov | 2023-01-13 17:38:06 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 18:11:56 +0300 |
commit | 35d25bbc9d261e7b5585d0fd1d398dff3ab4a176 (patch) | |
tree | 68a4d0b0190635615438343f6f6c52cacc213179 /src/main/java/com/juick/www/controllers/Site.java | |
parent | 8b70eded6c9cc3b9cf634356239701fe65779791 (diff) |
Fix OpenAPI generation
* Use HandlerMethodArgumentResolver to pass visitor
* Hide visitor from OpenAPI definitions
* Drop unused AsciiDoc template
Diffstat (limited to 'src/main/java/com/juick/www/controllers/Site.java')
-rw-r--r-- | src/main/java/com/juick/www/controllers/Site.java | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/main/java/com/juick/www/controllers/Site.java b/src/main/java/com/juick/www/controllers/Site.java index 217bb798..f4f8f744 100644 --- a/src/main/java/com/juick/www/controllers/Site.java +++ b/src/main/java/com/juick/www/controllers/Site.java @@ -26,6 +26,7 @@ import com.juick.util.WebUtils; import com.juick.www.WebApp; import com.juick.www.api.activity.model.Context; +import io.swagger.v3.oas.annotations.Parameter; import jakarta.servlet.http.HttpServletRequest; import jakarta.servlet.http.HttpSession; @@ -79,7 +80,7 @@ public class Site { @Value("${telegram_botname:Juick_bot}") private String tgBot; - private void fillUserModel(ModelMap model, User user, User visitor) { + private void fillUserModel(ModelMap model, User user, @Parameter(hidden = true) User visitor) { user.setAvatar(webApp.getAvatarWebPath(user)); model.addAttribute("user", user); model.addAttribute("isSubscribed", userService.isSubscribed(visitor.getUid(), user.getUid())); @@ -98,7 +99,7 @@ public class Site { } @GetMapping("/login") - public String getloginForm(@ModelAttribute User visitor, + public String getloginForm(@Parameter(hidden = true) User visitor, @RequestParam(name = "retpath", required = false, defaultValue = "/") String retPath, HttpSession session, ModelMap model) { @@ -126,7 +127,7 @@ public class Site { } @GetMapping("/") - protected String doGet(@ModelAttribute User visitor, Locale locale, @RequestParam(required = false) String tag, + protected String doGet(@Parameter(hidden = true) User visitor, Locale locale, @RequestParam(required = false) String tag, @RequestParam(name = "show", required = false) String paramShow, @RequestParam(name = "search", required = false) String paramSearch, @RequestParam(name = "before", required = false, defaultValue = "0") Integer paramBefore, @@ -218,7 +219,7 @@ public class Site { } @GetMapping(path = "/{uname}/", headers = "Connection!=Upgrade") - protected String doGetBlog(@ModelAttribute User visitor, @RequestParam(required = false, name = "show") String paramShow, + protected String doGetBlog(@Parameter(hidden = true) User visitor, @RequestParam(required = false, name = "show") String paramShow, @RequestParam(required = false, name = "tag") String paramTagStr, @RequestParam(required = false, name = "search") String paramSearch, @RequestParam(required = false, name = "page", defaultValue = "0") Integer page, @PathVariable String uname, @@ -325,7 +326,7 @@ public class Site { } @GetMapping("/{uname}/tags") - protected String doGetTags(@ModelAttribute User visitor, @PathVariable String uname, ModelMap model) { + protected String doGetTags(@Parameter(hidden = true) User visitor, @PathVariable String uname, ModelMap model) { User user = userService.getUserByName(uname); if (visitor.isBanned()) { throw new HttpNotFoundException(); @@ -345,7 +346,7 @@ public class Site { } @GetMapping("/{uname}/friends") - protected String doGetFriends(@ModelAttribute User visitor, @PathVariable String uname, ModelMap model) { + protected String doGetFriends(@Parameter(hidden = true) User visitor, @PathVariable String uname, ModelMap model) { User user = userService.getUserByName(uname); if (visitor.isBanned()) { throw new HttpNotFoundException(); @@ -361,7 +362,7 @@ public class Site { } @GetMapping("/{uname}/readers") - protected String doGetReaders(@ModelAttribute User visitor, @PathVariable String uname, ModelMap model) { + protected String doGetReaders(@Parameter(hidden = true) User visitor, @PathVariable String uname, ModelMap model) { User user = userService.getUserByName(uname); visitor.setAvatar(webApp.getAvatarWebPath(visitor)); model.addAttribute("title", "Читатели " + user.getName()); @@ -374,7 +375,7 @@ public class Site { } @GetMapping("/{uname}/bl") - protected String doGetBL(@ModelAttribute User visitor, @PathVariable String uname, ModelMap model) { + protected String doGetBL(@Parameter(hidden = true) User visitor, @PathVariable String uname, ModelMap model) { User user = userService.getUserByName(uname); if (visitor.getUid() != user.getUid()) { throw new HttpForbiddenException(); @@ -390,7 +391,7 @@ public class Site { } @GetMapping("/tag/{tagName}") - protected String tagAction(@ModelAttribute User visitor, HttpServletRequest request, @PathVariable String tagName, + protected String tagAction(@Parameter(hidden = true) User visitor, HttpServletRequest request, @PathVariable String tagName, @RequestParam(required = false, defaultValue = "0") int before, ModelMap model) { visitor.setAvatar(webApp.getAvatarWebPath(visitor)); String paramTagStr = StringEscapeUtils.unescapeHtml4(tagName); @@ -453,7 +454,7 @@ public class Site { } @GetMapping("/pm/inbox") - protected String doGetInbox(@ModelAttribute User visitor, ModelMap model) { + protected String doGetInbox(@Parameter(hidden = true) User visitor, ModelMap model) { visitor.setAvatar(webApp.getAvatarWebPath(visitor)); String title = "PM: Inbox"; List<Message> msgs = chatService.getInbox(visitor.getUid()); @@ -467,7 +468,7 @@ public class Site { } @GetMapping("/pm/sent") - protected String doGetSent(@ModelAttribute User visitor, @RequestParam(required = false) String uname, ModelMap model) { + protected String doGetSent(@Parameter(hidden = true) User visitor, @RequestParam(required = false) String uname, ModelMap model) { visitor.setAvatar(webApp.getAvatarWebPath(visitor)); String title = "PM: Sent"; List<Message> msgs = chatService.getOutbox(visitor.getUid()); @@ -492,7 +493,7 @@ public class Site { } @GetMapping(value = "/{uname}/{mid}", produces = { MediaType.TEXT_HTML_VALUE, MediaType.ALL_VALUE }) - protected String threadAction(@ModelAttribute User visitor, ModelMap model, @PathVariable String uname, + protected String threadAction(@Parameter(hidden = true) User visitor, ModelMap model, @PathVariable String uname, @PathVariable int mid, @CookieValue(name = "sape_cookie", required = false, defaultValue = StringUtils.EMPTY) String sapeCookie) { if (!messagesService.canViewThread(mid, visitor.getUid())) { @@ -585,7 +586,7 @@ public class Site { } @GetMapping("/post") - protected String postAction(@ModelAttribute User visitor, @RequestParam(required = false) String body, ModelMap model) { + protected String postAction(@Parameter(hidden = true) User visitor, @RequestParam(required = false) String body, ModelMap model) { fillUserModel(model, visitor, visitor); visitor.setAvatar(webApp.getAvatarWebPath(visitor)); model.addAttribute("title", "Написать"); |