-
-
Notifications
You must be signed in to change notification settings - Fork 558
Open
Description
Describe the bug
HAL _links field is generated incorrectly for a subtype schema extending a schema that extends a RepresentationModel.
_links:
type: array
items:
$ref: "#/components/schemas/Link"To Reproduce
Steps to reproduce the behavior:
- spring-boot version: 3.5.8 (using spring-boot-starter-hateoas and spring-boot-starter-web)
- springdoc-openapi-starter-webmvc-ui version: 2.8.14
Code Snippet:
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.hateoas.RepresentationModel;
@Schema(subTypes = {ExtendedTestDto.class})
public class TestDto extends RepresentationModel<TestDto> {
private String field;
public String getField() {
return field;
}
public void setField(String field) {
this.field = field;
}
}import io.swagger.v3.oas.annotations.media.Schema;
@Schema(allOf = {TestDto.class})
public class ExtendedTestDto extends TestDto {
private String otherField;
public String getOtherField() {
return otherField;
}
public void setOtherField(String otherField) {
this.otherField = otherField;
}
}import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class Controller {
@GetMapping(path = "/hello")
public ExtendedTestDto hello() {
return new ExtendedTestDto();
}
}Expected behavior
The subtype should not have a _links field at all since that field is already in the schema of TestDto.
This worked as expected in springdoc-openapi-starter-webmvc-ui version:2.7.0.
Actual:
ExtendedTestDto:
allOf:
- $ref: "#/components/schemas/TestDto"
- type: object
properties:
otherField:
type: string
_links:
type: array
items:
$ref: "#/components/schemas/Link"Expected:
ExtendedTestDto:
type: object
allOf:
- $ref: "#/components/schemas/TestDto"
- type: object
properties:
otherField:
type: stringMetadata
Metadata
Assignees
Labels
No labels