Skip to content

Commit ab907e1

Browse files
committed
Spring Data Rest: Collection models generated with non-HAL content. fixes #1070
1 parent 9d604b8 commit ab907e1

File tree

9 files changed

+245
-169
lines changed

9 files changed

+245
-169
lines changed

springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/core/DataRestResponseService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ else if ((HttpEntity.class.equals(parameterizedType.getRawType())
254254
}
255255
else if ((CollectionModel.class.equals(parameterizedType.getRawType())
256256
&& Object.class.equals(parameterizedType.getActualTypeArguments()[0]))) {
257-
return ResolvableType.forClassWithGenerics(CollectionModel.class, returnedEntityType).getType();
257+
return resolveGenericType(CollectionModel.class, EntityModel.class, returnedEntityType);
258258
}
259259
}
260260
return returnType;

springdoc-openapi-data-rest/src/test/resources/results/app10.json

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424
"content": {
2525
"application/hal+json": {
2626
"schema": {
27-
"$ref": "#/components/schemas/CollectionModelAccount"
27+
"$ref": "#/components/schemas/CollectionModelEntityModelAccount"
2828
}
2929
},
3030
"application/x-spring-data-compact+json": {
3131
"schema": {
32-
"$ref": "#/components/schemas/CollectionModelAccount"
32+
"$ref": "#/components/schemas/CollectionModelEntityModelAccount"
3333
}
3434
},
3535
"text/uri-list": {
3636
"schema": {
37-
"$ref": "#/components/schemas/CollectionModelAccount"
37+
"$ref": "#/components/schemas/CollectionModelEntityModelAccount"
3838
}
3939
}
4040
}
@@ -517,17 +517,17 @@
517517
"content": {
518518
"application/hal+json": {
519519
"schema": {
520-
"$ref": "#/components/schemas/CollectionModelCustomer"
520+
"$ref": "#/components/schemas/CollectionModelEntityModelCustomer"
521521
}
522522
},
523523
"application/x-spring-data-compact+json": {
524524
"schema": {
525-
"$ref": "#/components/schemas/CollectionModelCustomer"
525+
"$ref": "#/components/schemas/CollectionModelEntityModelCustomer"
526526
}
527527
},
528528
"text/uri-list": {
529529
"schema": {
530-
"$ref": "#/components/schemas/CollectionModelCustomer"
530+
"$ref": "#/components/schemas/CollectionModelEntityModelCustomer"
531531
}
532532
}
533533
}
@@ -934,7 +934,7 @@
934934
}
935935
}
936936
},
937-
"CollectionModelAccount": {
937+
"CollectionModelEntityModelAccount": {
938938
"type": "object",
939939
"properties": {
940940
"_embedded": {
@@ -943,7 +943,7 @@
943943
"accounts": {
944944
"type": "array",
945945
"items": {
946-
"$ref": "#/components/schemas/Account"
946+
"$ref": "#/components/schemas/EntityModelAccount"
947947
}
948948
}
949949
}
@@ -1024,7 +1024,26 @@
10241024
}
10251025
}
10261026
},
1027-
"CollectionModelCustomer": {
1027+
"CollectionModelAccount": {
1028+
"type": "object",
1029+
"properties": {
1030+
"_embedded": {
1031+
"type": "object",
1032+
"properties": {
1033+
"accounts": {
1034+
"type": "array",
1035+
"items": {
1036+
"$ref": "#/components/schemas/Account"
1037+
}
1038+
}
1039+
}
1040+
},
1041+
"_links": {
1042+
"$ref": "#/components/schemas/Links"
1043+
}
1044+
}
1045+
},
1046+
"CollectionModelEntityModelCustomer": {
10281047
"type": "object",
10291048
"properties": {
10301049
"_embedded": {
@@ -1033,7 +1052,7 @@
10331052
"customers": {
10341053
"type": "array",
10351054
"items": {
1036-
"$ref": "#/components/schemas/Customer"
1055+
"$ref": "#/components/schemas/EntityModelCustomer"
10371056
}
10381057
}
10391058
}

springdoc-openapi-data-rest/src/test/resources/results/app11.json

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@
6060
"content": {
6161
"application/hal+json": {
6262
"schema": {
63-
"$ref": "#/components/schemas/CollectionModelPerson"
63+
"$ref": "#/components/schemas/CollectionModelEntityModelPerson"
6464
}
6565
},
6666
"application/x-spring-data-compact+json": {
6767
"schema": {
68-
"$ref": "#/components/schemas/CollectionModelPerson"
68+
"$ref": "#/components/schemas/CollectionModelEntityModelPerson"
6969
}
7070
},
7171
"text/uri-list": {
7272
"schema": {
73-
"$ref": "#/components/schemas/CollectionModelPerson"
73+
"$ref": "#/components/schemas/CollectionModelEntityModelPerson"
7474
}
7575
}
7676
}
@@ -422,18 +422,7 @@
422422
}
423423
}
424424
},
425-
"Person": {
426-
"type": "object",
427-
"properties": {
428-
"firstName": {
429-
"type": "string"
430-
},
431-
"lastName": {
432-
"type": "string"
433-
}
434-
}
435-
},
436-
"CollectionModelPerson": {
425+
"CollectionModelEntityModelPerson": {
437426
"type": "object",
438427
"properties": {
439428
"_embedded": {
@@ -442,7 +431,7 @@
442431
"people": {
443432
"type": "array",
444433
"items": {
445-
"$ref": "#/components/schemas/Person"
434+
"$ref": "#/components/schemas/EntityModelPerson"
446435
}
447436
}
448437
}
@@ -466,6 +455,36 @@
466455
}
467456
}
468457
},
458+
"Person": {
459+
"type": "object",
460+
"properties": {
461+
"firstName": {
462+
"type": "string"
463+
},
464+
"lastName": {
465+
"type": "string"
466+
}
467+
}
468+
},
469+
"CollectionModelPerson": {
470+
"type": "object",
471+
"properties": {
472+
"_embedded": {
473+
"type": "object",
474+
"properties": {
475+
"people": {
476+
"type": "array",
477+
"items": {
478+
"$ref": "#/components/schemas/Person"
479+
}
480+
}
481+
}
482+
},
483+
"_links": {
484+
"$ref": "#/components/schemas/Links"
485+
}
486+
}
487+
},
469488
"Link": {
470489
"type": "object",
471490
"properties": {

0 commit comments

Comments
 (0)