diff options
author | Vitaly Takmazov | 2020-12-07 18:32:27 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2020-12-07 18:33:10 +0300 |
commit | 8e9b670b272b8f030a1035cb7918e9fc0fea89a5 (patch) | |
tree | 79326bdfb119728a3dea37316c555ea2ca638a73 | |
parent | 75b985391dc47d11edc87fee099a85dc30edd386 (diff) |
springfox -> springdoc
-rw-r--r-- | build.gradle | 3 | ||||
-rw-r--r-- | src/main/java/com/juick/www/api/Index.java | 4 | ||||
-rw-r--r-- | src/main/java/com/juick/www/api/Notifications.java | 10 | ||||
-rw-r--r-- | src/main/java/com/juick/www/api/Service.java | 6 | ||||
-rw-r--r-- | src/main/java/com/juick/www/api/webhooks/TelegramWebhook.java | 4 | ||||
-rw-r--r-- | src/test/java/com/juick/config/SwaggerConfiguration.java | 31 | ||||
-rw-r--r-- | src/test/java/com/juick/server/tests/ServerTests.java | 2 |
7 files changed, 27 insertions, 33 deletions
diff --git a/build.gradle b/build.gradle index 24220c62..eb6935cc 100644 --- a/build.gradle +++ b/build.gradle @@ -137,7 +137,7 @@ dependencies { compile 'com.twelvemonkeys.imageio:imageio-jpeg:3.6.1' compile 'org.imgscalr:imgscalr-lib:4.2' - compileOnly 'io.springfox:springfox-core:2.9.2' + implementation "org.springdoc:springdoc-openapi-webmvc-core:1.5.0" compile 'org.apache.commons:commons-email:1.5' compile 'com.github.scribejava:scribejava-apis:7.1.1' @@ -175,7 +175,6 @@ dependencies { testCompile('org.springframework.security:spring-security-test') testCompile("ch.vorburger.mariaDB4j:mariaDB4j:2.4.0") - testCompile 'io.springfox:springfox-swagger2:2.9.2' testCompile 'org.bouncycastle:bcpkix-jdk15on:1.67' } diff --git a/src/main/java/com/juick/www/api/Index.java b/src/main/java/com/juick/www/api/Index.java index 13807aaa..bafb6758 100644 --- a/src/main/java/com/juick/www/api/Index.java +++ b/src/main/java/com/juick/www/api/Index.java @@ -17,13 +17,13 @@ package com.juick.www.api; +import io.swagger.v3.oas.annotations.Hidden; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.servlet.support.ServletUriComponentsBuilder; -import springfox.documentation.annotations.ApiIgnore; import java.net.URI; @@ -33,7 +33,7 @@ import java.net.URI; @RestController public class Index { - @ApiIgnore + @Hidden @RequestMapping(value = { "/api/", "/ws/" }, method = RequestMethod.GET) public ResponseEntity<Void> description() { URI redirectUri = ServletUriComponentsBuilder.fromCurrentRequestUri().path("/swagger-ui.html").build().toUri(); diff --git a/src/main/java/com/juick/www/api/Notifications.java b/src/main/java/com/juick/www/api/Notifications.java index e0326225..76bb4380 100644 --- a/src/main/java/com/juick/www/api/Notifications.java +++ b/src/main/java/com/juick/www/api/Notifications.java @@ -29,6 +29,7 @@ import com.juick.service.SubscriptionService; import com.juick.service.TelegramService; import com.juick.service.UserService; import com.juick.service.security.annotation.Visitor; +import io.swagger.v3.oas.annotations.Hidden; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; @@ -38,7 +39,6 @@ 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 springfox.documentation.annotations.ApiIgnore; import javax.inject.Inject; import java.util.Collections; @@ -82,7 +82,7 @@ public class Notifications { return user; } - @ApiIgnore + @Hidden @RequestMapping(value = "/api/notifications", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<List<User>> doGet( @Visitor User visitor, @@ -117,7 +117,7 @@ public class Notifications { } } - @ApiIgnore + @Hidden @RequestMapping(value = "/api/notifications", method = RequestMethod.DELETE, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Status> doDelete( @Visitor User visitor, @@ -143,7 +143,7 @@ public class Notifications { return ResponseEntity.ok(Status.OK); } - @ApiIgnore + @Hidden @RequestMapping(value = "/api/notifications/delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<Status> doDeleteTokens( @Visitor User visitor, @@ -170,7 +170,7 @@ public class Notifications { return ResponseEntity.ok(Status.OK); } - @ApiIgnore + @Hidden @RequestMapping(value = "/api/notifications", method = RequestMethod.PUT, produces = MediaType.APPLICATION_JSON_VALUE) public Status doPut( @Visitor User visitor, diff --git a/src/main/java/com/juick/www/api/Service.java b/src/main/java/com/juick/www/api/Service.java index 67e2fd01..8b18b125 100644 --- a/src/main/java/com/juick/www/api/Service.java +++ b/src/main/java/com/juick/www/api/Service.java @@ -30,6 +30,7 @@ import com.juick.service.MessagesService; import com.juick.service.UserService; import com.juick.service.component.AccountVerificationEvent; import com.juick.service.security.annotation.Visitor; +import io.swagger.v3.oas.annotations.Hidden; import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.RandomStringUtils; @@ -47,7 +48,6 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.context.request.async.AsyncRequestTimeoutException; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; -import springfox.documentation.annotations.ApiIgnore; import javax.inject.Inject; import javax.mail.Session; @@ -85,7 +85,7 @@ public class Service { private final Session session = Session.getDefaultInstance(new Properties()); - @ApiIgnore + @Hidden @PostMapping("/api/mail") @ResponseStatus(value = HttpStatus.OK) public void processMail(@Visitor User current, InputStream data) throws Exception { @@ -178,7 +178,7 @@ public class Service { throw new HttpForbiddenException(); } } - @ApiIgnore + @Hidden @PostMapping("/api/mail/unsubscribe") @ResponseStatus(value = HttpStatus.OK) public void processMailUnsubscribe(@Visitor User current, InputStream data) throws Exception { diff --git a/src/main/java/com/juick/www/api/webhooks/TelegramWebhook.java b/src/main/java/com/juick/www/api/webhooks/TelegramWebhook.java index 590db060..a3cc2791 100644 --- a/src/main/java/com/juick/www/api/webhooks/TelegramWebhook.java +++ b/src/main/java/com/juick/www/api/webhooks/TelegramWebhook.java @@ -20,6 +20,7 @@ package com.juick.www.api.webhooks; import com.juick.TelegramBotManager; import com.pengrad.telegrambot.BotUtils; import com.pengrad.telegrambot.model.Update; +import io.swagger.v3.oas.annotations.Hidden; import org.apache.commons.io.IOUtils; import org.apache.commons.text.StringEscapeUtils; import org.slf4j.Logger; @@ -30,7 +31,6 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; -import springfox.documentation.annotations.ApiIgnore; import javax.inject.Inject; import java.io.InputStream; @@ -39,7 +39,7 @@ import java.nio.charset.StandardCharsets; /** * Created by vt on 24/11/2016. */ -@ApiIgnore +@Hidden @RestController @ConditionalOnProperty({"telegram_token"}) public class TelegramWebhook { diff --git a/src/test/java/com/juick/config/SwaggerConfiguration.java b/src/test/java/com/juick/config/SwaggerConfiguration.java index f92ef6c0..d3eb7185 100644 --- a/src/test/java/com/juick/config/SwaggerConfiguration.java +++ b/src/test/java/com/juick/config/SwaggerConfiguration.java @@ -17,29 +17,24 @@ package com.juick.config; -import com.google.common.base.Predicates; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.info.License; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -import java.util.Collections; @Configuration -@EnableSwagger2 public class SwaggerConfiguration { @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .host("api.juick.com") - .select() - .apis(Predicates.not(Predicates.or(RequestHandlerSelectors.basePackage("org.springframework.boot"), RequestHandlerSelectors.basePackage("com.juick.server.www")))) - .paths(PathSelectors.any()).build().apiInfo(new ApiInfo("Juick API", "Juick REST API Documentation", - "2.0", "https://juick.com/help/tos", null, - "AGPLv3", "https://www.gnu.org/licenses/agpl-3.0.html", Collections.emptyList())); + public OpenAPI api() { + return new OpenAPI() + .info(new Info() + .title("Juick API") + .version("2.0") + .description("Juick Rest API Documentation") + .termsOfService("https://juick.com/help/tos") + .license(new License() + .name("AGPLv3") + .url("https://www.gnu.org/licenses/agpl-3.0.html"))); } } diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java index f8d3bfdc..33b0f0da 100644 --- a/src/test/java/com/juick/server/tests/ServerTests.java +++ b/src/test/java/com/juick/server/tests/ServerTests.java @@ -1801,7 +1801,7 @@ public class ServerTests { @Test public void swaggerOutput() throws Exception { - MvcResult result = mockMvc.perform(get("/v2/api-docs") + MvcResult result = mockMvc.perform(get("/v3/api-docs") .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andReturn(); |