mirror of
https://gitee.com/dromara/MaxKey.git
synced 2025-12-08 01:48:33 +08:00
Swagger+Knife4j Docs
Swagger+Knife4j Docs
This commit is contained in:
parent
16912f7562
commit
0527968490
43
build.gradle
43
build.gradle
@ -94,8 +94,6 @@ subprojects {
|
||||
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/'}
|
||||
maven { url "https://repo.spring.io/plugins-release/" }
|
||||
maven { url "https://repo.spring.io/milestone" }
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven { url "https://repo1.maven.org/maven2/" }
|
||||
maven { url "https://build.shibboleth.net/nexus/content/repositories/releases/" }
|
||||
maven { url "https://mvnrepository.com/repos/central/" }
|
||||
@ -105,6 +103,8 @@ subprojects {
|
||||
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
|
||||
maven { url "https://maven.repository.redhat.com/ga/" }
|
||||
maven { url "https://repository.apache.org/content/repositories/releases/" }
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
//all dependencies
|
||||
@ -213,6 +213,10 @@ subprojects {
|
||||
//spring-session
|
||||
compile group: 'org.springframework.session', name: 'spring-session-core', version: "${springSessionVersion}"
|
||||
compile group: 'org.springframework.session', name: 'spring-session-data-redis', version: "${springSessionVersion}"
|
||||
|
||||
compile group: 'org.springframework.plugin', name: 'spring-plugin-core', version: '2.0.0.RELEASE'
|
||||
compile group: 'org.springframework.plugin', name: 'spring-plugin-metadata', version: '2.0.0.RELEASE'
|
||||
|
||||
//saml
|
||||
compile group: 'org.opensaml', name: 'opensaml', version: '2.6.6'
|
||||
compile group: 'org.opensaml', name: 'openws', version: '1.5.6'
|
||||
@ -256,6 +260,10 @@ subprojects {
|
||||
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "${jacksonVersion}"
|
||||
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: "${jacksonVersion}"
|
||||
compile group: 'com.fasterxml.jackson.core', name: 'jackson-annotations', version: "${jacksonVersion}"
|
||||
compile group: 'com.fasterxml.jackson.datatype', name: 'jackson-datatype-jsr310', version: "${jacksonVersion}"
|
||||
compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: "${jacksonVersion}"
|
||||
compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-xml', version: "${jacksonVersion}"
|
||||
|
||||
compile group: 'com.fasterxml', name: 'classmate', version: '1.5.0'
|
||||
compile group: 'com.alibaba', name: 'fastjson', version: '1.2.74'
|
||||
//reactive
|
||||
@ -297,6 +305,37 @@ subprojects {
|
||||
compile group: 'com.thoughtworks.xstream', name: 'xstream', version: '1.4.10'
|
||||
compile group: 'org.passay', name: 'passay', version: '1.6.0'
|
||||
|
||||
//docs
|
||||
compile group: 'org.mapstruct', name: 'mapstruct', version: '1.4.1.Final'
|
||||
compile group: 'io.swagger', name: 'swagger-annotations', version: "${swaggerVersion}"
|
||||
compile group: 'io.swagger', name: 'swagger-models', version: "${swaggerVersion}"
|
||||
compile group: 'io.swagger.core.v3', name: 'swagger-annotations', version: "${swaggerV3Version}"
|
||||
compile group: 'io.swagger.core.v3', name: 'swagger-core', version: "${swaggerV3Version}"
|
||||
compile group: 'io.swagger.core.v3', name: 'swagger-integration', version: "${swaggerV3Version}"
|
||||
compile group: 'io.swagger.core.v3', name: 'swagger-models', version: "${swaggerV3Version}"
|
||||
//springfox
|
||||
compile group: 'io.springfox', name: 'springfox-bean-validators', version: "${springfoxVersion}"
|
||||
compile group: 'io.springfox', name: 'springfox-core', version: "${springfoxVersion}"
|
||||
compile group: 'io.springfox', name: 'springfox-data-rest', version: "${springfoxVersion}"
|
||||
compile group: 'io.springfox', name: 'springfox-spi', version: "${springfoxVersion}"
|
||||
compile group: 'io.springfox', name: 'springfox-oas', version: "${springfoxVersion}"
|
||||
compile group: 'io.springfox', name: 'springfox-schema', version: "${springfoxVersion}"
|
||||
compile group: 'io.springfox', name: 'springfox-swagger2', version: "${springfoxVersion}"
|
||||
compile group: 'io.springfox', name: 'springfox-swagger-ui', version: "${springfoxVersion}"
|
||||
compile group: 'io.springfox', name: 'springfox-swagger-common', version: "${springfoxVersion}"
|
||||
compile group: 'io.springfox', name: 'springfox-spring-webmvc', version: "${springfoxVersion}"
|
||||
compile group: 'io.springfox', name: 'springfox-spring-web', version: "${springfoxVersion}"
|
||||
compile group: 'io.springfox', name: 'springfox-spring-webflux', version: "${springfoxVersion}"
|
||||
compile group: 'io.springfox', name: 'springfox-boot-starter', version: "${springfoxVersion}"
|
||||
//knife4j
|
||||
compile group: 'com.github.xiaoymin', name: 'knife4j-annotations', version: "${knife4jVersion}"
|
||||
compile group: 'com.github.xiaoymin', name: 'knife4j-core', version: "${knife4jVersion}"
|
||||
compile group: 'com.github.xiaoymin', name: 'knife4j-spring-mvc', version: "${knife4jVersion}"
|
||||
compile group: 'com.github.xiaoymin', name: 'knife4j-spring', version: "${knife4jVersion}"
|
||||
compile group: 'com.github.xiaoymin', name: 'knife4j-spring-ui', version: "${knife4jVersion}"
|
||||
compile group: 'com.github.xiaoymin', name: 'knife4j-spring-boot-starter', version: "${knife4jVersion}"
|
||||
compile group: 'com.github.xiaoymin', name: 'knife4j-spring-boot-autoconfigure', version: "${knife4jVersion}"
|
||||
|
||||
//local jars
|
||||
compile fileTree(dir: "${rootDir}/maxkey-lib/", include: '*.jar')
|
||||
//阿里云
|
||||
|
||||
@ -16,3 +16,7 @@ bouncycastleVersion =1.64
|
||||
httpcomponentsVersion =4.5.12
|
||||
poiVersion =4.1.2
|
||||
jibGradlePluginVersion =2.7.0
|
||||
swaggerVersion =1.6.2
|
||||
swaggerV3Version =2.1.6
|
||||
springfoxVersion =3.0.0
|
||||
knife4jVersion =3.0.2
|
||||
@ -37,7 +37,7 @@ import org.maxkey.crypto.KeyPairType;
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
public final class DsaSigner implements Signer {
|
||||
public final class DsaSigner implements ISigner {
|
||||
|
||||
// <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Կ<EFBFBD>㷨
|
||||
public static final KeyPairType KEY_ALGORITHM = KeyPairType.DSA;
|
||||
|
||||
@ -34,7 +34,7 @@ package org.maxkey.crypto.signature;
|
||||
* @author Crystal.Sea
|
||||
*
|
||||
*/
|
||||
public interface Signer {
|
||||
public interface ISigner {
|
||||
|
||||
public byte[] sign(byte[] data,byte[] privateKey)throws Exception;
|
||||
|
||||
@ -39,7 +39,7 @@ import org.maxkey.crypto.KeyPairType;
|
||||
*
|
||||
*/
|
||||
|
||||
public final class RsaSigner implements Signer {
|
||||
public final class RsaSigner implements ISigner {
|
||||
|
||||
public static final KeyPairType KEY_ALGORTHM = KeyPairType.RSA;
|
||||
|
||||
|
||||
@ -34,10 +34,14 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* @author Crystal.Sea
|
||||
* https://apereo.github.io/cas/6.2.x/protocol/CAS-Protocol-Specification.html
|
||||
*/
|
||||
@Api(tags = "CAS API文档模块")
|
||||
@Controller
|
||||
public class Cas10AuthorizeEndpoint extends CasBaseAuthorizeEndpoint{
|
||||
|
||||
@ -77,6 +81,7 @@ renew [OPTIONAL] - if this parameter is set, ticket validation will only succeed
|
||||
no<LF>
|
||||
<LF>
|
||||
*/
|
||||
@ApiOperation(value = "CAS 1.0 ticket验证接口", notes = "通过ticket获取当前登录用户信息",httpMethod="POST")
|
||||
@RequestMapping("/authz/cas/validate")
|
||||
@ResponseBody
|
||||
public String validate(
|
||||
|
||||
@ -72,6 +72,14 @@ public class MaxKeyMvcConfig implements WebMvcConfigurer {
|
||||
.addResourceLocations("classpath:/static/");
|
||||
registry.addResourceHandler("/templates/**")
|
||||
.addResourceLocations("classpath:/templates/");
|
||||
|
||||
registry.addResourceHandler("swagger-ui.html")
|
||||
.addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("/webjars/**")
|
||||
.addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
|
||||
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
_logger.debug("add addResourceHandler");
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,73 @@
|
||||
package org.maxkey.autoconfigure;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import org.mybatis.spring.annotation.MapperScan;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.oas.annotations.EnableOpenApi;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@Configuration
|
||||
@EnableSwagger2
|
||||
@EnableOpenApi
|
||||
@EnableKnife4j
|
||||
@MapperScan(basePackages = {"org.maxkey"})
|
||||
public class SwaggerConfig {
|
||||
|
||||
@Value("${maxkey.swagger.title}")
|
||||
String title;
|
||||
|
||||
@Value("${maxkey.swagger.description}")
|
||||
String description;
|
||||
|
||||
@Value("${maxkey.swagger.version}")
|
||||
String version;
|
||||
|
||||
@Value("${maxkey.swagger.enable}")
|
||||
boolean enable;
|
||||
|
||||
@Bean
|
||||
public Docket docket(){
|
||||
if(enable) {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.basePackage("org.maxkey")
|
||||
.and(RequestHandlerSelectors.withClassAnnotation(Api.class))
|
||||
.and(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 配置swagger信息
|
||||
private ApiInfo apiInfo() {
|
||||
Contact contact = new Contact(
|
||||
"MaxKey.top",
|
||||
"https://www.maxkey.top/",
|
||||
"maxkeysupport@163.com");
|
||||
|
||||
return new ApiInfo(
|
||||
title,
|
||||
description,
|
||||
version,
|
||||
"https://www.maxkey.top/",
|
||||
contact,
|
||||
"Apache License, Version 2.0",
|
||||
"http://www.apache.org/licenses/LICENSE-2.0",
|
||||
new ArrayList());
|
||||
}
|
||||
}
|
||||
@ -8,4 +8,7 @@ org.maxkey.autoconfigure.CasAutoConfiguration,\
|
||||
org.maxkey.autoconfigure.Oauth20AutoConfiguration,\
|
||||
org.maxkey.autoconfigure.Saml20AutoConfiguration,\
|
||||
org.maxkey.autoconfigure.SocialSignOnAutoConfiguration,\
|
||||
org.maxkey.autoconfigure.SwaggerConfig,\
|
||||
org.maxkey.MaxKeyMvcConfig
|
||||
|
||||
|
||||
|
||||
@ -109,3 +109,10 @@ spring.kafka.producer.key-serializer=org.apache.kafka.common.serialization.Strin
|
||||
spring.kafka.producer.value-serializer=org.apache.kafka.common.serialization.StringSerializer
|
||||
# \u81ea\u5b9a\u4e49\u5206\u533a\u5668
|
||||
# spring.kafka.producer.properties.partitioner.class=com.felix.kafka.producer.CustomizePartitioner
|
||||
|
||||
#springfox.documentation.swagger.v2.path=/api-docs
|
||||
#Swagger Configure Properties
|
||||
maxkey.swagger.enable=true
|
||||
maxkey.swagger.title=MaxKey\u5355\u70b9\u767b\u5f55\u8ba4\u8bc1\u7cfb\u7edfapi\u6587\u6863
|
||||
maxkey.swagger.description=MaxKey\u5355\u70b9\u767b\u5f55\u8ba4\u8bc1\u7cfb\u7edfapi\u6587\u6863
|
||||
maxkey.swagger.version=${application.formatted-version}
|
||||
Loading…
x
Reference in New Issue
Block a user