Skip to content

Commit ee6f06b

Browse files
committed
fixed duplicate tag groups
1 parent ab11678 commit ee6f06b

File tree

13 files changed

+47
-94
lines changed

13 files changed

+47
-94
lines changed

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ springfox.version=1.0.0
8282
__Full example__
8383
```java
8484
@EnableSpringfox(
85-
conventionMode = false,
85+
convention = false,
8686
swaggerUiBasePath = "",
8787
includeControllers = MyController.class,
8888
value = @Info(
@@ -98,8 +98,7 @@ __Full example__
9898
)
9999
```
100100

101-
* Use __conventionMode__ to print better names on the swagger-ui page. It will alter the tags (the name of the groups).
102-
It will remove _Controller_ at the end of the text if it is present. Additionally, it will split the operation name by
101+
* Use __convention__ to print better names on the swagger-ui page. It will split the operation name by
103102
replacing camelcase with space and uppercasing the word (for example the method `getCustomer()` will be displayed as `Get customer`).
104103
If the `@ApiOperation` annotation is present, these values will be used.
105104
* __swaggerUiBasePath__ customize the base path to swagger-ui. If the value is for example '/documentation', the path to swagger-ui will be '/documentation/swagger-ui.html'.
@@ -124,7 +123,7 @@ __Application properties__
124123
* springfox.contact.email
125124
* springfox.license.name
126125
* springfox.license.url
127-
* springfox.activeProfiles - _Enable springfox for the configured profiles. If not set, all profiles loads springfox. Default is all profiles._
126+
* springfox.profiles - _Enable springfox for the configured profiles. If not set, all profiles loads springfox. Default is all profiles._
128127
* springfox.swagger-ui-base-path
129128

130129
### Swagger UI

src/main/java/com/github/springfox/loader/ActiveProfilesCondition.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ public class ActiveProfilesCondition implements Condition {
99
@Override
1010
public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
1111
Environment environment = conditionContext.getEnvironment();
12-
String[] profiles = environment.getProperty("springfox.activeProfiles", String[].class);
12+
String[] profiles = environment.getProperty("springfox.profiles", String[].class);
1313
return profiles == null || profiles.length == 0 || environment.acceptsProfiles(profiles);
1414
}
1515
}

src/main/java/com/github/springfox/loader/EnableSpringfox.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
String swaggerUiBasePath() default "";
2121

22-
boolean conventionMode() default true;
22+
boolean convention() default true;
2323

2424
Class<?>[] includeControllers() default {};
2525

src/main/java/com/github/springfox/loader/SpringfoxLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ String getLicenseUrl() {
9999
return val(license.url(), loaderProps.getLicenseUrl());
100100
}
101101

