58
58
59
59
import org .springframework .beans .factory .config .BeanDefinition ;
60
60
import org .springframework .boot .autoconfigure .AutoConfigurationPackages ;
61
- import org .springframework .boot .autoconfigure .web .servlet .error .BasicErrorController ;
62
61
import org .springframework .context .ApplicationContext ;
63
62
import org .springframework .context .annotation .ClassPathScanningCandidateComponentProvider ;
64
63
import org .springframework .core .annotation .AnnotatedElementUtils ;
@@ -167,7 +166,7 @@ public class OpenAPIService {
167
166
this .securityParser = securityParser ;
168
167
this .springDocConfigProperties = springDocConfigProperties ;
169
168
this .openApiBuilderCustomisers = openApiBuilderCustomisers ;
170
- if (springDocConfigProperties .isUseFqn ())
169
+ if (springDocConfigProperties .isUseFqn ())
171
170
TypeNameResolver .std .setUseFqn (true );
172
171
}
173
172
@@ -223,12 +222,28 @@ else if (calculatedOpenAPI.getInfo() == null) {
223
222
}
224
223
225
224
private void initializeHiddenRestController () {
226
- getConfig ().addHiddenRestControllers (BasicErrorController .class );
225
+ Class basicErrorController = null ;
226
+ try {
227
+ //spring-boot 2
228
+ basicErrorController = Class .forName ("org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController" );
229
+ }
230
+ catch (ClassNotFoundException e ) {
231
+ //spring-boot 1
232
+ try {
233
+ basicErrorController = Class .forName ("org.springframework.boot.autoconfigure.web.BasicErrorController" );
234
+ }
235
+ catch (ClassNotFoundException classNotFoundException ) {
236
+ //Basic error controller class not found
237
+ LOGGER .warn (classNotFoundException .getMessage ());
238
+ }
239
+ }
240
+ if (basicErrorController != null )
241
+ getConfig ().addHiddenRestControllers (basicErrorController );
227
242
List <Class <?>> hiddenRestControllers = this .mappingsMap .entrySet ().parallelStream ()
228
243
.filter (controller -> (AnnotationUtils .findAnnotation (controller .getValue ().getClass (),
229
244
Hidden .class ) != null )).map (controller -> controller .getValue ().getClass ())
230
245
.collect (Collectors .toList ());
231
- if (!CollectionUtils .isEmpty (hiddenRestControllers ))
246
+ if (!CollectionUtils .isEmpty (hiddenRestControllers ))
232
247
getConfig ().addHiddenRestControllers (hiddenRestControllers .toArray (new Class <?>[hiddenRestControllers .size ()]));
233
248
}
234
249
@@ -239,7 +254,7 @@ private void initializeHiddenRestController() {
239
254
* @return the open api
240
255
*/
241
256
public OpenAPI updateServers (OpenAPI openAPI ) {
242
- if (!isServersPresent && serverBaseUrl != null ) // default server value
257
+ if (!isServersPresent && serverBaseUrl != null ) // default server value
243
258
{
244
259
Server server = new Server ().url (serverBaseUrl ).description (DEFAULT_SERVER_DESCRIPTION );
245
260
List <Server > servers = new ArrayList <>();
0 commit comments