Skip to content

Commit bcaa257

Browse files
committed
Remove webjars-locator-core #2173
1 parent c53c5bf commit bcaa257

File tree

31 files changed

+257
-509
lines changed

31 files changed

+257
-509
lines changed

pom.xml

-22
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@
6363
<nexus-staging-maven-plugin>1.6.8</nexus-staging-maven-plugin>
6464
<swagger-api.version>2.2.9</swagger-api.version>
6565
<swagger-ui.version>4.18.1</swagger-ui.version>
66-
<classgraph.version>4.8.149</classgraph.version>
67-
<webjars-locator-core.version>0.52</webjars-locator-core.version>
6866
<gmavenplus-plugin.version>1.13.1</gmavenplus-plugin.version>
6967
<jaxb-impl.version>2.1</jaxb-impl.version>
7068
<javax.jws-api.version>1.1</javax.jws-api.version>
@@ -88,26 +86,6 @@
8886
<artifactId>swagger-ui</artifactId>
8987
<version>${swagger-ui.version}</version>
9088
</dependency>
91-
<dependency>
92-
<groupId>org.webjars</groupId>
93-
<artifactId>webjars-locator-core</artifactId>
94-
<version>${webjars-locator-core.version}</version>
95-
<exclusions>
96-
<exclusion>
97-
<groupId>io.github.classgraph</groupId>
98-
<artifactId>classgraph</artifactId>
99-
</exclusion>
100-
<exclusion>
101-
<groupId>com.fasterxml.jackson.core</groupId>
102-
<artifactId>jackson-core</artifactId>
103-
</exclusion>
104-
</exclusions>
105-
</dependency>
106-
<dependency>
107-
<groupId>io.github.classgraph</groupId>
108-
<artifactId>classgraph</artifactId>
109-
<version>${classgraph.version}</version>
110-
</dependency>
11189
<dependency>
11290
<groupId>javax.xml</groupId>
11391
<artifactId>jaxb-impl</artifactId>

springdoc-openapi-starter-common/pom.xml

