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/api/Mastodon.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/api/Mastodon.java')
-rw-r--r-- | src/main/java/com/juick/www/api/Mastodon.java | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/main/java/com/juick/www/api/Mastodon.java b/src/main/java/com/juick/www/api/Mastodon.java index 5982209e..c595bb19 100644 --- a/src/main/java/com/juick/www/api/Mastodon.java +++ b/src/main/java/com/juick/www/api/Mastodon.java @@ -33,6 +33,7 @@ import com.juick.util.HttpBadRequestException; import com.juick.util.MessageUtils; import com.juick.www.WebApp; import com.juick.www.api.activity.helpers.ProfileUriBuilder; +import io.swagger.v3.oas.annotations.Parameter; import jakarta.validation.Valid; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Value; @@ -166,7 +167,7 @@ public class Mastodon { } @GetMapping("/api/v1/accounts/verify_credentials") - public CredentialAccount account(@ModelAttribute User visitor) { + public CredentialAccount account(@Parameter(hidden = true) User visitor) { return toAccount(visitor); } @@ -220,7 +221,7 @@ public class Mastodon { } @GetMapping("/api/v1/accounts/relationships") - public List<Relationship> relationships(@ModelAttribute User visitor, @RequestParam(value = "id[]") String[] ids) { + public List<Relationship> relationships(@Parameter(hidden = true) User visitor, @RequestParam(value = "id[]") String[] ids) { return Stream.of(ids).map( id -> findRelationships(String.valueOf(visitor.getUid()), id) ).collect(Collectors.toList()); @@ -283,7 +284,7 @@ public class Mastodon { } @GetMapping("/api/v1/conversations") - public List<Conversation> conversations(@ModelAttribute User visitor) { + public List<Conversation> conversations(@Parameter(hidden = true) User visitor) { return chatService.getLastChats(visitor).stream().map( this::toConversation ).collect(Collectors.toList()); @@ -313,7 +314,7 @@ public class Mastodon { } @GetMapping("/api/v1/timelines/{timeline}") - public List<Status> publicTimeline(@ModelAttribute User visitor, + public List<Status> publicTimeline(@Parameter(hidden = true) User visitor, @PathVariable String timeline, @RequestParam(value = "max_id", required = false) String maxId, @RequestParam(value = "only_media", required = false, defaultValue = "false") Boolean media) { @@ -349,7 +350,7 @@ public class Mastodon { } @GetMapping("/api/v1/statuses/{mid}-{rid}/context") - public Context thread(@ModelAttribute User visitor, @PathVariable int mid, @PathVariable int rid) { + public Context thread(@Parameter(hidden = true) User visitor, @PathVariable int mid, @PathVariable int rid) { var thread = messagesService.getReplies(visitor, mid).stream() .filter(m -> m.getRid() > rid) .peek(msg -> msg.getUser().setAvatar(webApp.getAvatarUrl(msg.getUser()))) |