Skip to content

Commit 6725f08

Browse files
committed
Add support for spring-native 0.11-RC1. (remove property springdoc.enable-native-image-support and introduce new springdoc module). Fixes #1328
1 parent 3483389 commit 6725f08

File tree

18 files changed

+309
-137
lines changed

18 files changed

+309
-137
lines changed

pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
<module>springdoc-openapi-ui</module>
6262
<module>springdoc-openapi-webflux-ui</module>
6363
<module>springdoc-openapi-javadoc</module>
64+
<module>springdoc-openapi-native</module>
6465
</modules>
6566

6667
<properties>
@@ -76,7 +77,7 @@
7677
<jaxb-impl.version>2.1</jaxb-impl.version>
7778
<javax.jws-api.version>1.1</javax.jws-api.version>
7879
<jjwt.version>0.9.1</jjwt.version>
79-
<spring-native.version>0.10.1</spring-native.version>
80+
<spring-native.version>0.11.0-RC1</spring-native.version>
8081
<therapi-runtime-javadoc.version>0.12.0</therapi-runtime-javadoc.version>
8182
</properties>
8283

springdoc-openapi-common/pom.xml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,19 +46,8 @@
4646
<artifactId>spring-boot-starter-actuator</artifactId>
4747
<optional>true</optional>
4848
</dependency>
49-
<dependency>
50-
<groupId>org.springframework.experimental</groupId>
51-
<artifactId>spring-native</artifactId>
52-
<optional>true</optional>
53-
</dependency>
5449
</dependencies>
5550
<build>
56-
<resources>
57-
<resource>
58-
<directory>src/main/resources</directory>
59-
<filtering>true</filtering>
60-
</resource>
61-
</resources>
6251
<plugins>
6352
<plugin>
6453
<groupId>org.apache.maven.plugins</groupId>