-6
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,6 @@
7878
<artifactId>querydsl-core</artifactId>
7979
<optional>true</optional>
8080
</dependency>
81-
<!-- classgraph -->
82-
<dependency>
83-
<groupId>io.github.classgraph</groupId>
84-
<artifactId>classgraph</artifactId>
85-
<optional>true</optional>
86-
</dependency>
8781
</dependencies>
8882
<build>
8983
<resources>
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@
4747
* @author bnasslahsen
4848
*/
4949
@Lazy(false)
50-
@ConditionalOnExpression("${springdoc.api-docs.enabled:true} and ${springdoc.enable-native-support:false}")
50+
@ConditionalOnExpression("${springdoc.api-docs.enabled:true}")
5151
@ConditionalOnWebApplication
5252
@Configuration(proxyBeanMethods = false)
5353
@ConditionalOnBean(SpringDocConfiguration.class)
54-
public class SpringDocNativeConfiguration implements InitializingBean {
54+
public class SpringDocUIConfiguration implements InitializingBean {
5555

5656
/**
5757
* The constant SPRINGDOC_CONFIG_PROPERTIES.
@@ -73,7 +73,7 @@ public class SpringDocNativeConfiguration implements InitializingBean {
7373
*
7474
* @param optionalSwaggerUiConfigProperties the swagger ui config properties
7575
*/
76-
public SpringDocNativeConfiguration(Optional<SwaggerUiConfigProperties> optionalSwaggerUiConfigProperties) {
76+
public SpringDocUIConfiguration(Optional<SwaggerUiConfigProperties> optionalSwaggerUiConfigProperties) {
7777
this.optionalSwaggerUiConfigProperties = optionalSwaggerUiConfigProperties;
7878
}
7979

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/hints/SpringDocHints.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
import io.swagger.v3.oas.models.security.Scopes;
7474
import io.swagger.v3.oas.models.servers.ServerVariables;
7575
import org.apache.commons.lang3.reflect.FieldUtils;
76-
import org.springdoc.core.configuration.SpringDocNativeConfiguration;
76+
import org.springdoc.core.configuration.SpringDocUIConfiguration;
7777
import org.springdoc.core.properties.SpringDocConfigProperties.ModelConverters;
7878

7979
import org.springframework.aot.hint.MemberCategory;
@@ -185,7 +185,7 @@ public void registerHints(RuntimeHints hints, ClassLoader classLoader) {
185185
//springdoc
186186
hints.reflection().registerField(FieldUtils.getDeclaredField(io.swagger.v3.core.converter.ModelConverters.class, "converters", true));
187187
hints.reflection().registerType(org.springdoc.core.utils.Constants.class, hint -> hint.withMembers(MemberCategory.DECLARED_FIELDS));
188-
hints.resources().registerPattern(SpringDocNativeConfiguration.SPRINGDOC_CONFIG_PROPERTIES)
188+
hints.resources().registerPattern(SpringDocUIConfiguration.SPRINGDOC_CONFIG_PROPERTIES)
189189
.registerResourceBundle("sun.util.resources.LocaleNames");
190190
}
191191

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/configuration/hints/SpringDocUiHints.java

-52
This file was deleted.

springdoc-openapi-starter-common/src/main/java/org/springdoc/core/properties/SpringDocConfigProperties.java

-24
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,6 @@ public class SpringDocConfigProperties {
212212
*/
213213
private boolean enableKotlin = true;
214214

215-
/**
216-
* The Enable native support.
217-
*/
218-
private boolean enableNativeSupport = false;
219-
220215
/**
221216
* The Enable hateoas.
222217
*/
@@ -373,25 +368,6 @@ public void setEnableHateoas(boolean enableHateoas) {
373368
this.enableHateoas = enableHateoas;
374369
}
375370

376-
/**
377-
* Is enable native support boolean.
378-
*
379-
* @return the boolean
380-
*/
381-
public boolean isEnableNativeSupport() {
382-
return enableNativeSupport;
383-
}
384-
385-
/**
386-
* Sets enable native support.
387-
*
388-
* @param enableNativeSupport the enable native support
389-
*/
390-
public void setEnableNativeSupport(boolean enableNativeSupport) {
391-
this.enableNativeSupport = enableNativeSupport;
392-
}
393-
394-
395371
/**
396372
* Is enable kotlin boolean.
397373
*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package org.springdoc.ui;
2+
3+
import java.io.File;
4+
5+
6+
import org.springdoc.core.properties.SwaggerUiConfigProperties;
7+
8+
import org.springframework.lang.Nullable;
9+
10+
/**
11+
* The type Web jars version resource resolver.
12+
*
13+
* @author bnasslahsen
14+
*/
15+
public class AbstractSwaggerResourceResolver {
16+
17+
/**
18+
* The Swagger ui config properties.
19+
*/
20+
private final SwaggerUiConfigProperties swaggerUiConfigProperties;
21+
22+
/**
23+
* Instantiates a new Web jars version resource resolver.
24+
*
25+
* @param swaggerUiConfigProperties the swagger ui config properties
26+
*/
27+
public AbstractSwaggerResourceResolver(SwaggerUiConfigProperties swaggerUiConfigProperties) {
28+
this.swaggerUiConfigProperties = swaggerUiConfigProperties;
29+
}
30+
31+
/**
32+
* Find web jar resource path string.
33+
*
34+
* @param path the path
35+
* @return the string
36+
*/
37+
@Nullable
38+
protected String findWebJarResourcePath(String path) {
39+
String webjar = webjar(path);
40+
if (webjar.length() > 0) {
41+
String version = swaggerUiConfigProperties.getVersion();
42+
if (version != null) {
43+
String partialPath = path(webjar, path);
44+
return webjar + File.separator + version + File.separator + partialPath;
45+
}
46+
}
47+
return null;
48+
}
49+
50+
/**
51+
* Webjar string.
52+
*
53+
* @param path the path
54+
* @return the string
55+
*/
56+
private String webjar(String path) {
57+
int startOffset = (path.startsWith("/") ? 1 : 0);
58+
int endOffset = path.indexOf('/', 1);
59+
return endOffset != -1 ? path.substring(startOffset, endOffset) : path;
60+
}
61+
62+
63+
/**
64+
* Path string.
65+
*
66+
* @param webjar the webjar
67+
* @param path the path
68+
* @return the string
69+
*/
70+
private String path(String webjar, String path) {
71+
if (path.startsWith(webjar)) {
72+
path = path.substring(webjar.length() + 1);
73+
}
74+
return path;
75+
}
76+
}

springdoc-openapi-starter-common/src/main/java/org/springdoc/ui/AbstractSwaggerWelcome.java

+3-13
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,14 @@
3333
import org.springframework.util.CollectionUtils;
3434
import org.springframework.web.util.UriComponentsBuilder;
3535

36-
import static org.springdoc.core.utils.Constants.INDEX_PAGE;
37-
import static org.springdoc.core.utils.Constants.OAUTH_REDIRECT_PAGE;
3836
import static org.springdoc.core.utils.Constants.SWAGGER_UI_OAUTH_REDIRECT_URL;
39-
import static org.springdoc.core.utils.Constants.SWAGGER_UI_PREFIX;
4037
import static org.springdoc.core.utils.Constants.SWAGGER_UI_URL;
4138
import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR;
4239

4340

4441
/**
4542
* The type Abstract swagger welcome.
43+
*
4644
* @author bnasslashen
4745
*/
4846
public abstract class AbstractSwaggerWelcome {
@@ -224,12 +222,7 @@ protected void calculateUiRootCommon(StringBuilder sbUrl, StringBuilder[] sbUrls
224222
* @return the oauth2 redirect url
225223
*/
226224
protected String getOauth2RedirectUrl() {
227-
if (StringUtils.isNotEmpty(swaggerUiConfig.getVersion())) {
228-
return StringUtils.defaultIfBlank(swaggerUiConfig.getOauth2RedirectUrl(), SWAGGER_UI_PREFIX + DEFAULT_PATH_SEPARATOR + swaggerUiConfig.getVersion() + OAUTH_REDIRECT_PAGE);
229-
}
230-
else {
231-
return StringUtils.defaultIfBlank(swaggerUiConfig.getOauth2RedirectUrl(), SWAGGER_UI_OAUTH_REDIRECT_URL);
232-
}
225+
return StringUtils.defaultIfBlank(swaggerUiConfig.getOauth2RedirectUrl(), SWAGGER_UI_OAUTH_REDIRECT_URL);
233226
}
234227

235228
/**
@@ -238,9 +231,6 @@ protected String getOauth2RedirectUrl() {
238231
* @return the swagger ui url
239232
*/
240233
protected String getSwaggerUiUrl() {
241-
if (StringUtils.isNotEmpty(swaggerUiConfig.getVersion()))
242-
return SWAGGER_UI_PREFIX + DEFAULT_PATH_SEPARATOR + swaggerUiConfig.getVersion() + INDEX_PAGE;
243-
else
244-
return SWAGGER_UI_URL;
234+
return SWAGGER_UI_URL;
245235
}
246236
}

springdoc-openapi-starter-common/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ org.springdoc.core.configuration.SpringDocJavadocConfiguration
44
org.springdoc.core.configuration.SpringDocGroovyConfiguration
55
org.springdoc.core.configuration.SpringDocSecurityConfiguration
66
org.springdoc.core.configuration.SpringDocFunctionCatalogConfiguration
7-
org.springdoc.core.configuration.SpringDocNativeConfiguration
87
org.springdoc.core.configuration.SpringDocHateoasConfiguration
98
org.springdoc.core.configuration.SpringDocPageableConfiguration
109
org.springdoc.core.configuration.SpringDocSortConfiguration

springdoc-openapi-starter-webflux-ui/pom.xml

-8
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@
1818
<groupId>org.webjars</groupId>
1919
<artifactId>swagger-ui</artifactId>
2020
</dependency>
21-
<dependency>
22-
<groupId>org.webjars</groupId>
23-
<artifactId>webjars-locator-core</artifactId>
24-
</dependency>
25-
<dependency>
26-
<groupId>io.github.classgraph</groupId>
27-
<artifactId>classgraph</artifactId>
28-
</dependency>
2921
<!-- Actuator dependencies -->
3022
<dependency>
3123
<groupId>org.springframework.boot</groupId>

springdoc-openapi-starter-webflux-ui/src/main/java/org/springdoc/webflux/ui/SwaggerConfig.java

+25-2
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,16 @@ SwaggerUiHome swaggerUiHome(Optional<WebFluxProperties> optionalWebFluxPropertie
121121
* @param springDocConfigProperties the spring doc config properties
122122
* @param swaggerIndexTransformer the swagger index transformer
123123
* @param actuatorProvider the actuator provider
124+
* @param swaggerResourceResolver the swagger resource resolver
124125
* @return the swagger web flux configurer
125126
*/
126127
@Bean
127128
@ConditionalOnMissingBean
128129
@Lazy(false)
129-
SwaggerWebFluxConfigurer swaggerWebFluxConfigurer(SwaggerUiConfigParameters swaggerUiConfigParameters, SpringDocConfigProperties springDocConfigProperties, SwaggerIndexTransformer swaggerIndexTransformer, Optional<ActuatorProvider> actuatorProvider) {
130-
return new SwaggerWebFluxConfigurer(swaggerUiConfigParameters, springDocConfigProperties, swaggerIndexTransformer, actuatorProvider);
130+
SwaggerWebFluxConfigurer swaggerWebFluxConfigurer(SwaggerUiConfigParameters swaggerUiConfigParameters,
131+
SpringDocConfigProperties springDocConfigProperties, SwaggerIndexTransformer swaggerIndexTransformer,
132+
Optional<ActuatorProvider> actuatorProvider, SwaggerResourceResolver swaggerResourceResolver) {
133+
return new SwaggerWebFluxConfigurer(swaggerUiConfigParameters, springDocConfigProperties, swaggerIndexTransformer, actuatorProvider, swaggerResourceResolver);
131134
}
132135

133136
/**
@@ -173,6 +176,26 @@ SpringWebProvider springWebProvider() {
173176
return new SpringWebFluxProvider();
174177
}
175178

179+
/**
180+
* Swagger resource resolver swagger resource resolver.
181+
*
182+
* @param swaggerUiConfigProperties the swagger ui config properties
183+
* @return the swagger resource resolver
184+
*/
185+
186+
/**
187+
* Swagger resource resolver swagger resource resolver.
188+
*
189+
* @param swaggerUiConfigProperties the swagger ui config properties
190+
* @return the swagger resource resolver
191+
*/
192+
@Bean
193+
@ConditionalOnMissingBean
194+
@Lazy(false)
195+
SwaggerResourceResolver swaggerResourceResolver(SwaggerUiConfigProperties swaggerUiConfigProperties) {
196+
return new SwaggerResourceResolver(swaggerUiConfigProperties);
197+
}
198+
176199
/**
177200
* The type Swagger actuator welcome configuration.
178201
* @author bnasslashen

0 commit comments

Comments
 (0)