102-
boolean conventionMode() {
103-
return annotation.conventionMode();
102+
boolean convention() {
103+
return annotation.convention();
104104
}
105105

106106
String swaggerUiBasePath() {

src/main/java/com/github/springfox/loader/SpringfoxLoaderConfig.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.github.springfox.loader;
22

33
import com.github.springfox.loader.plugins.LoaderOperationPlugin;
4-
import com.github.springfox.loader.plugins.LoaderTagProvider;
54
import io.swagger.annotations.Extension;
65
import io.swagger.annotations.ExtensionProperty;
76
import org.springframework.beans.BeansException;
@@ -15,18 +14,14 @@
1514
import org.springframework.util.StringValueResolver;
1615
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
1716
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
18-
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
17+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
1918
import springfox.documentation.RequestHandler;
2019
import springfox.documentation.builders.PathSelectors;
2120
import springfox.documentation.builders.RequestHandlerSelectors;
22-
import springfox.documentation.service.ApiInfo;
23-
import springfox.documentation.service.ObjectVendorExtension;
24-
import springfox.documentation.service.StringVendorExtension;
25-
import springfox.documentation.service.VendorExtension;
21+
import springfox.documentation.service.*;
2622
import springfox.documentation.spi.DocumentationType;
2723
import springfox.documentation.spring.web.plugins.ApiSelectorBuilder;
2824
import springfox.documentation.spring.web.plugins.Docket;
29-
import springfox.documentation.spring.web.readers.operation.DefaultTagsProvider;
3025

3126
import java.util.Arrays;
3227
import java.util.Collections;
@@ -37,7 +32,7 @@
3732
@EnableConfigurationProperties
3833
@Configuration
3934
@ComponentScan(basePackageClasses = SpringfoxLoaderConfig.class)
40-
public class SpringfoxLoaderConfig implements WebMvcConfigurer, ApplicationContextAware, EmbeddedValueResolverAware {
35+
public class SpringfoxLoaderConfig extends WebMvcConfigurerAdapter implements ApplicationContextAware, EmbeddedValueResolverAware {
4136

4237
private SpringfoxLoader springfoxLoader = new SpringfoxLoader();
4338

@@ -96,17 +91,10 @@ private List<VendorExtension> getVendorExtensions() {
9691
}).collect(Collectors.toList());
9792
}
9893

99-
@Bean
100-
@Primary
101-
@Conditional(ActiveProfilesCondition.class)
102-
public DefaultTagsProvider loaderDefaultTagsProvider() {
103-
return new LoaderTagProvider(springfoxLoader.conventionMode());
104-
}
105-
10694
@Bean
10795
@Conditional(ActiveProfilesCondition.class)
10896
public LoaderOperationPlugin loaderOperationPlugin() {
109-
return new LoaderOperationPlugin(springfoxLoader.conventionMode());
97+
return new LoaderOperationPlugin(springfoxLoader.convention());
11098
}
11199

112100
@Override

src/main/java/com/github/springfox/loader/plugins/LoaderOperationPlugin.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010

1111
@Order(SwaggerPluginSupport.SWAGGER_PLUGIN_ORDER)
1212
public class LoaderOperationPlugin implements OperationBuilderPlugin {
13-
private final boolean conventionMode;
13+
private final boolean convention;
1414

15-
public LoaderOperationPlugin(boolean conventionMode) {
16-
this.conventionMode = conventionMode;
15+
public LoaderOperationPlugin(boolean convention) {
16+
this.convention = convention;
1717
}
1818

1919
@Override
2020
public void apply(OperationContext operationContext) {
21-
if (conventionMode) {
21+
if (convention) {
2222
String summary = operationContext.operationBuilder().build().getSummary();
2323
String newSummary = Paths.splitCamelCase(summary, " ").toLowerCase();
2424
operationContext.operationBuilder().summary(StringUtils.capitalize(newSummary));

src/main/java/com/github/springfox/loader/plugins/LoaderTagProvider.java

Lines changed: 0 additions & 26 deletions
This file was deleted.

src/test/groovy/com/github/springfox/loader/plugins/LoaderOperationPluginSpec.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class LoaderOperationPluginSpec extends Specification {
2121
}
2222
}
2323

24-
def "Update summary when creating LoaderOperationPlugin with conventionMode enabled"() {
24+
def "Update summary when creating LoaderOperationPlugin with convention enabled"() {
2525
when:
2626
def plugin = new LoaderOperationPlugin(true)
2727
plugin.apply(context)
@@ -30,7 +30,7 @@ class LoaderOperationPluginSpec extends Specification {
3030
1 * builder.summary('My test')
3131
}
3232

33-
def "Do not update summary when creating LoaderOperationPlugin with conventionMode disabled"() {
33+
def "Do not update summary when creating LoaderOperationPlugin with convention disabled"() {
3434
when:
3535
def plugin = new LoaderOperationPlugin(false)
3636
plugin.apply(context)

src/test/groovy/com/github/springfox/loader/plugins/LoaderTagProviderSpec.groovy

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/test/groovy/com/github/springfox/loader/testutils/TestApplication.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import io.swagger.annotations.Extension;
55
import io.swagger.annotations.ExtensionProperty;
66
import io.swagger.annotations.Info;
7+
import org.springframework.boot.SpringApplication;
78
import org.springframework.boot.autoconfigure.SpringBootApplication;
89

910
@EnableSpringfox(
@@ -15,4 +16,8 @@
1516
swaggerUiBasePath = "/docs", includeControllers = TestController.class)
1617
@SpringBootApplication
1718
public class TestApplication {
19+
20+
public static void main(String[] args) {
21+
SpringApplication.run(TestApplication.class, args);
22+
}
1823
}

0 commit comments

Comments
 (0)