Skip to content

Commit f62cbb2

Browse files
committed
code review + upgrade spring-boot to 2.6.4 and spring-native 0.11.3
1 parent 0c28581 commit f62cbb2

File tree

5 files changed

+51
-27
lines changed

5 files changed

+51
-27
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<parent>
1212
<groupId>org.springframework.boot</groupId>
1313
<artifactId>spring-boot-starter-parent</artifactId>
14-
<version>2.6.2</version>
14+
<version>2.6.4</version>
1515
</parent>
1616

1717
<licenses>
@@ -77,7 +77,7 @@
7777
<jaxb-impl.version>2.1</jaxb-impl.version>
7878
<javax.jws-api.version>1.1</javax.jws-api.version>
7979
<jjwt.version>0.9.1</jjwt.version>
80-
<spring-native.version>0.11.1</spring-native.version>
80+
<spring-native.version>0.11.3</spring-native.version>
8181
<therapi-runtime-javadoc.version>0.13.0</therapi-runtime-javadoc.version>
8282
<spring-cloud.version>2021.0.0</spring-cloud.version>
8383
<spring-cloud-netflix.version>2.2.10.RELEASE</spring-cloud-netflix.version>

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

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

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

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

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

104-
/**
105-
* The constant LOGGER.
106-
*/
107-
private static final Logger LOGGER = LoggerFactory.getLogger(GenericResponseService.class);
108-
109104
/**
110105
* The Response entity exception handler class.
111106
*/
112107
private static Class<?> responseEntityExceptionHandlerClass;
113108

114-
static {
115-
try {
116-
responseEntityExceptionHandlerClass = Class.forName("org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler");
117-
}
118-
catch (ClassNotFoundException classNotFoundException) {
119-
LOGGER.trace(classNotFoundException.getMessage());
120-
}
121-
}
122-
123109
/**
124110
* Instantiates a new Generic response builder.
125111
*
@@ -628,4 +614,12 @@ private boolean isHttpCodePresent(String httpCode, Set<io.swagger.v3.oas.annotat
628614
return !responseSet.isEmpty() && responseSet.stream().anyMatch(apiResponseAnnotations -> httpCode.equals(apiResponseAnnotations.responseCode()));
629615
}
630616

617+
/**
618+
* Sets response entity exception handler class.
619+
*
620+
* @param responseEntityExceptionHandlerClass the response entity exception handler class
621+
*/
622+
public static void setResponseEntityExceptionHandlerClass(Class<?> responseEntityExceptionHandlerClass) {
623+
GenericResponseService.responseEntityExceptionHandlerClass = responseEntityExceptionHandlerClass;
624+
}
631625
}

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,5 +299,27 @@ public SpringDocUtils replaceParameterObjectWithClass(Class source, Class target
299299
AdditionalModelsConverter.replaceParameterObjectWithClass(source, target);
300300
return this;
301301
}
302+
303+
/**
304+
* Sets response entity exception handler class.
305+
*
306+
* @param clazz the clazz
307+
* @return the response entity exception handler class
308+
*/
309+
public SpringDocUtils setResponseEntityExceptionHandlerClass(Class<?> clazz) {
310+
GenericResponseService.setResponseEntityExceptionHandlerClass(clazz);
311+
return this;
312+
}
313+
314+
/**
315+
* Sets model and view class.
316+
*
317+
* @param clazz the clazz
318+
* @return the model and view class
319+
*/
320+
public SpringDocUtils setModelAndViewClass(Class<?> clazz) {
321+
AbstractOpenApiResource.setModelAndViewClass(clazz);
322+
return this;
323+
}
302324
}
303325

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,13 @@
5959
import org.springframework.context.annotation.Configuration;
6060
import org.springframework.context.annotation.Lazy;
6161
import org.springframework.core.LocalVariableTableParameterNameDiscoverer;
62+
import org.springframework.web.servlet.ModelAndView;
6263
import org.springframework.web.servlet.function.RouterFunction;
64+
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;
6365

6466
import static org.springdoc.core.Constants.SPRINGDOC_ENABLED;
6567
import static org.springdoc.core.Constants.SPRINGDOC_USE_MANAGEMENT_PORT;
68+
import static org.springdoc.core.SpringDocUtils.getConfig;
6669

6770
/**
6871
* The type Spring doc web mvc configuration.
@@ -74,6 +77,11 @@
7477
@ConditionalOnProperty(name = SPRINGDOC_ENABLED, matchIfMissing = true)
7578
public class SpringDocWebMvcConfiguration {
7679

80+
static {
81+
getConfig().setResponseEntityExceptionHandlerClass(ResponseEntityExceptionHandler.class)
82+
.setModelAndViewClass(ModelAndView.class);
83+
}
84+
7785
/**
7886
* Open api resource open api resource.
7987
*
@@ -132,7 +140,7 @@ RequestService requestBuilder(GenericParameterService parameterBuilder, RequestB
132140
@Bean
133141
@ConditionalOnMissingBean
134142
@Lazy(false)
135-
SpringWebProvider springWebProvider(){
143+
SpringWebProvider springWebProvider() {
136144
return new SpringWebMvcProvider();
137145
}
138146

@@ -237,7 +245,7 @@ OpenApiActuatorResource openApiActuatorResource(ObjectFactory<OpenAPIService> op
237245
return new OpenApiActuatorResource(openAPIBuilderObjectFactory,
238246
requestBuilder, responseBuilder,
239247
operationParser,
240-
operationCustomizers, openApiCustomisers,methodFilters,
248+
operationCustomizers, openApiCustomisers, methodFilters,
241249
springDocConfigProperties, springDocProviders);
242250
}
243251
}

0 commit comments

Comments
 (0)