Skip to content

Commit 2ac3482

Browse files
committed
code review
1 parent b432293 commit 2ac3482

File tree

7 files changed

+20
-27
lines changed

7 files changed

+20
-27
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public class DataRestRepository {
6969
/**
7070
* The Persistent entity.
7171
*/
72-
PersistentEntity<?, ?> persistentEntity;
72+
private PersistentEntity persistentEntity;
7373

7474
/**
7575
* Instantiates a new Data rest repository.
@@ -215,7 +215,7 @@ public void setPropertyType(Class<?> propertyType) {
215215
*
216216
* @return the persistent entity
217217
*/
218-
public PersistentEntity<?, ?> getPersistentEntity() {
218+
public PersistentEntity getPersistentEntity() {
219219
return persistentEntity;
220220
}
221221

@@ -224,7 +224,7 @@ public void setPropertyType(Class<?> propertyType) {
224224
*
225225
* @param persistentEntity the persistent entity
226226
*/
227-
public void setPersistentEntity(PersistentEntity<?, ?> persistentEntity) {
227+
public void setPersistentEntity(PersistentEntity persistentEntity) {
228228
this.persistentEntity = persistentEntity;
229229
}
230230

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ else if (methodParameter.getParameterAnnotation(BackendId.class) != null) {
175175
}
176176
parameter = requestBuilder.buildParams(parameterInfo, openAPI.getComponents(), requestMethod, null);
177177

178-
addParameters(openAPI, requestMethod, methodAttributes, operation, methodParameter, parameterInfo, parameter, resourceMetadata, dataRestRepository);
178+
addParameters(openAPI, requestMethod, methodAttributes, operation, methodParameter, parameterInfo, parameter);
179179
}
180180
}
181181
}
@@ -214,11 +214,9 @@ private boolean isParamToIgnore(MethodParameter methodParameter) {
214214
* @param methodParameter the method parameter
215215
* @param parameterInfo the parameter info
216216
* @param parameter the parameter
217-
* @param resourceMetadata the resource metadata
218-
* @param dataRestRepository the data rest repository
219217
*/
220-
private void addParameters(OpenAPI openAPI, RequestMethod requestMethod, MethodAttributes methodAttributes, Operation operation, MethodParameter methodParameter,
221-
ParameterInfo parameterInfo, Parameter parameter, ResourceMetadata resourceMetadata, DataRestRepository dataRestRepository) {
218+
private void addParameters(OpenAPI openAPI, RequestMethod requestMethod, MethodAttributes methodAttributes, Operation operation,
219+
MethodParameter methodParameter, ParameterInfo parameterInfo, Parameter parameter) {
222220
List<Annotation> parameterAnnotations = Arrays.asList(methodParameter.getParameterAnnotations());
223221
if (requestBuilder.isValidParameter(parameter)) {
224222
requestBuilder.applyBeanValidatorAnnotations(parameter, parameterAnnotations);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@
5959
import org.springframework.web.bind.annotation.RequestMethod;
6060
import org.springframework.web.method.HandlerMethod;
6161

62-
;
63-
6462
/**
6563
* The type Data rest response builder.
6664
* @author bnasslahsen

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,7 @@ else if (ControllerType.PROPERTY.equals(controllerType))
320320
* @param requestMethod the request method
321321
* @return the boolean
322322
*/
323-
private boolean isSearchControllerPresent(RequestMappingInfo
324-
requestMappingInfo, HandlerMethod handlerMethod, RequestMethod requestMethod) {
323+
private boolean isSearchControllerPresent(RequestMappingInfo requestMappingInfo, HandlerMethod handlerMethod, RequestMethod requestMethod) {
325324
if (!UNDOCUMENTED_REQUEST_METHODS.contains(requestMethod)) {
326325
Set<String> patterns = getActivePatterns(requestMappingInfo);
327326
if (!CollectionUtils.isEmpty(patterns)) {

springdoc-openapi-data-rest/src/main/java/org/springdoc/data/rest/utils/SpringDocDataRestUtils.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ private void updateRequestBodySchema(String className, Schema schema, Components
192192
referencedSchema.addProperties(propId, new StringSchema());
193193
}
194194
}
195-
} if (referencedSchema instanceof ComposedSchema)
195+
}
196+
if (referencedSchema instanceof ComposedSchema)
196197
updateComposedSchema((ComposedSchema) referencedSchema, REQUEST_BODY, components);
197198
});
198199
}
@@ -312,15 +313,13 @@ private void updateKey(List<Schema> allSchemas, String suffix, Components compon
312313
if (!allKey.endsWith(REQUEST_BODY) && !allKey.endsWith(RESPONSE)) {
313314
String newAllKey = allKey + suffix;
314315
allSchema.set$ref(newAllKey);
315-
if (components!=null && !components.getSchemas().containsKey(newAllKey)) {
316-
if (entityInoMap.containsKey(allKey)) {
317-
if (RESPONSE.equals(suffix))
318-
createNewResponseSchema(allKey, components);
319-
}
316+
if (components != null && !components.getSchemas().containsKey(newAllKey) && entityInoMap.containsKey(allKey) && RESPONSE.equals(suffix)) {
317+
createNewResponseSchema(allKey, components);
320318
}
321319
}
322320
}
323321
}
322+
324323
}
325324

326325
/**
@@ -354,12 +353,12 @@ private List<String> getIgnoredFields(ResourceMetadata
354353
if (entity != null && entity.getIdProperty() != null) {
355354
String idField = entity.getIdProperty().getName();
356355
ignoredFields.add(idField);
356+
entity.doWithAssociations((SimpleAssociationHandler) association -> {
357+
PersistentProperty<?> property = association.getInverse();
358+
String filedName = resourceMetadata.getMappingFor(property).getRel().value();
359+
ignoredFields.add(filedName);
360+
});
357361
}
358-
entity.doWithAssociations((SimpleAssociationHandler) association -> {
359-
PersistentProperty<?> property = association.getInverse();
360-
String filedName = resourceMetadata.getMappingFor(property).getRel().value();
361-
ignoredFields.add(filedName);
362-
});
363362
return ignoredFields;
364363
}
365364

@@ -369,7 +368,7 @@ private List<String> getIgnoredFields(ResourceMetadata
369368
* @param content the content
370369
*/
371370
public void buildTextUriContent(Content content) {
372-
if (content.get(RestMediaTypes.TEXT_URI_LIST_VALUE) != null)
371+
if (content.containsKey(RestMediaTypes.TEXT_URI_LIST_VALUE))
373372
content.put(RestMediaTypes.TEXT_URI_LIST_VALUE, new MediaType().schema(new StringSchema()));
374373
}
375374

springdoc-openapi-data-rest/src/test/java/test/org/springdoc/api/app25/repo/ClinicRepo.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import java.util.UUID;
44

5-
65
import test.org.springdoc.api.app25.model.Clinic;
76

87
import org.springframework.data.repository.CrudRepository;

springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/app150/HelloController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818

1919
package test.org.springdoc.api.app150;
2020

21-
import static org.springframework.format.annotation.DateTimeFormat.ISO.DATE;
22-
2321
import java.time.LocalDate;
2422
import java.util.List;
2523

@@ -34,6 +32,8 @@
3432
import org.springframework.web.bind.annotation.ResponseStatus;
3533
import org.springframework.web.bind.annotation.RestController;
3634

35+
import static org.springframework.format.annotation.DateTimeFormat.ISO.DATE;
36+
3737
@RestController
3838
public class HelloController {
3939

0 commit comments

Comments
 (0)