File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 4 files changed +54
-5
lines changed Original file line number Diff line number Diff line change 3636import org .springdoc .core .customizers .RouterOperationCustomizer ;
3737import org .springdoc .core .filters .OpenApiMethodFilter ;
3838
39+ import org .springframework .util .Assert ;
3940import org .springframework .util .CollectionUtils ;
4041
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 ;
4243
4344/**
4445 * The type Grouped open api.
@@ -117,7 +118,8 @@ public class GroupedOpenApi {
117118 * @param builder the builder
118119 */
119120 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 ;
121123 this .pathsToMatch = builder .pathsToMatch ;
122124 this .packagesToScan = builder .packagesToScan ;
123125 this .producesToMatch = builder .producesToMatch ;
Original file line number Diff line number Diff line change 3232import com .fasterxml .jackson .annotation .JsonProperty ;
3333import org .apache .commons .lang3 .StringUtils ;
3434
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 ;
3636
3737/**
3838 * Please refer to the swagger
@@ -724,7 +724,7 @@ public SwaggerUrl() {
724724 * @param displayName the display name
725725 */
726726 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 );
728728 this .url = url ;
729729 this .name = group ;
730730 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 {
243243 /**
244244 * The constant GROUP_NAME_NOT_NULL.
245245 */
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 " ;
247247
248248 /**
249249 * 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