You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have defined a custom extension to EntityModel i.e to provide custom behaviour
public class HalEntityModel<T> extends EntityModel<T> { ... }
Our API uses this class in its responses on the API. A typical controller method looks like this
@Operation(summary = "Gets clients. Used to view clients in the system ") @GetMapping() public PagedModel<HalEntityModel<ClientDTO>> findClient( ... ) { ... }
Actual behavior
Schema Generated for the return type this looks like this. Noting the Embedded Property Name is "halEntityModels"
Resolution
The issue has been tracked down to the following line of code inside Class : CollectionModelContentConverter : lIne 89 if (containerEntityType.isAssignableFrom(EntityModel.class)) {
the line should read if ( EntityModel.class.isAssignableFrom(containerEntityType) ) {
The issue is since the containerEntity type (at runtime) is referring to the HalEntityModel class which extends EntityModel. The line of code as written, evaluates to false since Entity Model cannot be assigned to a Sub class. However in the corrected code the expression is true because HalEntityModel is a subtype of Entity Model.
Additional context
This has been tested and return the Schema in the expected format
The text was updated successfully, but these errors were encountered:
Describe the bug
To Reproduce
We are using the following modules
Steps to reproduce the behavior:
public class HalEntityModel<T> extends EntityModel<T> { ... }
@Operation(summary = "Gets clients. Used to view clients in the system ") @GetMapping() public PagedModel<HalEntityModel<ClientDTO>> findClient( ... ) { ... }
Actual behavior
Schema Generated for the return type this looks like this. Noting the Embedded Property Name is "halEntityModels"
Expected behavior
The expected result is as below noting the Embedded Property Name is "clients"
Resolution
The issue has been tracked down to the following line of code inside Class : CollectionModelContentConverter : lIne 89
if (containerEntityType.isAssignableFrom(EntityModel.class)) {
the line should read
if ( EntityModel.class.isAssignableFrom(containerEntityType) ) {
The issue is since the containerEntity type (at runtime) is referring to the HalEntityModel class which extends EntityModel. The line of code as written, evaluates to false since Entity Model cannot be assigned to a Sub class. However in the corrected code the expression is true because HalEntityModel is a subtype of Entity Model.
Additional context
This has been tested and return the Schema in the expected format
The text was updated successfully, but these errors were encountered: