-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
786 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
wegas-core/src/main/java/com/wegas/editor/JSONSchema/JSONArray.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.wegas.editor.JSONSchema; | ||
|
||
public class JSONArray extends JSONType { | ||
private JSONSchema items; | ||
private Integer minItems; | ||
private Integer maxItems; | ||
|
||
/** | ||
* @return the items | ||
*/ | ||
public JSONSchema getItems() { | ||
return items; | ||
} | ||
|
||
/** | ||
* @return the maxItems | ||
*/ | ||
public Integer getMaxItems() { | ||
return maxItems; | ||
} | ||
|
||
/** | ||
* @param maxItems the maxItems to set | ||
*/ | ||
public void setMaxItems(Integer maxItems) { | ||
this.maxItems = maxItems; | ||
} | ||
|
||
/** | ||
* @return the minItems | ||
*/ | ||
public Integer getMinItems() { | ||
return minItems; | ||
} | ||
|
||
/** | ||
* @param minItems the minItems to set | ||
*/ | ||
public void setMinItems(Integer minItems) { | ||
this.minItems = minItems; | ||
} | ||
|
||
/** | ||
* @param items the items to set | ||
*/ | ||
public void setItems(JSONSchema items) { | ||
this.items = items; | ||
} | ||
|
||
@Override | ||
final public String getType() { | ||
return "array"; | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
wegas-core/src/main/java/com/wegas/editor/JSONSchema/JSONBoolean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.wegas.editor.JSONSchema; | ||
|
||
public class JSONBoolean extends JSONType { | ||
|
||
@Override | ||
final public String getType() { | ||
return "boolean"; | ||
} | ||
|
||
} |
10 changes: 10 additions & 0 deletions
10
wegas-core/src/main/java/com/wegas/editor/JSONSchema/JSONNumber.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.wegas.editor.JSONSchema; | ||
|
||
public class JSONNumber extends JSONType { | ||
|
||
@Override | ||
final public String getType() { | ||
return "number"; | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
wegas-core/src/main/java/com/wegas/editor/JSONSchema/JSONObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package com.wegas.editor.JSONSchema; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class JSONObject extends JSONType { | ||
private Map<String, JSONSchema> properties; | ||
private JSONSchema additionalProperties; | ||
|
||
/** | ||
* @return the additionalProperties | ||
*/ | ||
public JSONSchema getAdditionalProperties() { | ||
return additionalProperties; | ||
} | ||
|
||
/** | ||
* @param additionalProperties the additionalProperties to set | ||
*/ | ||
public void setAdditionalProperties(JSONSchema additionalProperties) { | ||
this.additionalProperties = additionalProperties; | ||
} | ||
|
||
/** | ||
* @return the properties | ||
*/ | ||
public Map<String, JSONSchema> getProperties() { | ||
return properties; | ||
} | ||
|
||
/** | ||
* @param prop the property name | ||
* @param value the value | ||
*/ | ||
public void setProperty(String prop, JSONSchema value) { | ||
if (this.properties == null) { | ||
this.properties = new HashMap<>(); | ||
} | ||
this.properties.put(prop, value); | ||
} | ||
|
||
@Override | ||
final public String getType() { | ||
return "object"; | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
wegas-core/src/main/java/com/wegas/editor/JSONSchema/JSONRef.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.wegas.editor.JSONSchema; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
public class JSONRef implements JSONSchema { | ||
@JsonProperty("$ref") | ||
private String ref; | ||
|
||
public JSONRef(String ref) { | ||
this.ref = ref; | ||
} | ||
|
||
/** | ||
* @return the ref | ||
*/ | ||
public String getRef() { | ||
return ref; | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
wegas-core/src/main/java/com/wegas/editor/JSONSchema/JSONSchema.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package com.wegas.editor.JSONSchema; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public interface JSONSchema { | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
wegas-core/src/main/java/com/wegas/editor/JSONSchema/JSONString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.wegas.editor.JSONSchema; | ||
|
||
public class JSONString extends JSONType { | ||
|
||
@Override | ||
final public String getType() { | ||
return "string"; | ||
} | ||
} |
78 changes: 78 additions & 0 deletions
78
wegas-core/src/main/java/com/wegas/editor/JSONSchema/JSONType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package com.wegas.editor.JSONSchema; | ||
|
||
import java.util.List; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public abstract class JSONType implements JSONSchema { | ||
abstract String getType(); | ||
|
||
private JsonNode value; | ||
|
||
@JsonProperty("enum") | ||
private List<JsonNode> enums; | ||
|
||
@JsonProperty("const") | ||
private JsonNode constant; | ||
|
||
private String description; | ||
|
||
/** | ||
* @return the description | ||
*/ | ||
public String getDescription() { | ||
return description; | ||
} | ||
|
||
/** | ||
* @param description the description to set | ||
*/ | ||
public void setDescription(String description) { | ||
this.description = description; | ||
} | ||
|
||
/** | ||
* @return the enums (enum) | ||
*/ | ||
public List<JsonNode> getEnums() { | ||
return enums; | ||
} | ||
|
||
/** | ||
* @param enums the enums to set (enum) | ||
*/ | ||
public void setEnums(List<JsonNode> enums) { | ||
this.enums = enums; | ||
} | ||
|
||
/** | ||
* @return the value | ||
*/ | ||
public JsonNode getValue() { | ||
return value; | ||
} | ||
|
||
/** | ||
* @param value the value to set | ||
*/ | ||
public void setValue(JsonNode value) { | ||
this.value = value; | ||
} | ||
|
||
/** | ||
* @return the constant (const) | ||
*/ | ||
public JsonNode getConstant() { | ||
return constant; | ||
} | ||
|
||
/** | ||
* @param constant the constant to set (const) | ||
*/ | ||
public void setConstant(JsonNode constant) { | ||
this.constant = constant; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
wegas-core/src/main/java/com/wegas/editor/JSONSchema/JSONUnknown.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.wegas.editor.JSONSchema; | ||
|
||
public final class JSONUnknown extends JSONType { | ||
|
||
@Override | ||
public String getType() { | ||
return null; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.wegas.editor; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Repeatable; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import com.wegas.editor.JSONSchema.JSONSchema; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.TYPE }) | ||
@Inherited | ||
@Repeatable(Schemas.class) | ||
public @interface Schema { | ||
Class<? extends JSONSchema> value(); | ||
|
||
String property(); | ||
|
||
/** | ||
* Shallow merge, default true | ||
*/ | ||
boolean merge() default true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.wegas.editor; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ ElementType.TYPE }) | ||
@Inherited | ||
public @interface Schemas { | ||
Schema[] value(); | ||
} |
Oops, something went wrong.