Переглянути джерело

`swagger`支持参数默认值

mxd 4 роки тому
батько
коміт
440dbecc17

+ 24 - 13
src/main/java/org/ssssssss/magicapi/swagger/SwaggerEntity.java

@@ -274,30 +274,26 @@ public class SwaggerEntity {
 
 		private String type;
 
-		private Map<String, Object> schema;
+		private Object schema;
 
 		private String description;
 
+		private Object example;
+
 		public Parameter(String name, String in, String type, String description, Object example) {
 			this.name = name;
 			this.in = in;
-			this.schema = new HashMap<>();
-			this.schema.put("type", type);
-			this.schema.put("example", example);
 			this.description = description;
 			if ("body".equalsIgnoreCase(in)) {
+				Map<String, Object> schema = new HashMap<>();
+				schema.put("type", type);
+				schema.put("example", example);
 				this.schema = doProcessSchema(example);
+			} else {
+				this.example = example;
 			}
 		}
 
-		public String getDescription() {
-			return description;
-		}
-
-		public void setDescription(String description) {
-			this.description = description;
-		}
-
 		public String getName() {
 			return name;
 		}
@@ -334,10 +330,25 @@ public class SwaggerEntity {
 			return schema;
 		}
 
-		public void setSchema(Map<String, Object> schema) {
+		public void setSchema(Object schema) {
 			this.schema = schema;
 		}
 
+		public String getDescription() {
+			return description;
+		}
+
+		public void setDescription(String description) {
+			this.description = description;
+		}
+
+		public Object getExample() {
+			return example;
+		}
+
+		public void setExample(Object example) {
+			this.example = example;
+		}
 	}
 
 	public static class Tag {