From 4824cd1233aae7d151ef32baaf454e4dcf4e331f Mon Sep 17 00:00:00 2001 From: VampireAchao Date: Sat, 24 Aug 2024 23:28:17 +0800 Subject: [PATCH] [Improve] [ISSUE #5628] Migrate Admin swagger from springfox to springdoc (#5630) * [Improve] Migrate Admin swagger from springfox to springdoc * [Fix] try fix ci * [Fix] fix test case * [Fix] fix test case * [Fix] fix test case --- pom.xml | 2 +- .../impl/PullSwaggerDocServiceImpl.java | 4 +- .../manager/impl/SwaggerDocParser.java | 5 +- .../manager/impl/DocManagerImplTest.java | 2 +- .../manager/impl/SwaggerDocParserTest.java | 239 ++++++------------ .../ApacheDubboClientValidatorTest.java | 2 +- shenyu-examples/pom.xml | 14 +- .../http/config/SwaggerConfiguration.java | 157 ------------ .../Dockerfile | 2 +- .../k8s/script/healthcheck.sh | 0 .../k8s/script/services.list | 0 .../k8s/shenyu-deployment.yml | 14 +- .../k8s/shenyu-examples-http-deployment.yml | 24 +- .../k8s/shenyu-examples-http-service.yml | 14 +- .../k8s/shenyu-service.yml | 10 +- .../pom.xml | 20 +- .../http/ShenyuTestSwaggerApplication.java | 0 .../http/config/HttpServerConfig.java | 0 .../http/config/SwaggerConfiguration.java | 112 ++++++++ .../http/controller/HttpTestController.java | 49 ++-- .../http/controller/OauthController.java | 0 .../http/controller/OrderController.java | 12 +- .../http/controller/RequestController.java | 12 +- .../ShenyuClientPathController.java | 4 +- .../SpringMvcMappingPathController.java | 12 +- .../http/controller/UploadController.java | 13 +- .../shenyu/examples/http/dto/OAuth2DTO.java | 4 +- .../shenyu/examples/http/dto/OrderDTO.java | 9 +- .../shenyu/examples/http/dto/RequestDTO.java | 11 +- .../shenyu/examples/http/dto/UserDTO.java | 14 +- .../examples/http/result/ResultBean.java | 0 .../examples/http/result/TreeResult.java | 11 +- .../http/router/ShenyuTestHttpRouter.java | 0 .../src/main/resources/application.yml | 8 +- shenyu-examples/shenyu-examples-http/pom.xml | 2 +- 35 files changed, 327 insertions(+), 455 deletions(-) delete mode 100644 shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/config/SwaggerConfiguration.java rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/Dockerfile (95%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/k8s/script/healthcheck.sh (100%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/k8s/script/services.list (100%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/k8s/shenyu-deployment.yml (89%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/k8s/shenyu-examples-http-deployment.yml (80%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/k8s/shenyu-examples-http-service.yml (83%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/k8s/shenyu-service.yml (87%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/pom.xml (92%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/java/org/apache/shenyu/examples/http/ShenyuTestSwaggerApplication.java (100%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/java/org/apache/shenyu/examples/http/config/HttpServerConfig.java (100%) create mode 100644 shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/config/SwaggerConfiguration.java rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/java/org/apache/shenyu/examples/http/controller/HttpTestController.java (90%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/java/org/apache/shenyu/examples/http/controller/OauthController.java (100%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/java/org/apache/shenyu/examples/http/controller/OrderController.java (91%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/java/org/apache/shenyu/examples/http/controller/RequestController.java (89%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java (95%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java (85%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/java/org/apache/shenyu/examples/http/controller/UploadController.java (89%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/java/org/apache/shenyu/examples/http/dto/OAuth2DTO.java (92%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/java/org/apache/shenyu/examples/http/dto/OrderDTO.java (88%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/java/org/apache/shenyu/examples/http/dto/RequestDTO.java (88%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/java/org/apache/shenyu/examples/http/dto/UserDTO.java (87%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/java/org/apache/shenyu/examples/http/result/ResultBean.java (100%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/java/org/apache/shenyu/examples/http/result/TreeResult.java (86%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/java/org/apache/shenyu/examples/http/router/ShenyuTestHttpRouter.java (100%) rename shenyu-examples/{shenyu-examples-http-swagger2 => shenyu-examples-http-swagger3}/src/main/resources/application.yml (91%) diff --git a/pom.xml b/pom.xml index 6bc2b419d96a..5f1183c317d5 100644 --- a/pom.xml +++ b/pom.xml @@ -85,7 +85,7 @@ false 1.6.0 - 0.8.7 + 0.8.12 1.6.3 1.6 3.0.1 diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/PullSwaggerDocServiceImpl.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/PullSwaggerDocServiceImpl.java index 9e7a7e5758a1..dec7c930e639 100644 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/PullSwaggerDocServiceImpl.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/PullSwaggerDocServiceImpl.java @@ -56,7 +56,7 @@ public class PullSwaggerDocServiceImpl implements PullSwaggerDocService { private static final HttpUtils HTTP_UTILS = new HttpUtils(); - private static final String SWAGGER_V2_PATH = "/v2/api-docs"; + private static final String SWAGGER_V3_PATH = "/v3/api-docs"; private static final long PULL_MIN_INTERVAL_TIME = 30 * 1000; @@ -181,7 +181,7 @@ private String getSwaggerRequestUrl(final UpstreamInstance instance) { uriComponentsBuilder.host(instance.getIp()); uriComponentsBuilder.port(instance.getPort()); uriComponentsBuilder.path(Optional.ofNullable(instance.getContextPath()).orElse("")); - uriComponentsBuilder.path(SWAGGER_V2_PATH); + uriComponentsBuilder.path(SWAGGER_V3_PATH); return uriComponentsBuilder.build().toUriString(); } diff --git a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParser.java b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParser.java index f7afed202ec5..fc8bbf97d0c3 100755 --- a/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParser.java +++ b/shenyu-admin/src/main/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParser.java @@ -247,9 +247,8 @@ protected List buildResponseParameterList(final JsonObject docInfo } protected List buildDocParameters(final String ref, final JsonObject docRoot, final boolean doSubRef) { - JsonObject responseObject = docRoot.getAsJsonObject("definitions").getAsJsonObject(ref); - String className = responseObject.get("title").getAsString(); - JsonObject extProperties = docRoot.getAsJsonObject(className); + JsonObject responseObject = docRoot.getAsJsonObject("components").getAsJsonObject("schemas").getAsJsonObject(ref); + JsonObject extProperties = responseObject.getAsJsonObject("properties"); JsonArray requiredProperties = responseObject.getAsJsonArray("required"); List requiredFieldList = this.jsonArrayToStringList(requiredProperties); JsonObject properties = responseObject.getAsJsonObject("properties"); diff --git a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/manager/impl/DocManagerImplTest.java b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/manager/impl/DocManagerImplTest.java index 733191716a42..60dfdd7dfc32 100644 --- a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/manager/impl/DocManagerImplTest.java +++ b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/manager/impl/DocManagerImplTest.java @@ -48,7 +48,7 @@ public void testAddDocInfo() { instance.setContextPath("/testClusterName"); AtomicBoolean atomicBoolean = new AtomicBoolean(false); docManager.addDocInfo(instance, SwaggerDocParserTest.DOC_INFO_JSON, "", docInfo -> { - Assertions.assertEquals(docInfo.getTitle(), "shenyu-examples-http-swagger2 API"); + Assertions.assertEquals(docInfo.getTitle(), "shenyu-examples-http-swagger3 API"); Assertions.assertEquals(docInfo.getClusterName(), "testClusterName"); atomicBoolean.set(true); }); diff --git a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParserTest.java b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParserTest.java index 323c96757f29..7a88703962b7 100644 --- a/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParserTest.java +++ b/shenyu-admin/src/test/java/org/apache/shenyu/admin/service/manager/impl/SwaggerDocParserTest.java @@ -32,165 +32,86 @@ public class SwaggerDocParserTest { public static final String DOC_INFO_JSON = "{\n" - + " \"swagger\":\"2.0\",\n" - + " \"info\":{\n" - + " \"description\":\"shenyu-examples-http-swagger2 API\",\n" - + " \"version\":\"2.3.0\",\n" - + " \"title\":\"shenyu-examples-http-swagger2 API\",\n" - + " \"contact\":{\n" - + " \"name\":\"ShenYu\",\n" - + " \"url\":\"https://github.com/apache/shenyu\",\n" - + " \"email\":\"dev@shenyu.apache.org\"\n" - + " }\n" - + " },\n" - + " \"host\":\"127.0.0.1:8190\",\n" - + " \"basePath\":\"/\",\n" - + " \"tags\":[\n" - + " {\n" - + " \"name\":\"Order API\",\n" - + " \"description\":\"Order Controller\"\n" - + " },\n" - + " {\n" - + " \"name\":\"http-test-controller\",\n" - + " \"description\":\"Http Test Controller\"\n" - + " }\n" - + " ],\n" - + " \"paths\":{\n" - + " \"/order/path/{id}/{name}\":{\n" - + " \"get\":{\n" - + " \"tags\":[\n" - + " \"Order API\"\n" - + " ],\n" - + " \"summary\":\"getPathVariable\",\n" - + " \"description\":\"get path variable.\",\n" - + " \"operationId\":\"getPathVariableUsingGET_1\",\n" - + " \"produces\":[\n" - + " \"*/*\"\n" - + " ],\n" - + " \"parameters\":[\n" - + " {\n" - + " \"name\":\"X-Access-Token\",\n" - + " \"in\":\"header\",\n" - + " \"description\":\"user auth\",\n" - + " \"required\":false,\n" - + " \"type\":\"string\"\n" - + " },\n" - + " {\n" - + " \"name\":\"id\",\n" - + " \"in\":\"path\",\n" - + " \"description\":\"id\",\n" - + " \"required\":true,\n" - + " \"type\":\"string\"\n" - + " },\n" - + " {\n" - + " \"name\":\"name\",\n" - + " \"in\":\"path\",\n" - + " \"description\":\"name\",\n" - + " \"required\":true,\n" - + " \"type\":\"string\"\n" - + " }\n" - + " ],\n" - + " \"responses\":{\n" - + " \"200\":{\n" - + " \"description\":\"OK\",\n" - + " \"schema\":{\n" - + " \"$ref\":\"#/definitions/OrderDTO\"\n" - + " }\n" - + " },\n" - + " \"deprecated\":false\n" - + " }\n" - + " }\n" - + " },\n" - + " \"/test/payment\":{\n" - + " \"post\":{\n" - + " \"tags\":[\n" - + " \"http-test-controller\"\n" - + " ],\n" - + " \"summary\":\"payment\",\n" - + " \"description\":\"The user pays the order.\",\n" - + " \"operationId\":\"postUsingPOST\",\n" - + " \"consumes\":[\n" - + " \"application/json\"\n" - + " ],\n" - + " \"produces\":[\n" - + " \"*/*\"\n" - + " ],\n" - + " \"parameters\":[\n" - + " {\n" - + " \"name\":\"X-Access-Token\",\n" - + " \"in\":\"header\",\n" - + " \"description\":\"user auth\",\n" - + " \"required\":false,\n" - + " \"type\":\"string\"\n" - + " },\n" - + " {\n" - + " \"in\":\"body\",\n" - + " \"name\":\"userDTO\",\n" - + " \"description\":\"userDTO\",\n" - + " \"required\":true,\n" - + " \"schema\":{\n" - + " \"$ref\":\"#/definitions/UserDTO\"\n" - + " }\n" - + " }\n" - + " ],\n" - + " \"responses\":{\n" - + " \"200\":{\n" - + " \"description\":\"OK\",\n" - + " \"schema\":{\n" - + " \"$ref\":\"#/definitions/UserDTO\"\n" - + " }\n" - + " }\n" - + " },\n" - + " \"deprecated\":false\n" - + " }\n" - + " }\n" - + " },\n" - + " \"definitions\":{\n" - + " \"Mono«string»\":{\n" - + " \"type\":\"object\",\n" - + " \"title\":\"Mono«string»\"\n" - + " },\n" - + " \"OrderDTO\":{\n" - + " \"type\":\"object\",\n" - + " \"required\":[\n" - + " \"id\",\n" - + " \"name\"\n" - + " ],\n" - + " \"properties\":{\n" - + " \"id\":{\n" - + " \"type\":\"string\",\n" - + " \"example\":100000,\n" - + " \"description\":\"id\"\n" - + " },\n" - + " \"name\":{\n" - + " \"type\":\"string\",\n" - + " \"example\":\"jack\",\n" - + " \"description\":\"name\"\n" - + " }\n" - + " },\n" - + " \"title\":\"OrderDTO\"\n" - + " },\n" - + " \"UserDTO\":{\n" - + " \"type\":\"object\",\n" - + " \"required\":[\n" - + " \"userId\"\n" - + " ],\n" - + " \"properties\":{\n" - + " \"userId\":{\n" - + " \"type\":\"string\",\n" - + " \"example\":100000,\n" - + " \"description\":\"user id\"\n" - + " },\n" - + " \"userName\":{\n" - + " \"type\":\"string\",\n" - + " \"example\":\"shenyu\",\n" - + " \"description\":\"user name\"\n" - + " }\n" - + " },\n" - + " \"title\":\"UserDTO\"\n" - + " }\n" - + " }\n" - + "}"; + + " \"openapi\": \"3.0.1\",\n" + + " \"info\": {\n" + + " \"title\": \"shenyu-examples-http-swagger3 API\",\n" + + " \"description\": \"shenyu-examples-http-swagger3 API\",\n" + + " \"version\": \"3.0.1\",\n" + + " \"contact\": {\n" + + " \"name\": \"ShenYu\",\n" + + " \"url\": \"https://github.com/apache/shenyu\",\n" + + " \"email\": \"dev@shenyu.apache.org\"\n" + + " }\n" + + " },\n" + + " \"servers\": [\n" + + " {\n" + + " \"url\": \"http://127.0.0.1:8190\",\n" + + " \"description\": \"Local server\"\n" + + " }\n" + + " ],\n" + + " \"tags\": [\n" + + " {\n" + + " \"name\": \"Order API\",\n" + + " \"description\": \"Order Controller\"\n" + + " }\n" + + " ],\n" + + " \"paths\": {\n" + + " \"/order/path/{id}/{name}\": {\n" + + " \"get\": {\n" + + " \"tags\": [\"Order API\"],\n" + + " \"summary\": \"Get path variable\",\n" + + " \"parameters\": [\n" + + " {\n" + + " \"name\": \"id\",\n" + + " \"in\": \"path\",\n" + + " \"required\": true,\n" + + " \"schema\": {\n" + + " \"type\": \"string\"\n" + + " }\n" + + " },\n" + + " {\n" + + " \"name\": \"name\",\n" + + " \"in\": \"path\",\n" + + " \"required\": true,\n" + + " \"schema\": {\n" + + " \"type\": \"string\"\n" + + " }\n" + + " }\n" + + " ],\n" + + " \"responses\": {\n" + + " \"200\": {\n" + + " \"description\": \"Successful response\",\n" + + " \"content\": {\n" + + " \"application/json\": {\n" + + " \"schema\": {\n" + + " \"$ref\": \"#/components/schemas/OrderDTO\"\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + " },\n" + + " \"components\": {\n" + + " \"schemas\": {\n" + + " \"OrderDTO\": {\n" + + " \"type\": \"object\",\n" + + " \"required\": [\"id\", \"name\"],\n" + + " \"properties\": {\n" + + " \"id\": {\n" + + " \"type\": \"string\",\n" + + " \"example\": \"100000\"\n" + + " },\n" + + " \"name\": {\n" + + " \"type\": \"string\",\n" + + " \"example\": \"jack\"\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + " }\n" + + "}\n"; @InjectMocks private SwaggerDocParser swaggerDocParser; diff --git a/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidatorTest.java b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidatorTest.java index 73573674ca00..626d21ab53b7 100644 --- a/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidatorTest.java +++ b/shenyu-client/shenyu-client-dubbo/shenyu-client-apache-dubbo/src/test/java/org/apache/shenyu/client/apache/dubbo/validation/ApacheDubboClientValidatorTest.java @@ -91,7 +91,7 @@ public void testValidateWhenMeetsConstraintThenValidationFailed() throws Excepti .validate( "methodTwo", new Class[]{MockValidationParameter.class}, - new Object[]{new MockValidationParameter("NotBeNull")})); + new Object[]{new MockValidationParameter()})); } @Test diff --git a/shenyu-examples/pom.xml b/shenyu-examples/pom.xml index 848aab23c699..21907949281b 100644 --- a/shenyu-examples/pom.xml +++ b/shenyu-examples/pom.xml @@ -38,13 +38,13 @@ 2.5 0.40.1 3.1.0 - 2.9.2 + 2.6.0 shenyu-examples-common shenyu-examples-http - shenyu-examples-http-swagger2 + shenyu-examples-http-swagger3 shenyu-examples-https shenyu-examples-dubbo shenyu-examples-springcloud @@ -63,14 +63,8 @@ - io.springfox - springfox-swagger2 - ${swagger.version} - - - - io.springfox - springfox-swagger-ui + org.springdoc + springdoc-openapi-starter-webmvc-ui ${swagger.version} diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/config/SwaggerConfiguration.java b/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/config/SwaggerConfiguration.java deleted file mode 100644 index 1f62fc340069..000000000000 --- a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/config/SwaggerConfiguration.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.apache.shenyu.examples.http.config; - -import io.swagger.annotations.ApiOperation; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; -import java.util.stream.Collectors; -import org.apache.shenyu.common.constant.Constants; -import org.apache.shenyu.common.utils.VersionUtils; -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.util.ReflectionUtils; -import org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping; -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.ParameterBuilder; -import springfox.documentation.builders.PathSelectors; -import springfox.documentation.builders.RequestHandlerSelectors; -import springfox.documentation.schema.ModelRef; -import springfox.documentation.service.ApiInfo; -import springfox.documentation.service.Contact; -import springfox.documentation.service.Parameter; -import springfox.documentation.spi.DocumentationType; -import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.spring.web.plugins.WebMvcRequestHandlerProvider; -import springfox.documentation.swagger2.annotations.EnableSwagger2; - -/** - * Configuration class for Swagger API document. - */ -@Configuration -@EnableSwagger2 -public class SwaggerConfiguration { - - private static final String DEFAULT_SWAGGER_API_VERSION = "2.3.0"; - - private static final String TITLE = "shenyu-examples-http-swagger2 API"; - - private static final String DESCRIPTION = "shenyu-examples-http-swagger2 API"; - - private static final String CONTACT_NAME = "ShenYu"; - - private static final String CONTACT_URL = "https://github.com/apache/shenyu"; - - private static final String CONTACT_EMAIL = "dev@shenyu.apache.org"; - - private static final String TOKEN_DESCRIPTION = "user auth"; - - private static final String TOKEN_MODEL_REF_TYPE = "string"; - - private static final String TOKEN_PARAMETER_TYPE = "header"; - - private static boolean enable = true; - - public SwaggerConfiguration() { - } - - /** - * Configure The Docket with Swagger. - * - * @return Docket {@linkplain Docket} - */ - @Bean - public Docket createRestApi() { - ParameterBuilder commonParam = new ParameterBuilder(); - - // X-Access-Token - List pars = new ArrayList<>(); - commonParam.name(Constants.X_ACCESS_TOKEN) - .description(TOKEN_DESCRIPTION) - .modelRef(new ModelRef(TOKEN_MODEL_REF_TYPE)) - .parameterType(TOKEN_PARAMETER_TYPE) - .required(false); - pars.add(commonParam.build()); - - return new Docket(DocumentationType.SWAGGER_2) - .apiInfo(this.apiInfo()) - .enable(enable) - .globalOperationParameters(pars) - .select() - .apis(RequestHandlerSelectors.basePackage("org.apache.shenyu.examples.http.controller")) - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - .paths(PathSelectors.any()) - .build(); - } - - /** - * use bean to be compatible with springboot 2.6.8. - * - * @return BeanPostProcessor - */ - @Bean - public BeanPostProcessor springfoxBeanHandler() { - return new BeanPostProcessor() { - @Override - public Object postProcessAfterInitialization(final Object bean, - final String beanName) throws BeansException { - if (bean instanceof WebMvcRequestHandlerProvider) { - customizeSpringfoxHandlerMappings(getHandlerMappings(bean)); - } - return bean; - } - - private void customizeSpringfoxHandlerMappings( - final List mappings) { - List copy = mappings.stream() - .filter(mapping -> mapping.getPatternParser() == null) - .collect(Collectors.toList()); - mappings.clear(); - mappings.addAll(copy); - } - - @SuppressWarnings("unchecked") - private List getHandlerMappings(final Object bean) { - try { - Field field = ReflectionUtils.findField(bean.getClass(), "handlerMappings"); - field.setAccessible(true); - return (List) field.get(bean); - } catch (IllegalArgumentException | IllegalAccessException e) { - throw new IllegalStateException(e); - } - } - }; - } - - /** - * Fetch version information from pom.xml and set title, version, description, - * contact for Swagger API document. - * - * @return Api info - */ - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title(TITLE).description(DESCRIPTION) - .version(VersionUtils.getVersion(getClass(), DEFAULT_SWAGGER_API_VERSION)) - .contact(new Contact(CONTACT_NAME, CONTACT_URL, CONTACT_EMAIL)) - .build(); - } -} diff --git a/shenyu-examples/shenyu-examples-http-swagger2/Dockerfile b/shenyu-examples/shenyu-examples-http-swagger3/Dockerfile similarity index 95% rename from shenyu-examples/shenyu-examples-http-swagger2/Dockerfile rename to shenyu-examples/shenyu-examples-http-swagger3/Dockerfile index db8406672e6f..6c1108c95acf 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/Dockerfile +++ b/shenyu-examples/shenyu-examples-http-swagger3/Dockerfile @@ -16,7 +16,7 @@ FROM eclipse-temurin:17-centos7 -ENV APP_NAME shenyu-examples-http-swagger2 +ENV APP_NAME shenyu-examples-http-swagger3 ENV LOCAL_PATH /opt/${APP_NAME} RUN mkdir -p ${LOCAL_PATH} diff --git a/shenyu-examples/shenyu-examples-http-swagger2/k8s/script/healthcheck.sh b/shenyu-examples/shenyu-examples-http-swagger3/k8s/script/healthcheck.sh similarity index 100% rename from shenyu-examples/shenyu-examples-http-swagger2/k8s/script/healthcheck.sh rename to shenyu-examples/shenyu-examples-http-swagger3/k8s/script/healthcheck.sh diff --git a/shenyu-examples/shenyu-examples-http-swagger2/k8s/script/services.list b/shenyu-examples/shenyu-examples-http-swagger3/k8s/script/services.list similarity index 100% rename from shenyu-examples/shenyu-examples-http-swagger2/k8s/script/services.list rename to shenyu-examples/shenyu-examples-http-swagger3/k8s/script/services.list diff --git a/shenyu-examples/shenyu-examples-http-swagger2/k8s/shenyu-deployment.yml b/shenyu-examples/shenyu-examples-http-swagger3/k8s/shenyu-deployment.yml similarity index 89% rename from shenyu-examples/shenyu-examples-http-swagger2/k8s/shenyu-deployment.yml rename to shenyu-examples/shenyu-examples-http-swagger3/k8s/shenyu-deployment.yml index 415ca0be6e45..4fdef34672f7 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/k8s/shenyu-deployment.yml +++ b/shenyu-examples/shenyu-examples-http-swagger3/k8s/shenyu-deployment.yml @@ -20,18 +20,18 @@ metadata: name: shenyu-admin labels: app: shenyu-admin - all: shenyu-examples-http-swagger2 + all: shenyu-examples-http-swagger3 spec: replicas: 1 selector: matchLabels: app: shenyu-admin - all: shenyu-examples-http-swagger2 + all: shenyu-examples-http-swagger3 template: metadata: labels: app: shenyu-admin - all: shenyu-examples-http-swagger2 + all: shenyu-examples-http-swagger3 spec: containers: - name: shenyu-admin @@ -55,18 +55,18 @@ metadata: name: shenyu-bootstrap labels: app: shenyu-bootstrap - all: shenyu-examples-http-swagger2 + all: shenyu-examples-http-swagger3 spec: replicas: 1 selector: matchLabels: app: shenyu-bootstrap - all: shenyu-examples-http-swagger2 + all: shenyu-examples-http-swagger3 template: metadata: labels: app: shenyu-bootstrap - all: shenyu-examples-http-swagger2 + all: shenyu-examples-http-swagger3 spec: containers: - name: shenyu-bootstrap @@ -79,4 +79,4 @@ spec: - containerPort: 9195 imagePullPolicy: IfNotPresent restartPolicy: Always -status: {} \ No newline at end of file +status: {} diff --git a/shenyu-examples/shenyu-examples-http-swagger2/k8s/shenyu-examples-http-deployment.yml b/shenyu-examples/shenyu-examples-http-swagger3/k8s/shenyu-examples-http-deployment.yml similarity index 80% rename from shenyu-examples/shenyu-examples-http-swagger2/k8s/shenyu-examples-http-deployment.yml rename to shenyu-examples/shenyu-examples-http-swagger3/k8s/shenyu-examples-http-deployment.yml index 597fdead301f..602217e46592 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/k8s/shenyu-examples-http-deployment.yml +++ b/shenyu-examples/shenyu-examples-http-swagger3/k8s/shenyu-examples-http-deployment.yml @@ -17,26 +17,26 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: shenyu-examples-http-swagger2-deployment + name: shenyu-examples-http-swagger3-deployment labels: - app: shenyu-examples-http-swagger2 - all: shenyu-examples-http-swagger2 + app: shenyu-examples-http-swagger3 + all: shenyu-examples-http-swagger3 spec: replicas: 1 selector: matchLabels: - app: shenyu-examples-http-swagger2 - all: shenyu-examples-http-swagger2 + app: shenyu-examples-http-swagger3 + all: shenyu-examples-http-swagger3 strategy: {} template: metadata: labels: - app: shenyu-examples-http-swagger2 - all: shenyu-examples-http-swagger2 + app: shenyu-examples-http-swagger3 + all: shenyu-examples-http-swagger3 spec: containers: - - image: shenyu-examples-http-swagger2 - name: shenyu-examples-http-swagger2 + - image: shenyu-examples-http-swagger3 + name: shenyu-examples-http-swagger3 livenessProbe: exec: command: @@ -59,20 +59,20 @@ kind: Deployment metadata: labels: app: shenyu-zk - all: shenyu-examples-http-swagger2 + all: shenyu-examples-http-swagger3 name: shenyu-zk spec: replicas: 1 selector: matchLabels: app: shenyu-zk - all: shenyu-examples-http-swagger2 + all: shenyu-examples-http-swagger3 strategy: {} template: metadata: labels: app: shenyu-zk - all: shenyu-examples-http-swagger2 + all: shenyu-examples-http-swagger3 spec: containers: - image: zookeeper:3.5 diff --git a/shenyu-examples/shenyu-examples-http-swagger2/k8s/shenyu-examples-http-service.yml b/shenyu-examples/shenyu-examples-http-swagger3/k8s/shenyu-examples-http-service.yml similarity index 83% rename from shenyu-examples/shenyu-examples-http-swagger2/k8s/shenyu-examples-http-service.yml rename to shenyu-examples/shenyu-examples-http-swagger3/k8s/shenyu-examples-http-service.yml index d2166b1ab6df..c1d08e1be149 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/k8s/shenyu-examples-http-service.yml +++ b/shenyu-examples/shenyu-examples-http-swagger3/k8s/shenyu-examples-http-service.yml @@ -17,14 +17,14 @@ apiVersion: v1 kind: Service metadata: - name: shenyu-examples-http-swagger2-service + name: shenyu-examples-http-swagger3-service labels: - app: shenyu-examples-http-swagger2 - all: shenyu-examples-http-swagger2 + app: shenyu-examples-http-swagger3 + all: shenyu-examples-http-swagger3 spec: selector: - app: shenyu-examples-http-swagger2 - all: shenyu-examples-http-swagger2 + app: shenyu-examples-http-swagger3 + all: shenyu-examples-http-swagger3 type: NodePort ports: - name: "8190" @@ -41,12 +41,12 @@ metadata: name: shenyu-zk labels: app: shenyu-zk - all: shenyu-examples-http-swagger2 + all: shenyu-examples-http-swagger3 spec: type: NodePort selector: app: shenyu-zk - all: shenyu-examples-http-swagger2 + all: shenyu-examples-http-swagger3 ports: - name: "client" port: 2181 diff --git a/shenyu-examples/shenyu-examples-http-swagger2/k8s/shenyu-service.yml b/shenyu-examples/shenyu-examples-http-swagger3/k8s/shenyu-service.yml similarity index 87% rename from shenyu-examples/shenyu-examples-http-swagger2/k8s/shenyu-service.yml rename to shenyu-examples/shenyu-examples-http-swagger3/k8s/shenyu-service.yml index 63e38f8f3554..5da856eb43c5 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/k8s/shenyu-service.yml +++ b/shenyu-examples/shenyu-examples-http-swagger3/k8s/shenyu-service.yml @@ -20,12 +20,12 @@ metadata: name: shenyu-admin labels: app: shenyu-admin - all: shenyu-examples-http-swagger2 + all: shenyu-examples-http-swagger3 spec: type: NodePort selector: app: shenyu-admin - all: shenyu-examples-http-swagger2 + all: shenyu-examples-http-swagger3 ports: - name: "9095" port: 9095 @@ -39,14 +39,14 @@ metadata: name: shenyu-bootstrap labels: app: shenyu-bootstrap - all: shenyu-examples-http-swagger2 + all: shenyu-examples-http-swagger3 spec: type: NodePort selector: app: shenyu-bootstrap - all: shenyu-examples-http-swagger2 + all: shenyu-examples-http-swagger3 ports: - name: "9195" port: 9195 targetPort: 9195 - nodePort: 31195 \ No newline at end of file + nodePort: 31195 diff --git a/shenyu-examples/shenyu-examples-http-swagger2/pom.xml b/shenyu-examples/shenyu-examples-http-swagger3/pom.xml similarity index 92% rename from shenyu-examples/shenyu-examples-http-swagger2/pom.xml rename to shenyu-examples/shenyu-examples-http-swagger3/pom.xml index 8fb3dacca71a..4d4313e81ea0 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/pom.xml +++ b/shenyu-examples/shenyu-examples-http-swagger3/pom.xml @@ -25,10 +25,10 @@ 2.7.0-SNAPSHOT 4.0.0 - shenyu-examples-http-swagger2 + shenyu-examples-http-swagger3 - 3.3.2 + 3.12.0 21.0 4.4 @@ -110,17 +110,13 @@ - io.springfox - springfox-swagger2 - - - io.springfox - springfox-swagger-ui + org.springdoc + springdoc-openapi-starter-webmvc-ui - shenyu-examples-http-swagger2 + shenyu-examples-http-swagger3 org.springframework.boot @@ -137,8 +133,8 @@ example - shenyu-examples-http-swagger2 - shenyu-examples-http-swagger2 + shenyu-examples-http-swagger3 + shenyu-examples-http-swagger3 latest @@ -153,7 +149,7 @@ - shenyu-examples-http-swagger2 + shenyu-examples-http-swagger3 ${project.basedir} diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/ShenyuTestSwaggerApplication.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/ShenyuTestSwaggerApplication.java similarity index 100% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/ShenyuTestSwaggerApplication.java rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/ShenyuTestSwaggerApplication.java diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/config/HttpServerConfig.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/config/HttpServerConfig.java similarity index 100% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/config/HttpServerConfig.java rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/config/HttpServerConfig.java diff --git a/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/config/SwaggerConfiguration.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/config/SwaggerConfiguration.java new file mode 100644 index 000000000000..ea298043087d --- /dev/null +++ b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/config/SwaggerConfiguration.java @@ -0,0 +1,112 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.shenyu.examples.http.config; + +import io.swagger.v3.oas.models.Components; +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.oas.models.info.Info; +import io.swagger.v3.oas.models.media.StringSchema; +import io.swagger.v3.oas.models.parameters.Parameter; +import io.swagger.v3.oas.models.security.SecurityRequirement; +import io.swagger.v3.oas.models.security.SecurityScheme; +import io.swagger.v3.oas.models.tags.Tag; +import org.apache.shenyu.common.constant.Constants; +import org.apache.shenyu.common.utils.VersionUtils; +import org.springdoc.core.models.GroupedOpenApi; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.List; + +/** + * Configuration class for Swagger API document using Springdoc. + */ +@Configuration +public class SwaggerConfiguration { + + private static final String DEFAULT_SWAGGER_API_VERSION = "3.0.1"; + + private static final String TITLE = "shenyu-examples-http-swagger3 API"; + + private static final String DESCRIPTION = "shenyu-examples-http-swagger3 API"; + + private static final String CONTACT_NAME = "ShenYu"; + + private static final String CONTACT_URL = "https://github.com/apache/shenyu"; + + private static final String CONTACT_EMAIL = "dev@shenyu.apache.org"; + + private static final String TOKEN_DESCRIPTION = "user auth"; + + private static final String TOKEN_PARAMETER_TYPE = "header"; + + public SwaggerConfiguration() { + } + + /** + * Configure The OpenAPI with Springdoc. + * + * @return GroupedOpenApi {@linkplain GroupedOpenApi} + */ + @Bean + public GroupedOpenApi createRestApi() { + Parameter commonParam = new Parameter() + .in(TOKEN_PARAMETER_TYPE) + .name(Constants.X_ACCESS_TOKEN) + .description(TOKEN_DESCRIPTION) + .required(false) + .schema(new StringSchema()); + + return GroupedOpenApi.builder() + .group("default") + .addOperationCustomizer((operation, handlerMethod) -> { + operation.addParametersItem(commonParam); + return operation; + }) + .packagesToScan("org.apache.shenyu.examples.http.controller") + .build(); + } + + /** + * Configure the OpenAPI with API information. + * + * @return OpenAPI {@linkplain OpenAPI} + */ + @Bean + public OpenAPI customOpenAPI() { + return new OpenAPI() + .info(new Info() + .title(TITLE) + .version(VersionUtils.getVersion(getClass(), DEFAULT_SWAGGER_API_VERSION)) + .description(DESCRIPTION) + .contact(new io.swagger.v3.oas.models.info.Contact() + .name(CONTACT_NAME) + .url(CONTACT_URL) + .email(CONTACT_EMAIL))) + .components(new Components() + .addSecuritySchemes(Constants.X_ACCESS_TOKEN, new SecurityScheme() + .type(SecurityScheme.Type.APIKEY) + .in(SecurityScheme.In.HEADER) + .name(Constants.X_ACCESS_TOKEN))) + .addSecurityItem(new SecurityRequirement().addList(Constants.X_ACCESS_TOKEN)) + .tags(List.of( + new Tag().name("RequestController"), + new Tag().name("Order API") + )); + } +} diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/HttpTestController.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/HttpTestController.java similarity index 90% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/HttpTestController.java rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/HttpTestController.java index 71ab18c24f77..d09eb5b97591 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/HttpTestController.java +++ b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/HttpTestController.java @@ -18,11 +18,11 @@ package org.apache.shenyu.examples.http.controller; import com.google.common.collect.ImmutableMap; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import java.util.Arrays; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; import org.apache.shenyu.common.utils.GsonUtils; import org.apache.shenyu.examples.http.dto.UserDTO; @@ -35,18 +35,18 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.http.codec.multipart.FilePart; -import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestHeader; -import org.springframework.web.bind.annotation.CookieValue; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestPart; import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; import org.springframework.web.server.ServerWebExchange; import reactor.core.publisher.Mono; @@ -57,6 +57,7 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Arrays; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -67,7 +68,7 @@ @RestController @RequestMapping("/test") @ShenyuSpringMvcClient("/test/**") -@Api(tags = "HttpBaseTestAPI") +@Tag(name = "HttpBaseTestAPI") public class HttpTestController { private static final Logger LOGGER = LoggerFactory.getLogger(HttpTestController.class); @@ -78,7 +79,7 @@ public class HttpTestController { * @param userDTO the user dto * @return the user dto */ - @ApiOperation(value = "payment", notes = "The user pays the order.", position = -100) + @Operation(summary = "payment", description = "The user pays the order.") @PostMapping("/payment") public UserDTO post(@RequestBody final UserDTO userDTO) { return userDTO; @@ -90,8 +91,8 @@ public UserDTO post(@RequestBody final UserDTO userDTO) { * @param userId the user id * @return the string */ - @ApiOperation(value = "findByUserId", notes = "Query the user information with the user ID.") - @ApiImplicitParam(value = "user id", name = "userId", required = true, dataType = "string", example = "100000") + @Operation(summary = "findByUserId", description = "Query the user information with the user ID.") + @Parameter(description = "user id", name = "userId", required = true, schema = @Schema(type = "string", example = "100000")) @GetMapping("/findByUserId") public UserDTO findByUserId(@RequestParam("userId") final String userId) { return buildUser(userId, "hello world"); @@ -104,10 +105,10 @@ public UserDTO findByUserId(@RequestParam("userId") final String userId) { * @param name name * @return the string */ - @ApiOperation(value = "findByUserIdName", notes = "Query user information with user ID and name.") - @ApiImplicitParams(value = { - @ApiImplicitParam(value = "user id", name = "userId", required = true, dataTypeClass = String.class, example = "100000"), - @ApiImplicitParam(value = "user name", name = "name", dataTypeClass = String.class, example = "shenyu") + @Operation(summary = "findByUserIdName", description = "Query user information with user ID and name.") + @Parameters(value = { + @Parameter(name = "userId", description = "user id", required = true, schema = @Schema(type = "string", example = "100000")), + @Parameter(name = "name", description = "user name", schema = @Schema(type = "string", example = "shenyu")) }) @GetMapping("/findByUserIdName") public UserDTO findByUserId(@RequestParam("userId") final String userId, @RequestParam("name") final String name) { @@ -122,7 +123,7 @@ public UserDTO findByUserId(@RequestParam("userId") final String userId, @Reques * @param pageSize the page size * @return the user dto */ - @ApiOperation(value = "findByPage", notes = "Find user dto by page.") + @Operation(summary = "findByPage", description = "Find user dto by page.") @GetMapping("/findByPage") public UserDTO findByPage(final String keyword, final Integer page, final Integer pageSize) { return buildUser(keyword, "hello world keyword is " + keyword + " page is " + page + " pageSize is " + pageSize); @@ -135,7 +136,7 @@ public UserDTO findByPage(final String keyword, final Integer page, final Intege * @param name the name * @return the path variable */ - @ApiOperation(value = "getPathVariable", notes = "Gets path variable.") + @Operation(summary = "getPathVariable", description = "Gets path variable.") @GetMapping("/path/{id}") public UserDTO getPathVariable(@PathVariable("id") final String id, @RequestParam("name") final String name) { return buildUser(id, name); @@ -147,7 +148,7 @@ public UserDTO getPathVariable(@PathVariable("id") final String id, @RequestPara * @param id the id * @return the string */ - @ApiOperation(value = "testRestFul", notes = "Test rest ful string") + @Operation(summary = "testRestFul", description = "Test rest ful string") @GetMapping("/path/{id}/name") public UserDTO testRestFul(@PathVariable("id") final String id) { return buildUser(id, "hello world"); @@ -285,7 +286,7 @@ public Mono modifyResponse(final ServerWebExchange exchange) { * @param requestParameter parameter * @return result */ - @ApiOperation(value = "modifyRequestWithHeaderAndCookie", notes = "modify request with header and cookie.") + @Operation(summary = "modifyRequestWithHeaderAndCookie", description = "modify request with header and cookie.") @PostMapping(path = "/modifyRequest") public Map modifyRequest(@RequestBody final UserDTO userDTO, @CookieValue(value = "cookie", defaultValue = "") final String cookie, @@ -305,7 +306,7 @@ public Map modifyRequest(@RequestBody final UserDTO userDTO, * @param param param * @return TreeResult */ - @ApiOperation(value = "retureTreeData", notes = "Return Tree structure data.") + @Operation(summary = "retureTreeData", description = "Return Tree structure data.") @PostMapping("/tree/v1") public TreeResult tree(final UserDTO param) { int id = 0; diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/OauthController.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/OauthController.java similarity index 100% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/OauthController.java rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/OauthController.java diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/OrderController.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/OrderController.java similarity index 91% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/OrderController.java rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/OrderController.java index a96380ce3777..58430d88541b 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/OrderController.java +++ b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/OrderController.java @@ -17,8 +17,8 @@ package org.apache.shenyu.examples.http.controller; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; import org.apache.shenyu.examples.http.dto.OAuth2DTO; import org.apache.shenyu.examples.http.dto.OrderDTO; @@ -38,7 +38,7 @@ /** * TestController. */ -@Api(tags = "Order API", position = 2) +@Tag(name = "Order API") @RestController @RequestMapping("/order") @ShenyuSpringMvcClient("/order") @@ -50,7 +50,7 @@ public class OrderController { * @param orderDTO the order dto * @return the order dto */ - @ApiOperation(value = "save", notes = "save the order.") + @Operation(summary = "save", description = "save the order.") @PostMapping("/save") @ShenyuSpringMvcClient("/save") public OrderDTO save(@RequestBody final OrderDTO orderDTO) { @@ -64,7 +64,7 @@ public OrderDTO save(@RequestBody final OrderDTO orderDTO) { * @param id the id * @return the order dto */ - @ApiOperation(value = "findById", notes = "find order info by id.") + @Operation(summary = "findById", description = "find order info by id.") @GetMapping("/findById") @ShenyuSpringMvcClient("/findById") public OrderDTO findById(@RequestParam("id") final String id) { @@ -78,7 +78,7 @@ public OrderDTO findById(@RequestParam("id") final String id) { * @param name the name * @return the path variable */ - @ApiOperation(value = "getPathVariable", notes = "get path variable.") + @Operation(summary = "getPathVariable", description = "get path variable.") @GetMapping("/path/{id}/{name}") @ShenyuSpringMvcClient("/path/**") public OrderDTO getPathVariable(@PathVariable("id") final String id, @PathVariable("name") final String name) { diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/RequestController.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/RequestController.java similarity index 89% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/RequestController.java rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/RequestController.java index 22b8539a98af..8ce7a9b4cf86 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/RequestController.java +++ b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/RequestController.java @@ -17,8 +17,8 @@ package org.apache.shenyu.examples.http.controller; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +35,7 @@ /** * RequestController. */ -@Api(tags = "RequestController", position = 1) +@Tag(name = "RequestController") @RestController @RequestMapping("/request") @ShenyuSpringMvcClient("/request/**") @@ -50,7 +50,7 @@ public class RequestController { * @param serverHttpRequest request * @return response */ - @ApiOperation(value = "testRequestHeader", notes = "test request header.") + @Operation(summary = "testRequestHeader", description = "test request header.") @GetMapping(path = "/header") public Mono testRequestHeader(@RequestHeader("header_key1") final String headerKey1, final ServerHttpRequest serverHttpRequest) { @@ -65,7 +65,7 @@ public Mono testRequestHeader(@RequestHeader("header_key1") final String * @param serverHttpRequest request * @return response */ - @ApiOperation(value = "testRequestParameter", notes = "test request parameter.") + @Operation(summary = "testRequestParameter", description = "test request parameter.") @PostMapping(path = "/parameter") public Mono testRequestParameter(@RequestParam("parameter_key1") final String parameterKey1, final ServerHttpRequest serverHttpRequest) { @@ -80,7 +80,7 @@ public Mono testRequestParameter(@RequestParam("parameter_key1") final S * @param serverHttpRequest request * @return response */ - @ApiOperation(value = "testRequestCookie", notes = "test request parameter.") + @Operation(summary = "testRequestCookie", description = "test request parameter.") @GetMapping(path = "/cookie") public Mono testRequestCookie(@CookieValue("userId") final String userId, final ServerHttpRequest serverHttpRequest) { diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java similarity index 95% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java index 7fdb26112b2c..b6d92b537096 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java +++ b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/ShenyuClientPathController.java @@ -17,7 +17,7 @@ package org.apache.shenyu.examples.http.controller; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -53,7 +53,7 @@ public String hello() { * @param name say hello user name * @return result */ - @ApiOperation(value = "hello", notes = "Shenyu-Gateway System said hello to you.") + @Operation(summary = "hello", description = "Shenyu-Gateway System said hello to you.") @RequestMapping("shenyu/client/hi") @ShenyuSpringMvcClient("shenyu/client/hi") public String hello(final String name) { diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java similarity index 85% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java index 15130d842e99..9ddcbd7927b8 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java +++ b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/SpringMvcMappingPathController.java @@ -17,8 +17,8 @@ package org.apache.shenyu.examples.http.controller; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; @@ -29,7 +29,7 @@ */ @RestController @ShenyuSpringMvcClient(desc = "spring annotation register") -@Api(value = "springMvcMappingPathController") +@Tag(name = "springMvcMappingPathController") public class SpringMvcMappingPathController { private static final String HELLO_SUFFIX = "I'm Shenyu-Gateway System. Welcome!"; @@ -40,7 +40,7 @@ public class SpringMvcMappingPathController { * @return result */ @RequestMapping("hello") - @ApiOperation(value = "hello", notes = "say hello.") + @Operation(summary = "hello", description = "say hello.") public String hello() { return "hello! " + HELLO_SUFFIX; } @@ -52,7 +52,7 @@ public String hello() { * @return result */ @RequestMapping("hi") - @ApiOperation(value = "hi", notes = "say hello to name.") + @Operation(summary = "hi", description = "say hello to name.") public String hello(final String name) { return "hi! " + name + "! " + HELLO_SUFFIX; } @@ -64,7 +64,7 @@ public String hello(final String name) { * @return result */ @PostMapping("post/hi") - @ApiOperation(value = "postHi", notes = "post hi.") + @Operation(summary = "postHi", description = "post hi.") public String post(final String name) { return "[post method result]:hi! " + name + "! " + HELLO_SUFFIX; } diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/UploadController.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/UploadController.java similarity index 89% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/UploadController.java rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/UploadController.java index 93d1e9a2b5cf..ac1d9e58e101 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/controller/UploadController.java +++ b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/controller/UploadController.java @@ -17,9 +17,8 @@ package org.apache.shenyu.examples.http.controller; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import java.util.stream.Collectors; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient; import org.springframework.http.MediaType; import org.springframework.http.codec.multipart.FilePart; @@ -30,13 +29,15 @@ import reactor.core.publisher.Flux; import reactor.core.publisher.Mono; +import java.util.stream.Collectors; + /** * UploadController. */ @RestController @RequestMapping("/upload") @ShenyuSpringMvcClient("/upload/**") -@Api(tags = "upload api") +@Tag(name = "upload api") public class UploadController { /** @@ -46,7 +47,7 @@ public class UploadController { * @return response */ @PostMapping(value = "/webFluxSingle", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, MediaType.TEXT_PLAIN_VALUE}) - @ApiOperation(value = "webFluxSingle", notes = "upload webFluxSingle.") + @Operation(summary = "webFluxSingle", description = "upload webFluxSingle.") public Mono webFluxSingle(@RequestPart("file") final FilePart file) { return Mono.just(file.filename()); } @@ -58,7 +59,7 @@ public Mono webFluxSingle(@RequestPart("file") final FilePart file) { * @return response */ @PostMapping(value = "/webFluxFiles", consumes = {MediaType.MULTIPART_FORM_DATA_VALUE, MediaType.TEXT_PLAIN_VALUE}) - @ApiOperation(value = "webFluxFiles", notes = "upload webFluxFiles.") + @Operation(summary = "webFluxFiles", description = "upload webFluxFiles.") public Mono webFluxFiles(@RequestPart(value = "files", required = false) final Flux files) { return files.map(FilePart::filename).collect(Collectors.joining(",")); } diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/OAuth2DTO.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/dto/OAuth2DTO.java similarity index 92% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/OAuth2DTO.java rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/dto/OAuth2DTO.java index d0b8ca8525de..b4c379d9eeda 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/OAuth2DTO.java +++ b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/dto/OAuth2DTO.java @@ -17,11 +17,11 @@ package org.apache.shenyu.examples.http.dto; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; public class OAuth2DTO { - @ApiModelProperty(value = "token", example = "afte6789try") + @Schema(name = "token", example = "afte6789try") private String token; /** diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/OrderDTO.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/dto/OrderDTO.java similarity index 88% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/OrderDTO.java rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/dto/OrderDTO.java index 6f102465992c..03792aa2ca84 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/OrderDTO.java +++ b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/dto/OrderDTO.java @@ -17,7 +17,8 @@ package org.apache.shenyu.examples.http.dto; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; + import java.io.Serializable; import java.util.Date; import java.util.StringJoiner; @@ -27,13 +28,13 @@ */ public class OrderDTO implements Serializable { - @ApiModelProperty(value = "id", required = true, example = "100000") + @Schema(name = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "100000") private String id; - @ApiModelProperty(value = "name", required = true, example = "jack") + @Schema(name = "name", requiredMode = Schema.RequiredMode.REQUIRED, example = "jack") private String name; - @ApiModelProperty(value = "createTime", example = "2023-08-01 10:10:01") + @Schema(name = "createTime", example = "2023-08-01 10:10:01") private Date createTime; /** diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/RequestDTO.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/dto/RequestDTO.java similarity index 88% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/RequestDTO.java rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/dto/RequestDTO.java index ab506d8e6766..df98f78892e4 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/RequestDTO.java +++ b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/dto/RequestDTO.java @@ -17,7 +17,8 @@ package org.apache.shenyu.examples.http.dto; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; + import java.util.StringJoiner; /** @@ -25,16 +26,16 @@ */ public class RequestDTO { - @ApiModelProperty(value = "module", required = true, example = "usercenter") + @Schema(name = "module", requiredMode = Schema.RequiredMode.REQUIRED, example = "usercenter") private String module; - @ApiModelProperty(value = "method", required = true, example = "findByUserId", position = 1) + @Schema(name = "method", requiredMode = Schema.RequiredMode.REQUIRED, example = "findByUserId") private String method; - @ApiModelProperty(value = "content", example = "hello,shenyu") + @Schema(name = "content", example = "hello,shenyu") private String content; - @ApiModelProperty(value = "extInfo", example = "extended information", position = 2) + @Schema(name = "extInfo", example = "extended information") private String extInfo; public RequestDTO() { diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/UserDTO.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/dto/UserDTO.java similarity index 87% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/UserDTO.java rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/dto/UserDTO.java index 0a3980280e25..7ea45e0c3cb6 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/dto/UserDTO.java +++ b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/dto/UserDTO.java @@ -17,7 +17,9 @@ package org.apache.shenyu.examples.http.dto; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.ArraySchema; +import io.swagger.v3.oas.annotations.media.Schema; + import java.util.List; import java.util.Map; @@ -26,19 +28,19 @@ */ public class UserDTO { - @ApiModelProperty(value = "user id", required = true, example = "100000") + @Schema(name = "user id", requiredMode = Schema.RequiredMode.REQUIRED, example = "100000") private String userId; - @ApiModelProperty(value = "user name", example = "shenyu") + @Schema(name = "user name", example = "shenyu") private String userName; - @ApiModelProperty(value = "main order", example = "") + @Schema(name = "main order", example = "") private OrderDTO mainOrder; - @ApiModelProperty(value = "order list", required = true, dataType = "List", example = "") + @ArraySchema(schema = @Schema(description = "order list", requiredMode = Schema.RequiredMode.REQUIRED, example = "")) private List orderDetailList; - @ApiModelProperty(value = "order map", example = "") + @Schema(name = "order map", example = "") private Map orderDetailMap; /** diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/result/ResultBean.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/result/ResultBean.java similarity index 100% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/result/ResultBean.java rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/result/ResultBean.java diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/result/TreeResult.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/result/TreeResult.java similarity index 86% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/result/TreeResult.java rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/result/TreeResult.java index c5f7f831ea55..cc2af68e1506 100755 --- a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/result/TreeResult.java +++ b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/result/TreeResult.java @@ -17,20 +17,21 @@ package org.apache.shenyu.examples.http.result; -import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; + import java.util.List; public class TreeResult { - @ApiModelProperty(value = "id", required = true, example = "123") + @Schema(name = "id", requiredMode = Schema.RequiredMode.REQUIRED, example = "123") private Integer id; - @ApiModelProperty(value = "name", required = true, example = "shenyu") + @Schema(name = "name", requiredMode = Schema.RequiredMode.REQUIRED, example = "shenyu") private String name; - @ApiModelProperty(value = "parent id") + @Schema(name = "parent id") private Integer parentId; - @ApiModelProperty(value = "children node list", example = "list") + @Schema(name = "children node list", example = "list") private List children; /** diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/router/ShenyuTestHttpRouter.java b/shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/router/ShenyuTestHttpRouter.java similarity index 100% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/java/org/apache/shenyu/examples/http/router/ShenyuTestHttpRouter.java rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/java/org/apache/shenyu/examples/http/router/ShenyuTestHttpRouter.java diff --git a/shenyu-examples/shenyu-examples-http-swagger2/src/main/resources/application.yml b/shenyu-examples/shenyu-examples-http-swagger3/src/main/resources/application.yml similarity index 91% rename from shenyu-examples/shenyu-examples-http-swagger2/src/main/resources/application.yml rename to shenyu-examples/shenyu-examples-http-swagger3/src/main/resources/application.yml index a3662a040a5d..f220894363d3 100644 --- a/shenyu-examples/shenyu-examples-http-swagger2/src/main/resources/application.yml +++ b/shenyu-examples/shenyu-examples-http-swagger3/src/main/resources/application.yml @@ -19,7 +19,7 @@ server: tomcat: max-http-form-post-size: 100MB servlet: - context-path: /http-swagger2 # should be the same as shenyu.client.http.contextPath + context-path: /http-swagger3 # should be the same as shenyu.client.http.contextPath shenyu: register: @@ -31,15 +31,15 @@ shenyu: client: http: props: - contextPath: /http-swagger2 - appName: http-swagger2 + contextPath: /http-swagger3 + appName: http-swagger3 # port: 8190 # discovery: # enable: true # protocol: http:// #https:// # type: zookeeper # serverList: 127.0.0.1:2181 -# registerPath: /shenyu/discovery/demo_swagger2_common +# registerPath: /shenyu/discovery/demo_swagger3_common # props: # baseSleepTimeMilliseconds: 1000 # maxRetries: 4 diff --git a/shenyu-examples/shenyu-examples-http/pom.xml b/shenyu-examples/shenyu-examples-http/pom.xml index 8b97f444c3cf..bfb9ea521cec 100644 --- a/shenyu-examples/shenyu-examples-http/pom.xml +++ b/shenyu-examples/shenyu-examples-http/pom.xml @@ -28,7 +28,7 @@ shenyu-examples-http - 3.3.2 + 3.12.0 21.0 4.4