2323import springfox .documentation .spi .DocumentationType ;
2424import springfox .documentation .spring .web .plugins .Docket ;
2525
26- import java .util .ArrayList ;
27- import java .util .LinkedList ;
28- import java .util .List ;
29- import java .util .Set ;
26+ import java .util .*;
3027import java .util .stream .Collectors ;
3128
3229/**
@@ -171,6 +168,10 @@ public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
171168 private List <Parameter > buildGlobalOperationParametersFromSwaggerProperties (
172169 List <SwaggerProperties .GlobalOperationParameter > globalOperationParameters ) {
173170 List <Parameter > parameters = Lists .newArrayList ();
171+
172+ if (Objects .isNull (globalOperationParameters )) {
173+ return parameters ;
174+ }
174175 for (SwaggerProperties .GlobalOperationParameter globalOperationParameter : globalOperationParameters ) {
175176 parameters .add (new ParameterBuilder ()
176177 .name (globalOperationParameter .getName ())
@@ -194,7 +195,7 @@ private List<Parameter> assemblyGlobalOperationParameters(
194195 List <SwaggerProperties .GlobalOperationParameter > globalOperationParameters ,
195196 List <SwaggerProperties .GlobalOperationParameter > docketOperationParameters ) {
196197
197- if (docketOperationParameters == null || docketOperationParameters .isEmpty ()) {
198+ if (Objects . isNull ( docketOperationParameters ) || docketOperationParameters .isEmpty ()) {
198199 return buildGlobalOperationParametersFromSwaggerProperties (globalOperationParameters );
199200 }
200201
@@ -204,11 +205,14 @@ private List<Parameter> assemblyGlobalOperationParameters(
204205
205206 List <SwaggerProperties .GlobalOperationParameter > resultOperationParameters = Lists .newArrayList ();
206207
207- for (SwaggerProperties .GlobalOperationParameter parameter : globalOperationParameters ) {
208- if (!docketNames .contains (parameter .getName ())) {
209- resultOperationParameters .add (parameter );
208+ if (Objects .nonNull (globalOperationParameters )) {
209+ for (SwaggerProperties .GlobalOperationParameter parameter : globalOperationParameters ) {
210+ if (!docketNames .contains (parameter .getName ())) {
211+ resultOperationParameters .add (parameter );
212+ }
210213 }
211214 }
215+
212216 resultOperationParameters .addAll (docketOperationParameters );
213217 return buildGlobalOperationParametersFromSwaggerProperties (resultOperationParameters );
214218 }
0 commit comments