Skip to content

Commit fc942ba

Browse files
author
bnasslahsen
committed
code review
1 parent 4a9810e commit fc942ba

File tree

4 files changed

+82
-78
lines changed

4 files changed

+82
-78
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/core/RequestBodyBuilder.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ public Optional<RequestBody> buildRequestBodyFromDoc(
9191

9292
private void buildResquestBodyContent(io.swagger.v3.oas.annotations.parameters.RequestBody requestBody, RequestBody requestBodyOp, MethodAttributes methodAttributes, Components components, JsonView jsonViewAnnotation, String[] classConsumes, String[] methodConsumes, RequestBody requestBodyObject) {
9393
Optional<Content> optionalContent = AnnotationsUtils
94-
.getContent(requestBody.content(), classConsumes == null ? new String[0] : classConsumes,
95-
methodConsumes == null ? new String[0] : methodConsumes, null, components, jsonViewAnnotation);
94+
.getContent(requestBody.content(), getConsumes(classConsumes),
95+
getConsumes(methodConsumes), null, components, jsonViewAnnotation);
9696
if (requestBodyOp == null)
9797
optionalContent.ifPresent(requestBodyObject::setContent);
9898
else {
@@ -112,6 +112,10 @@ private void buildResquestBodyContent(io.swagger.v3.oas.annotations.parameters.R
112112
}
113113
}
114114

115+
private String[] getConsumes(String[] classConsumes) {
116+
return classConsumes == null ? new String[0] : classConsumes;
117+
}
118+
115119
public Optional<RequestBody> buildRequestBodyFromDoc(io.swagger.v3.oas.annotations.parameters.RequestBody requestBody,
116120
MethodAttributes methodAttributes, Components components) {
117121
return this.buildRequestBodyFromDoc(requestBody, null, methodAttributes,

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,20 @@ public DataRestTagsBuilder(OpenAPIBuilder openAPIBuilder) {
3939

4040
public void buildSearchTags(Operation operation, OpenAPI openAPI, HandlerMethod handlerMethod,
4141
Class<?> domainType) {
42-
buildTags(operation, openAPI, handlerMethod, domainType, "RepositorySearch", "Search");
42+
buildTags(operation, openAPI, handlerMethod, domainType);
4343
}
4444

4545
public void buildEntityTags(Operation operation, OpenAPI openAPI, HandlerMethod handlerMethod,
4646
Class<?> domainType) {
47-
buildTags(operation, openAPI, handlerMethod, domainType, "RepositoryEntity", "Entity");
47+
buildTags(operation, openAPI, handlerMethod, domainType);
4848
}
4949

5050
private void buildTags(Operation operation, OpenAPI openAPI, HandlerMethod handlerMethod,
51-
Class<?> domainType, String searchString, String replacement) {
51+
Class<?> domainType) {
5252
if (openAPIBuilder.isAutoTagClasses(operation)) {
5353
String tagName = handlerMethod.getBeanType().getSimpleName();
5454
if (domainType != null)
55-
tagName = tagName.replace(searchString, domainType.getSimpleName() + replacement);
55+
tagName = tagName.replace("Repository", domainType.getSimpleName());
5656
operation.addTagsItem(OpenAPIBuilder.splitCamelCase(tagName));
5757
}
5858
openAPIBuilder.buildTags(handlerMethod, operation, openAPI);

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

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@
256256
"/accounts/{id}/{property}": {
257257
"get": {
258258
"tags": [
259-
"repository-property-reference-controller"
259+
"account-property-reference-controller"
260260
],
261261
"description": "get-account",
262262
"operationId": "followPropertyReference-account-get_1",
@@ -301,7 +301,7 @@
301301
},
302302
"put": {
303303
"tags": [
304-
"repository-property-reference-controller"
304+
"account-property-reference-controller"
305305
],
306306
"description": "update-account",
307307
"operationId": "createPropertyReference-account-put",
@@ -370,7 +370,7 @@
370370
},
371371
"post": {
372372
"tags": [
373-
"repository-property-reference-controller"
373+
"account-property-reference-controller"
374374
],
375375
"description": "create-account",
376376
"operationId": "createPropertyReference-account-post",
@@ -426,7 +426,7 @@
426426
},
427427
"delete": {
428428
"tags": [
429-
"repository-property-reference-controller"
429+
"account-property-reference-controller"
430430
],
431431
"description": "delete-account",
432432
"operationId": "deletePropertyReference-account-delete",
@@ -459,7 +459,7 @@
459459
},
460460
"patch": {
461461
"tags": [
462-
"repository-property-reference-controller"
462+
"account-property-reference-controller"
463463
],
464464
"description": "patch-account",
465465
"operationId": "createPropertyReference-account-patch",
@@ -520,7 +520,7 @@
520520
"/accounts/{id}/{property}/{propertyId}": {
521521
"get": {
522522
"tags": [
523-
"repository-property-reference-controller"
523+
"account-property-reference-controller"
524524
],
525525
"description": "get-account",
526526
"operationId": "followPropertyReference-account-get",
@@ -568,7 +568,7 @@
568568
},
569569
"delete": {
570570
"tags": [
571-
"repository-property-reference-controller"
571+
"account-property-reference-controller"
572572
],
573573
"description": "delete-account",
574574
"operationId": "deletePropertyReferenceId-account-delete",
@@ -862,7 +862,7 @@
862862
"/customers/{id}/{property}": {
863863
"get": {
864864
"tags": [
865-
"repository-property-reference-controller"
865+
"customer-property-reference-controller"
866866
],
867867
"description": "get-customer",
868868
"operationId": "followPropertyReference-customer-get_1",
@@ -907,7 +907,7 @@
907907
},
908908
"put": {
909909
"tags": [
910-
"repository-property-reference-controller"
910+
"customer-property-reference-controller"
911911
],
912912
"description": "update-customer",
913913
"operationId": "createPropertyReference-customer-put",
@@ -976,7 +976,7 @@
976976
},
977977
"post": {
978978
"tags": [
979-
"repository-property-reference-controller"
979+
"customer-property-reference-controller"
980980
],
981981
"description": "create-customer",
982982
"operationId": "createPropertyReference-customer-post",
@@ -1032,7 +1032,7 @@
10321032
},
10331033
"patch": {
10341034
"tags": [
1035-
"repository-property-reference-controller"
1035+
"customer-property-reference-controller"
10361036
],
10371037
"description": "patch-customer",
10381038
"operationId": "createPropertyReference-customer-patch",
@@ -1093,7 +1093,7 @@
10931093
"/customers/{id}/{property}/{propertyId}": {
10941094
"get": {
10951095
"tags": [
1096-
"repository-property-reference-controller"
1096+
"customer-property-reference-controller"
10971097
],
10981098
"description": "get-customer",
10991099
"operationId": "followPropertyReference-customer-get",
@@ -1303,38 +1303,15 @@
13031303
}
13041304
}
13051305
},
1306-
"Account": {
1307-
"type": "object",
1308-
"properties": {
1309-
"id": {
1310-
"type": "integer",
1311-
"format": "int64"
1312-
},
1313-
"customer": {
1314-
"$ref": "#/components/schemas/Customer"
1315-
},
1316-
"expiryDate": {
1317-
"type": "string",
1318-
"format": "date-time"
1319-
}
1320-
}
1321-
},
1322-
"Customer": {
1306+
"RepresentationModelAccount": {
13231307
"type": "object",
13241308
"properties": {
1325-
"id": {
1326-
"type": "integer",
1327-
"format": "int64"
1328-
},
1329-
"firstname": {
1330-
"type": "string"
1331-
},
1332-
"lastname": {
1333-
"type": "string"
1309+
"_links": {
1310+
"$ref": "#/components/schemas/Links"
13341311
}
13351312
}
13361313
},
1337-
"EntityModelAccount": {
1314+
"Account": {
13381315
"type": "object",
13391316
"properties": {
13401317
"id": {
@@ -1347,22 +1324,19 @@
13471324
"expiryDate": {
13481325
"type": "string",
13491326
"format": "date-time"
1350-
},
1351-
"_links": {
1352-
"$ref": "#/components/schemas/Links"
13531327
}
13541328
}
13551329
},
1356-
"CollectionModelObject": {
1330+
"CollectionModelAccount": {
13571331
"type": "object",
13581332
"properties": {
13591333
"_embedded": {
13601334
"type": "object",
13611335
"properties": {
1362-
"objects": {
1336+
"accounts": {
13631337
"type": "array",
13641338
"items": {
1365-
"type": "object"
1339+
"$ref": "#/components/schemas/Account"
13661340
}
13671341
}
13681342
}
@@ -1372,24 +1346,31 @@
13721346
}
13731347
}
13741348
},
1375-
"RepresentationModelAccount": {
1349+
"Customer": {
13761350
"type": "object",
13771351
"properties": {
1378-
"_links": {
1379-
"$ref": "#/components/schemas/Links"
1352+
"id": {
1353+
"type": "integer",
1354+
"format": "int64"
1355+
},
1356+
"firstname": {
1357+
"type": "string"
1358+
},
1359+
"lastname": {
1360+
"type": "string"
13801361
}
13811362
}
13821363
},
1383-
"CollectionModelAccount": {
1364+
"CollectionModelObject": {
13841365
"type": "object",
13851366
"properties": {
13861367
"_embedded": {
13871368
"type": "object",
13881369
"properties": {
1389-
"accounts": {
1370+
"objects": {
13901371
"type": "array",
13911372
"items": {
1392-
"$ref": "#/components/schemas/Account"
1373+
"type": "object"
13931374
}
13941375
}
13951376
}
@@ -1399,18 +1380,19 @@
13991380
}
14001381
}
14011382
},
1402-
"EntityModelCustomer": {
1383+
"EntityModelAccount": {
14031384
"type": "object",
14041385
"properties": {
14051386
"id": {
14061387
"type": "integer",
14071388
"format": "int64"
14081389
},
1409-
"firstname": {
1410-
"type": "string"
1390+
"customer": {
1391+
"$ref": "#/components/schemas/Customer"
14111392
},
1412-
"lastname": {
1413-
"type": "string"
1393+
"expiryDate": {
1394+
"type": "string",
1395+
"format": "date-time"
14141396
},
14151397
"_links": {
14161398
"$ref": "#/components/schemas/Links"
@@ -1444,6 +1426,24 @@
14441426
}
14451427
}
14461428
},
1429+
"EntityModelCustomer": {
1430+
"type": "object",
1431+
"properties": {
1432+
"id": {
1433+
"type": "integer",
1434+
"format": "int64"
1435+
},
1436+
"firstname": {
1437+
"type": "string"
1438+
},
1439+
"lastname": {
1440+
"type": "string"
1441+
},
1442+
"_links": {
1443+
"$ref": "#/components/schemas/Links"
1444+
}
1445+
}
1446+
},
14471447
"PageMetadata": {
14481448
"type": "object",
14491449
"properties": {

0 commit comments

Comments
 (0)