File tree 4 files changed +54
-5
lines changed
springdoc-openapi-starter-common/src/main/java/org/springdoc/core
springdoc-openapi-starter-webmvc-api/src/test/java/test/org/springdoc/api/v30/app210
4 files changed +54
-5
lines changed Original file line number Diff line number Diff line change 36
36
import org .springdoc .core .customizers .RouterOperationCustomizer ;
37
37
import org .springdoc .core .filters .OpenApiMethodFilter ;
38
38
39
+ import org .springframework .util .Assert ;
39
40
import org .springframework .util .CollectionUtils ;
40
41
41
- import static org .springdoc .core .utils .Constants .GROUP_NAME_NOT_NULL ;
42
+ import static org .springdoc .core .utils .Constants .GROUP_NAME_NOT_NULL_OR_EMPTY ;
42
43
43
44
/**
44
45
* The type Grouped open api.
@@ -117,7 +118,8 @@ public class GroupedOpenApi {
117
118
* @param builder the builder
118
119
*/
119
120
private GroupedOpenApi (Builder builder ) {
120
- this .group = Objects .requireNonNull (builder .group , GROUP_NAME_NOT_NULL );
121
+ Assert .isTrue (StringUtils .isNotBlank (builder .group ), GROUP_NAME_NOT_NULL_OR_EMPTY );
122
+ this .group =builder .group ;
121
123
this .pathsToMatch = builder .pathsToMatch ;
122
124
this .packagesToScan = builder .packagesToScan ;
123
125
this .producesToMatch = builder .producesToMatch ;
Original file line number Diff line number Diff line change 32
32
import com .fasterxml .jackson .annotation .JsonProperty ;
33
33
import org .apache .commons .lang3 .StringUtils ;
34
34
35
- import static org .springdoc .core .utils .Constants .GROUP_NAME_NOT_NULL ;
35
+ import static org .springdoc .core .utils .Constants .GROUP_NAME_NOT_NULL_OR_EMPTY ;
36
36
37
37
/**
38
38
* Please refer to the swagger
@@ -724,7 +724,7 @@ public SwaggerUrl() {
724
724
* @param displayName the display name
725
725
*/
726
726
public SwaggerUrl (String group , String url , String displayName ) {
727
- Objects .requireNonNull (group , GROUP_NAME_NOT_NULL );
727
+ Objects .requireNonNull (group , GROUP_NAME_NOT_NULL_OR_EMPTY );
728
728
this .url = url ;
729
729
this .name = group ;
730
730
this .displayName = StringUtils .defaultIfEmpty (displayName , this .name );
Original file line number Diff line number Diff line change @@ -243,7 +243,7 @@ public final class Constants {
243
243
/**
244
244
* The constant GROUP_NAME_NOT_NULL.
245
245
*/
246
- public static final String GROUP_NAME_NOT_NULL = "Group name can not be null" ;
246
+ public static final String GROUP_NAME_NOT_NULL_OR_EMPTY = "Group name can not be null or empty " ;
247
247
248
248
/**
249
249
* The constant GET_METHOD.
Original file line number Diff line number Diff line change
1
+ /*
2
+ *
3
+ * *
4
+ * * *
5
+ * * * *
6
+ * * * * * Copyright 2019-2023 the original author or authors.
7
+ * * * * *
8
+ * * * * * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * * * * * you may not use this file except in compliance with the License.
10
+ * * * * * You may obtain a copy of the License at
11
+ * * * * *
12
+ * * * * * https://www.apache.org/licenses/LICENSE-2.0
13
+ * * * * *
14
+ * * * * * Unless required by applicable law or agreed to in writing, software
15
+ * * * * * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * * * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * * * * * See the License for the specific language governing permissions and
18
+ * * * * * limitations under the License.
19
+ * * * *
20
+ * * *
21
+ * *
22
+ *
23
+ */
24
+
25
+ package test .org .springdoc .api .v30 .app210 ;
26
+
27
+ import org .junit .jupiter .api .Test ;
28
+ import org .springdoc .core .models .GroupedOpenApi ;
29
+ import test .org .springdoc .api .AbstractCommonTest ;
30
+
31
+ import org .springframework .boot .autoconfigure .SpringBootApplication ;
32
+ import org .springframework .boot .test .context .SpringBootTest ;
33
+
34
+ import static org .junit .jupiter .api .Assertions .assertThrows ;
35
+
36
+ @ SpringBootTest
37
+ public class SpringDocApp210Test extends AbstractCommonTest {
38
+
39
+ @ Test
40
+ public void testApp (){
41
+ assertThrows (IllegalArgumentException .class , () -> GroupedOpenApi .builder ().group ("" ).build ());
42
+ }
43
+
44
+ @ SpringBootApplication
45
+ static class SpringDocTestApp {}
46
+
47
+ }
You can’t perform that action at this time.
0 commit comments