-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from axonivy/conditional
allow @conditional on property, that asserts a sibling value
- Loading branch information
Showing
3 changed files
with
133 additions
and
5 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
...sive-annotations/src/main/java/io/github/axonivy/json/schema/annotations/Conditional.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,37 @@ | ||
package io.github.axonivy.json.schema.annotations; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Repeatable; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Documents fields which only will be present, if a sibling has a certain value. | ||
* | ||
* @see "https://json-schema.org/understanding-json-schema/reference/conditionals.html" | ||
* @see Condition | ||
* | ||
*/ | ||
@Repeatable(Conditional.List.class) | ||
@Target({ElementType.FIELD}) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
public @interface Conditional { | ||
|
||
/** | ||
* @return the 'name' of a sibling property to asserted | ||
*/ | ||
public String ifProperty(); | ||
|
||
/** | ||
* @return the 'value' to assert on the field | ||
*/ | ||
public String[] hasConst(); | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({ElementType.FIELD}) | ||
@interface List { | ||
Conditional[] value(); | ||
} | ||
|
||
} |
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