springdoc-openapi-common/src/main/java/org/springdoc/core/Constants.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,6 @@ public final class Constants {
175175
*/
176176
public static final String SPRINGDOC_CONFIG_FILE = ResourceUtils.CLASSPATH_URL_PREFIX + "springdoc.swagger-ui.config";
177177

178-
/**
179-
* The constant SWAGGER_UI_VERSION.
180-
*/
181-
public static final String SWAGGER_UI_VERSION= "${springdoc.swagger-ui.version}";
182-
183178
/**
184179
* The constant SWAGGER_UI_PREFIX.
185180
*/

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

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -162,34 +162,11 @@ public class SpringDocConfigProperties {
162162
*/
163163
private boolean useManagementPort;
164164

165-
/**
166-
* The Enable native support.
167-
*/
168-
protected Boolean enableNativeImageSupport;
169-
170165
/**
171166
* The Disable i18n.
172167
*/
173168
private boolean disableI18n;
174169

175-
/**
176-
* Gets enable native image support.
177-
*
178-
* @return the enable native image support
179-
*/
180-
public Boolean getEnableNativeImageSupport() {
181-
return enableNativeImageSupport;
182-
}
183-
184-
/**
185-
* Sets enable native image support.
186-
*
187-
* @param enableNativeImageSupport the enable native image support
188-
*/
189-
public void setEnableNativeImageSupport(Boolean enableNativeImageSupport) {
190-
this.enableNativeImageSupport = enableNativeImageSupport;
191-
}
192-
193170
/**
194171
* Is use management port boolean.
195172
*

springdoc-openapi-common/src/main/java/org/springdoc/core/SwaggerUiConfigParameters.java

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,25 +25,20 @@
2525
import java.util.HashSet;
2626
import java.util.LinkedHashSet;
2727
import java.util.Map;
28-
import java.util.Optional;
2928
import java.util.Set;
3029
import java.util.TreeMap;
3130
import java.util.stream.Collectors;
3231

3332
import org.apache.commons.lang3.StringUtils;
3433

35-
import org.springframework.beans.factory.annotation.Value;
3634
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
3735
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
3836
import org.springframework.context.annotation.Configuration;
3937
import org.springframework.context.annotation.Lazy;
40-
import org.springframework.context.annotation.PropertySource;
4138
import org.springframework.util.CollectionUtils;
4239

43-
import static org.springdoc.core.Constants.SPRINGDOC_CONFIG_FILE;
4440
import static org.springdoc.core.Constants.SPRINGDOC_SWAGGER_UI_ENABLED;
4541
import static org.springdoc.core.Constants.SWAGGER_UI_OAUTH_REDIRECT_URL;
46-
import static org.springdoc.core.Constants.SWAGGER_UI_VERSION;
4742
import static org.springframework.util.AntPathMatcher.DEFAULT_PATH_SEPARATOR;
4843

4944
/**
@@ -54,7 +49,6 @@
5449
@Configuration(proxyBeanMethods = false)
5550
@ConditionalOnProperty(name = SPRINGDOC_SWAGGER_UI_ENABLED, matchIfMissing = true)
5651
@ConditionalOnBean(SpringDocConfiguration.class)
57-
@PropertySource(SPRINGDOC_CONFIG_FILE)
5852
public class SwaggerUiConfigParameters extends AbstractSwaggerUiConfigProperties {
5953

6054
/**
@@ -92,26 +86,14 @@ public class SwaggerUiConfigParameters extends AbstractSwaggerUiConfigProperties
9286
*/
9387
private final SwaggerUiConfigProperties swaggerUiConfig;
9488

95-
/**
96-
* The Swagger ui version.
97-
*/
98-
@Value(SWAGGER_UI_VERSION)
99-
private String swaggerUiVersion;
100-
101-
/**
102-
* The Spring doc hints optional.
103-
*/
104-
private final Optional<SpringDocHints> springDocHintsOptional;
10589

10690
/**
10791
* Instantiates a new Swagger ui config parameters.
10892
*
10993
* @param swaggerUiConfig the swagger ui config
110-
* @param springDocHintsOptional the spring doc hints optional
11194
*/
112-
public SwaggerUiConfigParameters(SwaggerUiConfigProperties swaggerUiConfig, Optional<SpringDocHints> springDocHintsOptional) {
95+
public SwaggerUiConfigParameters(SwaggerUiConfigProperties swaggerUiConfig) {
11396
this.swaggerUiConfig = swaggerUiConfig;
114-
this.springDocHintsOptional = springDocHintsOptional;
11597
this.path = StringUtils.defaultIfBlank(swaggerUiConfig.getPath(), Constants.DEFAULT_SWAGGER_UI_PATH);
11698
this.oauth2RedirectUrl = StringUtils.defaultIfBlank(swaggerUiConfig.getOauth2RedirectUrl(), SWAGGER_UI_OAUTH_REDIRECT_URL);
11799
this.layout = swaggerUiConfig.getLayout();
@@ -140,33 +122,6 @@ public SwaggerUiConfigParameters(SwaggerUiConfigProperties swaggerUiConfig, Opti
140122
this.persistAuthorization = swaggerUiConfig.getPersistAuthorization();
141123
}
142124

143-
/**
144-
* Gets spring doc hints optional.
145-
*
146-
* @return the spring doc hints optional
147-
*/
148-
public Optional<SpringDocHints> getSpringDocHintsOptional() {
149-
return springDocHintsOptional;
150-
}
151-
152-
/**
153-
* Gets swagger ui version.
154-
*
155-
* @return the swagger ui version
156-
*/
157-
public String getSwaggerUiVersion() {
158-
return swaggerUiVersion;
159-
}
160-
161-
/**
162-
* Sets swagger ui version.
163-
*
164-
* @param swaggerUiVersion the swagger ui version
165-
*/
166-
public void setSwaggerUiVersion(String swaggerUiVersion) {
167-
this.swaggerUiVersion = swaggerUiVersion;
168-
}
169-
170125
/**
171126
* Add group.
172127
*

springdoc-openapi-common/src/main/java/org/springdoc/core/SwaggerUiConfigProperties.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,28 @@ public class SwaggerUiConfigProperties extends AbstractSwaggerUiConfigProperties
5555
*/
5656
private boolean displayQueryParamsWithoutOauth2;
5757

58+
/**
59+
* The Swagger ui version.
60+
*/
61+
private String version;
62+
63+
/**
64+
* Gets swagger ui version.
65+
*
66+
* @return the swagger ui version
67+
*/
68+
public String getVersion() {
69+
return version;
70+
}
71+
72+
/**
73+
* Sets swagger ui version.
74+
*
75+
* @param version the swagger ui version
76+
*/
77+
public void setVersion(String version) {
78+
this.version = version;
79+
}
5880
/**
5981
* The Csrf configuration.
6082
*/
@@ -361,4 +383,5 @@ public void setTheme(String theme) {
361383
this.theme = theme;
362384
}
363385
}
386+
364387
}

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -226,21 +226,9 @@ protected String getOauth2RedirectUrl() {
226226
* @return the swagger ui url
227227
*/
228228
protected String getSwaggerUiUrl() {
229-
if (enableNativeImageSupport())
230-
return SWAGGER_UI_PREFIX + DEFAULT_PATH_SEPARATOR + swaggerUiConfigParameters.getSwaggerUiVersion() + INDEX_PAGE;
229+
if (StringUtils.isNotEmpty(swaggerUiConfig.getVersion()))
230+
return SWAGGER_UI_PREFIX + DEFAULT_PATH_SEPARATOR + swaggerUiConfig.getVersion() + INDEX_PAGE;
231231
else
232232
return SWAGGER_UI_URL;
233233
}
234-
235-
/**
236-
* Enable native image support boolean.
237-
*
238-
* @return the boolean
239-
*/
240-
private boolean enableNativeImageSupport(){
241-
if (springDocConfigProperties.getEnableNativeImageSupport() != null)
242-
return springDocConfigProperties.getEnableNativeImageSupport();
243-
else
244-
return swaggerUiConfigParameters.getSpringDocHintsOptional().isPresent();
245-
}
246234
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
22
org.springdoc.core.SpringDocConfiguration,\
3-
org.springdoc.core.SpringDocConfigProperties,\
4-
org.springdoc.core.SpringDocHints
3+
org.springdoc.core.SpringDocConfigProperties

springdoc-openapi-native/.gitignore

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
######################
2+
# Project Specific
3+
######################
4+
/target/www/**
5+
/src/test/javascript/coverage/
6+
7+
######################
8+
# Node
9+
######################
10+
/node/
11+
node_tmp/
12+
node_modules/
13+
npm-debug.log.*
14+
/.awcache/*
15+
/.cache-loader/*
16+
17+
######################
18+
# SASS
19+
######################
20+
.sass-cache/
21+
22+
######################
23+
# Eclipse
24+
######################
25+
*.pydevproject
26+
.project
27+
.metadata
28+
tmp/
29+
tmp/**/*
30+
*.tmp
31+
*.bak
32+
*.swp
33+
*~.nib
34+
local.properties
35+
.classpath
36+
.settings/
37+
.loadpath
38+
.factorypath
39+
/src/main/resources/rebel.xml
40+
41+
# External tool builders
42+
.externalToolBuilders/**
43+
44+
# Locally stored "Eclipse launch configurations"
45+
*.launch
46+
47+
# CDT-specific
48+
.cproject
49+
50+
# PDT-specific
51+
.buildpath
52+
53+
######################
54+
# Intellij
55+
######################
56+
.idea/
57+
*.iml
58+
*.iws
59+
*.ipr
60+
*.ids
61+
*.orig
62+
classes/
63+
out/
64+
65+
######################
66+
# Visual Studio Code
67+
######################
68+
.vscode/
69+
70+
######################
71+
# Maven
72+
######################
73+
/log/
74+
/target/
75+
76+
######################
77+
# Gradle
78+
######################
79+
.gradle/
80+
/build/
81+
82+
######################
83+
# Package Files
84+
######################
85+
*.jar
86+
*.war
87+
*.ear
88+
*.db
89+
90+
######################
91+
# Windows
92+
######################
93+
# Windows image file caches
94+
Thumbs.db
95+
96+
# Folder config file
97+
Desktop.ini
98+
99+
######################
100+
# Mac OSX
101+
######################
102+
.DS_Store
103+
.svn
104+
105+
# Thumbnails
106+
._*
107+
108+
# Files that might appear on external disk
109+
.Spotlight-V100
110+
.Trashes
111+
112+
######################
113+
# Directories
114+
######################
115+
/bin/
116+
/deploy/
117+
118+
######################
119+
# Logs
120+
######################
121+
*.log*
122+
123+
######################
124+
# Others
125+
######################
126+
*.class
127+
*.*~
128+
*~
129+
.merge_file*
130+
131+
######################
132+
# Gradle Wrapper
133+
######################
134+
!gradle/wrapper/gradle-wrapper.jar
135+
136+
######################
137+
# Maven Wrapper
138+
######################
139+
!.mvn/wrapper/maven-wrapper.jar
140+
141+
######################
142+
# ESLint
143+
######################
144+
.eslintcache

0 commit comments

Comments
 (0)