-
-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Polymorphic fields on polymorphic parents don't get correct oneOf doc…
…s generated. Fixes #2597
- Loading branch information
1 parent
8a1e0ad
commit 935b984
Showing
10 changed files
with
666 additions
and
202 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
23 changes: 23 additions & 0 deletions
23
...i-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/ARestController.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,23 @@ | ||
package test.org.springdoc.api.v30.app223; | ||
|
||
|
||
import test.org.springdoc.api.v30.app223.apiobjects.AbstractChild; | ||
import test.org.springdoc.api.v30.app223.apiobjects.AbstractParent; | ||
import test.org.springdoc.api.v30.app223.apiobjects.Response; | ||
|
||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class ARestController { | ||
@PostMapping("/parent") | ||
public Response parentEndpoint(@RequestBody AbstractParent parent) { | ||
return null; | ||
} | ||
|
||
@PostMapping("/child") | ||
public Response childEndpoint(@RequestBody AbstractChild child) { | ||
return null; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...arter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/SpringDocApp223Test.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,35 @@ | ||
/* | ||
* | ||
* * | ||
* * * | ||
* * * * | ||
* * * * * Copyright 2019-2022 the original author or authors. | ||
* * * * * | ||
* * * * * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * * * * you may not use this file except in compliance with the License. | ||
* * * * * You may obtain a copy of the License at | ||
* * * * * | ||
* * * * * https://www.apache.org/licenses/LICENSE-2.0 | ||
* * * * * | ||
* * * * * Unless required by applicable law or agreed to in writing, software | ||
* * * * * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * * * * See the License for the specific language governing permissions and | ||
* * * * * limitations under the License. | ||
* * * * | ||
* * * | ||
* * | ||
* | ||
*/ | ||
|
||
package test.org.springdoc.api.v30.app223; | ||
|
||
import test.org.springdoc.api.v30.AbstractSpringDocV30Test; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
|
||
public class SpringDocApp223Test extends AbstractSpringDocV30Test { | ||
|
||
@SpringBootApplication | ||
static class SpringDocTestApp {} | ||
} |
61 changes: 61 additions & 0 deletions
61
...-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/apiobjects/AbstractChild.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,61 @@ | ||
package test.org.springdoc.api.v30.app223.apiobjects; | ||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonSubTypes.Type; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; | ||
|
||
@JsonTypeInfo(use = Id.NAME, property = "type") | ||
@JsonSubTypes({ | ||
@Type(ChildType1.class), | ||
@Type(ChildType2.class) | ||
}) | ||
public abstract class AbstractChild { | ||
private int id; | ||
|
||
public AbstractChild(int id) { | ||
this.id = id; | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
} | ||
|
||
class ChildType1 extends AbstractChild { | ||
private String childType1Param; | ||
|
||
public ChildType1(int id, String childType1Param) { | ||
super(id); | ||
this.childType1Param = childType1Param; | ||
} | ||
|
||
public String getChildType1Param() { | ||
return childType1Param; | ||
} | ||
|
||
public void setChildType1Param(String childType1Param) { | ||
this.childType1Param = childType1Param; | ||
} | ||
} | ||
|
||
class ChildType2 extends AbstractChild { | ||
private String childType2Param; | ||
|
||
public ChildType2(int id, String childType2Param) { | ||
super(id); | ||
this.childType2Param = childType2Param; | ||
} | ||
|
||
public String getChildType2Param() { | ||
return childType2Param; | ||
} | ||
|
||
public void setChildType2Param(String childType2Param) { | ||
this.childType2Param = childType2Param; | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
...webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/apiobjects/AbstractParent.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,72 @@ | ||
package test.org.springdoc.api.v30.app223.apiobjects; | ||
|
||
import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
import com.fasterxml.jackson.annotation.JsonSubTypes.Type; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id; | ||
|
||
|
||
@JsonTypeInfo(use = Id.NAME, property = "type") | ||
@JsonSubTypes({ | ||
@Type(ParentType1.class), | ||
@Type(ParentType2.class) | ||
}) | ||
public abstract class AbstractParent { | ||
private int id; | ||
|
||
public AbstractParent(int id) { | ||
this.id = id; | ||
} | ||
|
||
public int getId() { | ||
return id; | ||
} | ||
|
||
public void setId(int id) { | ||
this.id = id; | ||
} | ||
} | ||
|
||
class ParentType1 extends AbstractParent { | ||
private String parentType1Param; | ||
private AbstractChild abstractChild; | ||
|
||
public ParentType1(int id, String parentType1Param, AbstractChild abstractChild) { | ||
super(id); | ||
this.parentType1Param = parentType1Param; | ||
this.abstractChild = abstractChild; | ||
} | ||
|
||
public String getParentType1Param() { | ||
return parentType1Param; | ||
} | ||
|
||
public void setParentType1Param(String parentType1Param) { | ||
this.parentType1Param = parentType1Param; | ||
} | ||
|
||
public AbstractChild getAbstractChild() { | ||
return abstractChild; | ||
} | ||
|
||
public void setAbstractChild(AbstractChild abstractChild) { | ||
this.abstractChild = abstractChild; | ||
} | ||
} | ||
|
||
class ParentType2 extends AbstractParent { | ||
private String parentType2Param; | ||
|
||
public ParentType2(int id, String parentType2Param) { | ||
super(id); | ||
this.parentType2Param = parentType2Param; | ||
} | ||
|
||
public String getParentType2Param() { | ||
return parentType2Param; | ||
} | ||
|
||
public void setParentType2Param(String parentType2Param) { | ||
this.parentType2Param = parentType2Param; | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
...arter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app223/apiobjects/Response.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,4 @@ | ||
package test.org.springdoc.api.v30.app223.apiobjects; | ||
|
||
public record Response(AbstractParent abstractParent, AbstractChild abstractChild) { | ||
} |
Oops, something went wrong.