Skip to content

Commit 187f55b

Browse files
committed
Changes report: code review + upgrade spring-boot to 2.6.4 and spring-native 0.11.3
1 parent 8876780 commit 187f55b

File tree

5 files changed

+49
-24
lines changed

5 files changed

+49
-24
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<jaxb-impl.version>2.1</jaxb-impl.version>
7070
<javax.jws-api.version>1.1</javax.jws-api.version>
7171
<jjwt.version>0.9.1</jjwt.version>
72-
<spring-native.version>0.11.1</spring-native.version>
72+
<spring-native.version>0.11.3</spring-native.version>
7373
<therapi-runtime-javadoc.version>0.13.0</therapi-runtime-javadoc.version>
7474
<spring-cloud-function.version>4.0.0-M1</spring-cloud-function.version>
7575
</properties>

springdoc-openapi-starter-common/src/main/java/org/springdoc/api/AbstractOpenApiResource.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,6 @@ public abstract class AbstractOpenApiResource extends SpecFilter {
212212
*/
213213
protected final SpringDocProviders springDocProviders;
214214

215-
static {
216-
try {
217-
modelAndViewClass = Class.forName("org.springframework.web.servlet.ModelAndView");
218-
}
219-
catch (ClassNotFoundException classNotFoundException) {
220-
LOGGER.trace(classNotFoundException.getMessage());
221-
}
222-
}
223-
224215
/**
225216
* Instantiates a new Abstract open api resource.
226217
* @param groupName the group name
@@ -1326,4 +1317,13 @@ private void sortOutput(ObjectMapper objectMapper) {
13261317
objectMapper.addMixIn(OpenAPI.class, SortedOpenAPIMixin.class);
13271318
objectMapper.addMixIn(Schema.class, SortedSchemaMixin.class);
13281319
}
1320+
1321+
/**
1322+
* Sets model and view class.
1323+
*
1324+
* @param modelAndViewClass the model and view class
1325+
*/
1326+
public static void setModelAndViewClass(Class<?> modelAndViewClass) {
1327+
AbstractOpenApiResource.modelAndViewClass = modelAndViewClass;
1328+
}
13291329
}

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/service/GenericResponseService.java

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -109,25 +109,11 @@ public class GenericResponseService {
109109
*/
110110
private List<ControllerAdviceInfo> controllerAdviceInfos = new ArrayList<>();
111111

112-
/**
113-
* The constant LOGGER.
114-
*/
115-
private static final Logger LOGGER = LoggerFactory.getLogger(GenericResponseService.class);
116-
117112
/**
118113
* The Response entity exception handler class.
119114
*/
120115
private static Class<?> responseEntityExceptionHandlerClass;
121116

122-
static {
123-
try {
124-
responseEntityExceptionHandlerClass = Class.forName("org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler");
125-
}
126-
catch (ClassNotFoundException classNotFoundException) {
127-
LOGGER.trace(classNotFoundException.getMessage());
128-
}
129-
}
130-
131117
/**
132118
* Instantiates a new Generic response builder.
133119
*
@@ -636,4 +622,12 @@ private boolean isHttpCodePresent(String httpCode, Set<io.swagger.v3.oas.annotat
636622
return !responseSet.isEmpty() && responseSet.stream().anyMatch(apiResponseAnnotations -> httpCode.equals(apiResponseAnnotations.responseCode()));
637623
}
638624

625+
/**
626+
* Sets response entity exception handler class.
627+
*
628+
* @param responseEntityExceptionHandlerClass the response entity exception handler class
629+
*/
630+
public static void setResponseEntityExceptionHandlerClass(Class<?> responseEntityExceptionHandlerClass) {
631+
GenericResponseService.responseEntityExceptionHandlerClass = responseEntityExceptionHandlerClass;
632+
}
639633
}

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/utils/SpringDocUtils.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.springdoc.core.extractor.MethodParameterPojoExtractor;
3434
import org.springdoc.core.service.AbstractRequestService;
3535
import org.springdoc.core.service.GenericParameterService;
36+
import org.springdoc.core.service.GenericResponseService;
3637

3738
/**
3839
* The type Spring doc utils.
@@ -304,5 +305,28 @@ public SpringDocUtils replaceParameterObjectWithClass(Class source, Class target
304305
AdditionalModelsConverter.replaceParameterObjectWithClass(source, target);
305306
return this;
306307
}
308+
309+
310+
/**
311+
* Sets response entity exception handler class.
312+
*
313+
* @param clazz the clazz
314+
* @return the response entity exception handler class
315+
*/
316+
public SpringDocUtils setResponseEntityExceptionHandlerClass(Class<?> clazz) {
317+
GenericResponseService.setResponseEntityExceptionHandlerClass(clazz);
318+
return this;
319+
}
320+
321+
/**
322+
* Sets model and view class.
323+
*
324+
* @param clazz the clazz
325+
* @return the model and view class
326+
*/
327+
public SpringDocUtils setModelAndViewClass(Class<?> clazz) {
328+
AbstractOpenApiResource.setModelAndViewClass(clazz);
329+
return this;
330+
}
307331
}
308332

springdoc-openapi-starter-webmvc-api/src/main/java/org/springdoc/webmvc/core/configuration/SpringDocWebMvcConfiguration.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,13 @@
6565
import org.springframework.context.annotation.Configuration;
6666
import org.springframework.context.annotation.Lazy;
6767
import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
68+
import org.springframework.web.servlet.ModelAndView;
6869
import org.springframework.web.servlet.function.RouterFunction;
70+
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
6971

7072
import static org.springdoc.core.utils.Constants.SPRINGDOC_ENABLED;
7173
import static org.springdoc.core.utils.Constants.SPRINGDOC_USE_MANAGEMENT_PORT;
74+
import static org.springdoc.core.utils.SpringDocUtils.getConfig;
7275

7376
/**
7477
* The type Spring doc web mvc configuration.
@@ -80,6 +83,10 @@
8083
@ConditionalOnProperty(name = SPRINGDOC_ENABLED, matchIfMissing = true)
8184
public class SpringDocWebMvcConfiguration {
8285

86+
static {
87+
getConfig().setResponseEntityExceptionHandlerClass(ResponseEntityExceptionHandler.class)
88+
.setModelAndViewClass(ModelAndView.class);
89+
}
8390
/**
8491
* Open api resource open api resource.
8592
*

0 commit comments

Comments
 (0)