Kaynağa Gözat

优化swagger

mxd 4 yıl önce
ebeveyn
işleme
d243e62ebf

+ 45 - 1
src/main/java/org/ssssssss/magicapi/swagger/SwaggerEntity.java

@@ -116,6 +116,39 @@ public class SwaggerEntity {
 		return paths;
 	}
 
+	public static class Concat {
+
+		private String name;
+
+		private String url;
+
+		private String email;
+
+		public String getName() {
+			return name;
+		}
+
+		public void setName(String name) {
+			this.name = name;
+		}
+
+		public String getUrl() {
+			return url;
+		}
+
+		public void setUrl(String url) {
+			this.url = url;
+		}
+
+		public String getEmail() {
+			return email;
+		}
+
+		public void setEmail(String email) {
+			this.email = email;
+		}
+	}
+
 	public static class Info {
 
 		private String description;
@@ -126,11 +159,14 @@ public class SwaggerEntity {
 
 		private License license;
 
-		public Info(String description, String version, String title, License license) {
+		private Concat concat;
+
+		public Info(String description, String version, String title, License license, Concat concat) {
 			this.description = description;
 			this.version = version;
 			this.title = title;
 			this.license = license;
+			this.concat = concat;
 		}
 
 		public String getDescription() {
@@ -164,6 +200,14 @@ public class SwaggerEntity {
 		public void setLicense(License license) {
 			this.license = license;
 		}
+
+		public Concat getConcat() {
+			return concat;
+		}
+
+		public void setConcat(Concat concat) {
+			this.concat = concat;
+		}
 	}
 
 	public static class Path {

+ 5 - 27
src/main/java/org/ssssssss/magicapi/swagger/SwaggerProvider.java

@@ -21,21 +21,6 @@ public class SwaggerProvider {
 
 	private MappingHandlerMapping mappingHandlerMapping;
 
-	/**
-	 * 描述信息
-	 */
-	private String description;
-
-	/**
-	 * 标题
-	 */
-	private String title;
-
-	/**
-	 * 版本号
-	 */
-	private String version;
-
 	/**
 	 * 基础路径
 	 */
@@ -43,6 +28,8 @@ public class SwaggerProvider {
 
 	private GroupServiceProvider groupServiceProvider;
 
+	private SwaggerEntity.Info info;
+
 	public void setMappingHandlerMapping(MappingHandlerMapping mappingHandlerMapping) {
 		this.mappingHandlerMapping = mappingHandlerMapping;
 	}
@@ -51,16 +38,8 @@ public class SwaggerProvider {
 		this.groupServiceProvider = groupServiceProvider;
 	}
 
-	public void setDescription(String description) {
-		this.description = description;
-	}
-
-	public void setTitle(String title) {
-		this.title = title;
-	}
-
-	public void setVersion(String version) {
-		this.version = version;
+	public void setInfo(SwaggerEntity.Info info) {
+		this.info = info;
 	}
 
 	public void setBasePath(String basePath) {
@@ -71,8 +50,7 @@ public class SwaggerProvider {
 	public SwaggerEntity swaggerJson() {
 		List<ApiInfo> infos = mappingHandlerMapping.getApiInfos();
 		SwaggerEntity swaggerEntity = new SwaggerEntity();
-		SwaggerEntity.License license = new SwaggerEntity.License("MIT", "https://gitee.com/ssssssss-team/magic-api/blob/master/LICENSE");
-		swaggerEntity.setInfo(new SwaggerEntity.Info(this.description, this.version, this.title, license));
+		swaggerEntity.setInfo(info);
 		swaggerEntity.setBasePath(this.basePath);
 		ObjectMapper mapper = new ObjectMapper();
 		for (ApiInfo info : infos) {