Skip to content

Commit

Permalink
Use title for oneOf union strategy
Browse files Browse the repository at this point in the history
Use `title` to improve generated documentation for the `oneOf` union
strategy. Without `title` tools see an inlined (unnamed) object.
  • Loading branch information
connorjs authored and mtdowling committed Jul 7, 2020
1 parent 986b389 commit 1eb18cd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ public Schema unionShape(UnionShape shape) {
String memberName = converter.toPropertyName(member);
schemas.add(Schema.builder()
.type("object")
.title(memberName)
.required(ListUtils.of(memberName))
.putProperty(memberName, createRef(member))
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"oneOf": [
{
"type": "object",
"title": "a",
"required": [
"a"
],
Expand All @@ -125,6 +126,7 @@
},
{
"type": "object",
"title": "b",
"required": [
"b"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
"oneOf": [
{
"type": "object",
"title": "a",
"properties": {
"a": {
"type": "string"
Expand All @@ -214,6 +215,7 @@
},
{
"type": "object",
"title": "b",
"properties": {
"b": {
"type": "string"
Expand Down

0 comments on commit 1eb18cd

Please sign in to comment.