mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-07 01:18:27 +08:00
swagger 5.15.0 knife4j 4.5.0
This commit is contained in:
parent
d82535228b
commit
8eb431c6aa
@ -398,8 +398,10 @@ subprojects {
|
|||||||
implementation group: 'com.tencentcloudapi', name: 'tencentcloud-sdk-java', version: "${tencentcloudsdkjavaVersion}"
|
implementation group: 'com.tencentcloudapi', name: 'tencentcloud-sdk-java', version: "${tencentcloudsdkjavaVersion}"
|
||||||
//docs
|
//docs
|
||||||
implementation group: 'org.mapstruct', name: 'mapstruct', version: "${mapstructVersion}"
|
implementation group: 'org.mapstruct', name: 'mapstruct', version: "${mapstructVersion}"
|
||||||
|
implementation group: 'io.swagger.core.v3', name: 'swagger-annotations', version: "${swaggerV3Version}"
|
||||||
implementation group: 'io.swagger.core.v3', name: 'swagger-annotations-jakarta', version: "${swaggerV3Version}"
|
implementation group: 'io.swagger.core.v3', name: 'swagger-annotations-jakarta', version: "${swaggerV3Version}"
|
||||||
implementation group: 'io.swagger.core.v3', name: 'swagger-core-jakarta', version: "${swaggerV3Version}"
|
implementation group: 'io.swagger.core.v3', name: 'swagger-core-jakarta', version: "${swaggerV3Version}"
|
||||||
|
//implementation group: 'io.swagger.core.v3', name: 'swagger-models', version: "${swaggerV3Version}"
|
||||||
implementation group: 'io.swagger.core.v3', name: 'swagger-models-jakarta', version: "${swaggerV3Version}"
|
implementation group: 'io.swagger.core.v3', name: 'swagger-models-jakarta', version: "${swaggerV3Version}"
|
||||||
//springdoc
|
//springdoc
|
||||||
implementation group: 'io.github.classgraph', name: 'classgraph', version: "${classgraphVersion}"
|
implementation group: 'io.github.classgraph', name: 'classgraph', version: "${classgraphVersion}"
|
||||||
|
|||||||
@ -198,8 +198,8 @@ swaggerV3Version =2.2.21
|
|||||||
classgraphVersion =4.8.149
|
classgraphVersion =4.8.149
|
||||||
webjarslocatorcoreVersion =0.58
|
webjarslocatorcoreVersion =0.58
|
||||||
webjarslocatorVersion =0.52
|
webjarslocatorVersion =0.52
|
||||||
swaggeruiVersion =5.17.2
|
swaggeruiVersion =5.15.0
|
||||||
springdocVersion =2.5.0
|
springdocVersion =2.0.4
|
||||||
knife4jVersion =4.5.0
|
knife4jVersion =4.5.0
|
||||||
#sdk
|
#sdk
|
||||||
aliyunjavasdkcoreVersion =4.6.4
|
aliyunjavasdkcoreVersion =4.6.4
|
||||||
|
|||||||
@ -45,6 +45,7 @@ import org.springframework.http.converter.HttpMessageConverter;
|
|||||||
import org.springframework.http.converter.StringHttpMessageConverter;
|
import org.springframework.http.converter.StringHttpMessageConverter;
|
||||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||||
import org.springframework.http.converter.xml.MarshallingHttpMessageConverter;
|
import org.springframework.http.converter.xml.MarshallingHttpMessageConverter;
|
||||||
|
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
|
||||||
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
|
import org.springframework.oxm.jaxb.Jaxb2Marshaller;
|
||||||
import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter;
|
import org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
@ -197,6 +198,10 @@ public class MvcAutoConfiguration implements WebMvcConfigurer {
|
|||||||
StringHttpMessageConverter stringHttpMessageConverter,
|
StringHttpMessageConverter stringHttpMessageConverter,
|
||||||
RequestMappingHandlerAdapter requestMappingHandlerAdapter) {
|
RequestMappingHandlerAdapter requestMappingHandlerAdapter) {
|
||||||
List<HttpMessageConverter<?>> httpMessageConverterList = new ArrayList<>();
|
List<HttpMessageConverter<?>> httpMessageConverterList = new ArrayList<>();
|
||||||
|
//需要追加byte,否则springdoc-openapi接口会响应Base64编码内容,导致接口文档显示失败
|
||||||
|
// https://github.com/springdoc/springdoc-openapi/issues/2143
|
||||||
|
// 解决方案
|
||||||
|
httpMessageConverterList.add(new ByteArrayHttpMessageConverter());
|
||||||
httpMessageConverterList.add(mappingJacksonHttpMessageConverter);
|
httpMessageConverterList.add(mappingJacksonHttpMessageConverter);
|
||||||
httpMessageConverterList.add(marshallingHttpMessageConverter);
|
httpMessageConverterList.add(marshallingHttpMessageConverter);
|
||||||
httpMessageConverterList.add(stringHttpMessageConverter);
|
httpMessageConverterList.add(stringHttpMessageConverter);
|
||||||
|
|||||||
@ -65,7 +65,7 @@ public class SwaggerAutoConfiguration {
|
|||||||
"/api/oauth/v20/me"
|
"/api/oauth/v20/me"
|
||||||
|
|
||||||
};
|
};
|
||||||
String[] packagedToMatch = { "org.maxkey.authz" };
|
String[] packagedToMatch = { "org.dromara.maxkey.authz" };
|
||||||
return GroupedOpenApi.builder().group(title)
|
return GroupedOpenApi.builder().group(title)
|
||||||
.pathsToMatch(paths)
|
.pathsToMatch(paths)
|
||||||
.packagesToScan(packagedToMatch).build();
|
.packagesToScan(packagedToMatch).build();
|
||||||
@ -79,7 +79,7 @@ public class SwaggerAutoConfiguration {
|
|||||||
.title(title)
|
.title(title)
|
||||||
.description(description)
|
.description(description)
|
||||||
.version(version)
|
.version(version)
|
||||||
.termsOfService("http://www.maxkey.top/")
|
.termsOfService("https://www.maxkey.top/")
|
||||||
.license(
|
.license(
|
||||||
new License()
|
new License()
|
||||||
.name("Apache License, Version 2.0")
|
.name("Apache License, Version 2.0")
|
||||||
@ -89,7 +89,7 @@ public class SwaggerAutoConfiguration {
|
|||||||
externalDocs(
|
externalDocs(
|
||||||
new ExternalDocumentation()
|
new ExternalDocumentation()
|
||||||
.description("MaxKey.top contact support@maxsso.net")
|
.description("MaxKey.top contact support@maxsso.net")
|
||||||
.url("http://www.maxkey.top/")
|
.url("https://www.maxkey.top/")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
BIN
maxkey-core/src/main/resources/favicon.ico
Normal file
BIN
maxkey-core/src/main/resources/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
@ -32,8 +32,8 @@ import org.dromara.maxkey.util.Instance;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@ -47,10 +47,10 @@ import jakarta.servlet.http.HttpServletRequest;
|
|||||||
@Tag(name = "2-8-ExtendApi接口文档模块")
|
@Tag(name = "2-8-ExtendApi接口文档模块")
|
||||||
@Controller
|
@Controller
|
||||||
public class ExtendApiAuthorizeEndpoint extends AuthorizeBaseEndpoint{
|
public class ExtendApiAuthorizeEndpoint extends AuthorizeBaseEndpoint{
|
||||||
final static Logger _logger = LoggerFactory.getLogger(ExtendApiAuthorizeEndpoint.class);
|
static final Logger _logger = LoggerFactory.getLogger(ExtendApiAuthorizeEndpoint.class);
|
||||||
|
|
||||||
@Operation(summary = "ExtendApi认证地址接口", description = "参数应用ID",method="GET")
|
@Operation(summary = "ExtendApi认证地址接口", description = "参数应用ID")
|
||||||
@RequestMapping("/authz/api/{id}")
|
@GetMapping("/authz/api/{id}")
|
||||||
public ModelAndView authorize(
|
public ModelAndView authorize(
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
@PathVariable("id") String id,
|
@PathVariable("id") String id,
|
||||||
@ -61,7 +61,7 @@ public class ExtendApiAuthorizeEndpoint extends AuthorizeBaseEndpoint{
|
|||||||
modelAndView.addObject("errorMessage", "");
|
modelAndView.addObject("errorMessage", "");
|
||||||
|
|
||||||
Apps apps = getApp(id);
|
Apps apps = getApp(id);
|
||||||
_logger.debug(""+apps);
|
_logger.debug("{}" , apps);
|
||||||
if(ConstsBoolean.isTrue(apps.getIsAdapter())){
|
if(ConstsBoolean.isTrue(apps.getIsAdapter())){
|
||||||
_logger.debug("Adapter {}",apps.getAdapter());
|
_logger.debug("Adapter {}",apps.getAdapter());
|
||||||
AbstractAuthorizeAdapter adapter = (AbstractAuthorizeAdapter)Instance.newInstance(apps.getAdapter());
|
AbstractAuthorizeAdapter adapter = (AbstractAuthorizeAdapter)Instance.newInstance(apps.getAdapter());
|
||||||
|
|||||||
@ -44,9 +44,8 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
@ -71,8 +70,8 @@ public class JwtAuthorizeEndpoint extends AuthorizeBaseEndpoint{
|
|||||||
@Autowired
|
@Autowired
|
||||||
ApplicationConfig applicationConfig;
|
ApplicationConfig applicationConfig;
|
||||||
|
|
||||||
@Operation(summary = "JWT应用ID认证接口", description = "应用ID",method="GET")
|
@Operation(summary = "JWT应用ID认证接口", description = "应用ID")
|
||||||
@RequestMapping("/authz/jwt/{id}")
|
@GetMapping("/authz/jwt/{id}")
|
||||||
public ModelAndView authorize(
|
public ModelAndView authorize(
|
||||||
HttpServletRequest request,
|
HttpServletRequest request,
|
||||||
HttpServletResponse response,
|
HttpServletResponse response,
|
||||||
@ -110,10 +109,8 @@ public class JwtAuthorizeEndpoint extends AuthorizeBaseEndpoint{
|
|||||||
return adapter.authorize(modelAndView);
|
return adapter.authorize(modelAndView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "JWT JWK元数据接口", description = "参数mxk_metadata_APPID",method="GET")
|
@Operation(summary = "JWT JWK元数据接口", description = "参数mxk_metadata_APPID")
|
||||||
@RequestMapping(
|
@GetMapping(value = "/metadata/jwt/" + WebConstants.MXK_METADATA_PREFIX + "{appid}.{mediaType}")
|
||||||
value = "/metadata/jwt/" + WebConstants.MXK_METADATA_PREFIX + "{appid}.{mediaType}",
|
|
||||||
method={RequestMethod.POST, RequestMethod.GET})
|
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public String metadata(HttpServletRequest request,
|
public String metadata(HttpServletRequest request,
|
||||||
HttpServletResponse response,
|
HttpServletResponse response,
|
||||||
|
|||||||
@ -111,6 +111,9 @@ public class MaxKeyMvcConfig implements WebMvcConfigurer {
|
|||||||
.addPathPatterns("/logout")
|
.addPathPatterns("/logout")
|
||||||
.addPathPatterns("/logout/**")
|
.addPathPatterns("/logout/**")
|
||||||
.addPathPatterns("/authz/refused")
|
.addPathPatterns("/authz/refused")
|
||||||
|
.excludePathPatterns("/swagger-ui/**")
|
||||||
|
.excludePathPatterns("/swagger-resources/**")
|
||||||
|
.excludePathPatterns("/v3/api-docs/**")
|
||||||
;
|
;
|
||||||
|
|
||||||
logger.debug("add Permission Interceptor");
|
logger.debug("add Permission Interceptor");
|
||||||
|
|||||||
@ -47,9 +47,11 @@ import org.springframework.http.ResponseEntity;
|
|||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.stereotype.Controller;
|
import org.springframework.stereotype.Controller;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
@ -61,7 +63,7 @@ import jakarta.servlet.http.HttpServletResponse;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Tag(name = "1-1-登录接口文档模块")
|
@Tag(name = "1-1-登录接口文档模块")
|
||||||
@Controller
|
@RestController
|
||||||
@RequestMapping(value = "/login")
|
@RequestMapping(value = "/login")
|
||||||
public class LoginEntryPoint {
|
public class LoginEntryPoint {
|
||||||
private static Logger logger = LoggerFactory.getLogger(LoginEntryPoint.class);
|
private static Logger logger = LoggerFactory.getLogger(LoginEntryPoint.class);
|
||||||
@ -213,7 +215,8 @@ public class LoginEntryPoint {
|
|||||||
* @param loginCredential
|
* @param loginCredential
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@RequestMapping(value={"/signin"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
@Operation(summary = "登录接口", description = "登录接口",method="POST")
|
||||||
|
@PostMapping(value={"/signin"}, produces = {MediaType.APPLICATION_JSON_VALUE})
|
||||||
public ResponseEntity<?> signin( HttpServletRequest request, HttpServletResponse response,
|
public ResponseEntity<?> signin( HttpServletRequest request, HttpServletResponse response,
|
||||||
@RequestBody LoginCredential credential) {
|
@RequestBody LoginCredential credential) {
|
||||||
Message<AuthJwt> authJwtMessage = new Message<AuthJwt>(Message.FAIL);
|
Message<AuthJwt> authJwtMessage = new Message<AuthJwt>(Message.FAIL);
|
||||||
|
|||||||
@ -292,7 +292,7 @@ springdoc.swagger-ui.showExtensions =true
|
|||||||
springdoc.api-docs.path =/v3/api-docs
|
springdoc.api-docs.path =/v3/api-docs
|
||||||
springdoc.group-configs[0].group =default
|
springdoc.group-configs[0].group =default
|
||||||
springdoc.group-configs[0].paths-to-match =/*
|
springdoc.group-configs[0].paths-to-match =/*
|
||||||
springdoc.group-configs[0].packages-to-scan =org.maxkey
|
springdoc.group-configs[0].packages-to-scan =org.dromara.maxkey
|
||||||
|
|
||||||
knife4j.enable =true
|
knife4j.enable =true
|
||||||
knife4j.setting.language =zh_cn
|
knife4j.setting.language =zh_cn
|
||||||
|
|||||||
@ -225,7 +225,7 @@ springdoc.swagger-ui.showExtensions =true
|
|||||||
springdoc.api-docs.path =/v3/api-docs
|
springdoc.api-docs.path =/v3/api-docs
|
||||||
springdoc.group-configs[0].group =default
|
springdoc.group-configs[0].group =default
|
||||||
springdoc.group-configs[0].paths-to-match =/*
|
springdoc.group-configs[0].paths-to-match =/*
|
||||||
springdoc.group-configs[0].packages-to-scan =org.maxkey
|
springdoc.group-configs[0].packages-to-scan =org.dromara.maxkey
|
||||||
|
|
||||||
knife4j.enable =true
|
knife4j.enable =true
|
||||||
knife4j.setting.language =zh_cn
|
knife4j.setting.language =zh_cn
|
||||||
|
|||||||
@ -225,7 +225,7 @@ springdoc.swagger-ui.showExtensions =true
|
|||||||
springdoc.api-docs.path =/v3/api-docs
|
springdoc.api-docs.path =/v3/api-docs
|
||||||
springdoc.group-configs[0].group =default
|
springdoc.group-configs[0].group =default
|
||||||
springdoc.group-configs[0].paths-to-match =/*
|
springdoc.group-configs[0].paths-to-match =/*
|
||||||
springdoc.group-configs[0].packages-to-scan =org.maxkey
|
springdoc.group-configs[0].packages-to-scan =org.dromara.maxkey
|
||||||
|
|
||||||
knife4j.enable =true
|
knife4j.enable =true
|
||||||
knife4j.setting.language =zh_cn
|
knife4j.setting.language =zh_cn
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user