forked from mbknor/mbknor-jackson-jsonSchema
-
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.
mbknor#147 Support concrete base class in polymorphic types
- Loading branch information
1 parent
6bb44c3
commit 1bcc064
Showing
6 changed files
with
479 additions
and
354 deletions.
There are no files selected for viewing
620 changes: 315 additions & 305 deletions
620
src/main/scala/com/kjetland/jackson/jsonSchema/JsonSchemaGenerator.scala
Large diffs are not rendered by default.
Oops, something went wrong.
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
38 changes: 38 additions & 0 deletions
38
src/test/scala/com/kjetland/jackson/jsonSchema/testData/polymorphism7/Child71.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,38 @@ | ||
package com.kjetland.jackson.jsonSchema.testData.polymorphism7; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
|
||
import java.util.Objects; | ||
|
||
@JsonSubTypes({ @JsonSubTypes.Type(value = Child73.class) }) | ||
public class Child71 extends Parent7 { | ||
|
||
public String child1String; | ||
|
||
@JsonProperty("_child1String2") | ||
public String child1String2; | ||
|
||
@JsonProperty(value = "_child1String3", required = true) | ||
public String child1String3; | ||
|
||
public String parentString; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof Child71)) return false; | ||
|
||
Child71 child1 = (Child71) o; | ||
|
||
return Objects.equals(child1String, child1.child1String) | ||
&& Objects.equals(child1String2, child1.child1String2) | ||
&& Objects.equals(child1String3, child1.child1String3) | ||
&& Objects.equals(parentString, child1.parentString); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(child1String, child1String2, child1String3, parentString); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/test/scala/com/kjetland/jackson/jsonSchema/testData/polymorphism7/Child72.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,26 @@ | ||
package com.kjetland.jackson.jsonSchema.testData.polymorphism7; | ||
|
||
import java.util.Objects; | ||
|
||
public class Child72 extends Parent7 { | ||
|
||
public Integer child2int; | ||
|
||
public String parentString; | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (!(o instanceof Child72)) return false; | ||
|
||
Child72 child2 = (Child72) o; | ||
|
||
return Objects.equals(child2int, child2.child2int) | ||
&& Objects.equals(parentString, child2.parentString); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return Objects.hash(child2int, parentString); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/test/scala/com/kjetland/jackson/jsonSchema/testData/polymorphism7/Child73.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,12 @@ | ||
package com.kjetland.jackson.jsonSchema.testData.polymorphism7; | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
|
||
import java.util.Objects; | ||
|
||
public class Child73 extends Child71 { | ||
|
||
@JsonProperty("_child3String") | ||
public String child3String; | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
src/test/scala/com/kjetland/jackson/jsonSchema/testData/polymorphism7/Parent7.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,15 @@ | ||
package com.kjetland.jackson.jsonSchema.testData.polymorphism7; | ||
|
||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
|
||
@JsonTypeInfo( | ||
use = JsonTypeInfo.Id.CLASS, | ||
include = JsonTypeInfo.As.PROPERTY, | ||
property = "polymorphicType") | ||
@JsonSubTypes({ | ||
@JsonSubTypes.Type(value = Child71.class), | ||
@JsonSubTypes.Type(value = Child72.class) }) | ||
public class Parent7 { | ||
|
||
} |