1
18
19 package org.springdoc.core;
20
21 import java.util.ArrayList;
22 import java.util.List;
23
24 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
25 import org.springframework.boot.context.properties.ConfigurationProperties;
26 import org.springframework.context.annotation.Configuration;
27 import org.springframework.http.MediaType;
28
29 import static org.springdoc.core.Constants.SPRINGDOC_ENABLED;
30
31 @Configuration
32 @ConfigurationProperties(prefix = Constants.SPRINGDOC_PREFIX)
33 @ConditionalOnProperty(name = SPRINGDOC_ENABLED, matchIfMissing = true)
34 public class SpringDocConfigProperties {
35
36 private boolean showActuator;
37
38 private Webjars webjars = new Webjars();
39
40 private ApiDocs apiDocs = new ApiDocs();
41
42 private List<String> packagesToScan;
43
44 private List<String> packagesToExclude;
45
46 private List<String> pathsToMatch;
47
48 private List<String> pathsToExclude;
49
50 private Cache cache = new Cache();
51
52 private List<GroupConfig> groupConfigs = new ArrayList<>();
53
54 private boolean autoTagClasses = true;
55
56 private boolean modelAndViewAllowed;
57
58 private boolean overrideWithGenericResponse = true;
59
60 private boolean removeBrokenReferenceDefinitions = true;
61
62 private String defaultConsumesMediaType = MediaType.APPLICATION_JSON_VALUE;
63
64 private String defaultProducesMediaType = MediaType.ALL_VALUE;
65
66 public boolean isAutoTagClasses() {
67 return autoTagClasses;
68 }
69
70 public void setAutoTagClasses(boolean autoTagClasses) {
71 this.autoTagClasses = autoTagClasses;
72 }
73
74 public boolean isModelAndViewAllowed() {
75 return modelAndViewAllowed;
76 }
77
78 public void setModelAndViewAllowed(boolean modelAndViewAllowed) {
79 this.modelAndViewAllowed = modelAndViewAllowed;
80 }
81
82 public List<String> getPackagesToExclude() {
83 return packagesToExclude;
84 }
85
86 public void setPackagesToExclude(List<String> packagesToExclude) {
87 this.packagesToExclude = packagesToExclude;
88 }
89
90 public List<String> getPathsToExclude() {
91 return pathsToExclude;
92 }
93
94 public void setPathsToExclude(List<String> pathsToExclude) {
95 this.pathsToExclude = pathsToExclude;
96 }
97
98 public List<String> getPackagesToScan() {
99 return packagesToScan;
100 }
101
102 public void setPackagesToScan(List<String> packagesToScan) {
103 this.packagesToScan = packagesToScan;
104 }
105
106 public boolean isShowActuator() {
107 return showActuator;
108 }
109
110 public void setShowActuator(boolean showActuator) {
111 this.showActuator = showActuator;
112 }
113
114 public Webjars getWebjars() {
115 return webjars;
116 }
117
118 public void setWebjars(Webjars webjars) {
119 this.webjars = webjars;
120 }
121
122 public ApiDocs getApiDocs() {
123 return apiDocs;
124 }
125
126 public void setApiDocs(ApiDocs apiDocs) {
127 this.apiDocs = apiDocs;
128 }
129
130 public List<String> getPathsToMatch() {
131 return pathsToMatch;
132 }
133
134 public void setPathsToMatch(List<String> pathsToMatch) {
135 this.pathsToMatch = pathsToMatch;
136 }
137
138 public void setCache(Cache cache) {
139 this.cache = cache;
140 }
141
142 public boolean isCacheDisabled() {
143 return cache.isDisabled();
144 }
145
146 public List<GroupConfig> getGroupConfigs() {
147 return groupConfigs;
148 }
149
150 public void setGroupConfigs(List<GroupConfig> groupConfigs) {
151 this.groupConfigs = groupConfigs;
152 }
153
154 public void addGroupConfig(GroupConfig groupConfigs) {
155 this.groupConfigs.add(groupConfigs);
156 }
157
158 public String getDefaultConsumesMediaType() {
159 return defaultConsumesMediaType;
160 }
161
162 public void setDefaultConsumesMediaType(String defaultConsumesMediaType) {
163 this.defaultConsumesMediaType = defaultConsumesMediaType;
164 }
165
166 public String getDefaultProducesMediaType() {
167 return defaultProducesMediaType;
168 }
169
170 public void setDefaultProducesMediaType(String defaultProducesMediaType) {
171 this.defaultProducesMediaType = defaultProducesMediaType;
172 }
173
174 public boolean isOverrideWithGenericResponse() {
175 return overrideWithGenericResponse;
176 }
177
178 public void setOverrideWithGenericResponse(boolean overrideWithGenericResponse) {
179 this.overrideWithGenericResponse = overrideWithGenericResponse;
180 }
181
182 public boolean isRemoveBrokenReferenceDefinitions() {
183 return removeBrokenReferenceDefinitions;
184 }
185
186 public void setRemoveBrokenReferenceDefinitions(boolean removeBrokenReferenceDefinitions) {
187 this.removeBrokenReferenceDefinitions = removeBrokenReferenceDefinitions;
188 }
189
190 public static class Webjars {
191 private String prefix = "/webjars";
192
193 public String getPrefix() {
194 return prefix;
195 }
196
197 public void setPrefix(String prefix) {
198 this.prefix = prefix;
199 }
200 }
201
202 public static class ApiDocs {
203
206 private String path = Constants.DEFAULT_API_DOCS_URL;
207
208
211 private boolean enabled = true;
212
213 private boolean resolveSchemaProperties;
214
215 private Groups groups = new Groups();
216
217 public String getPath() {
218 return path;
219 }
220
221 public void setPath(String path) {
222 this.path = path;
223 }
224
225 public boolean isEnabled() {
226 return enabled;
227 }
228
229 public void setEnabled(boolean enabled) {
230 this.enabled = enabled;
231 }
232
233 public Groups getGroups() {
234 return groups;
235 }
236
237 public void setGroups(Groups groups) {
238 this.groups = groups;
239 }
240
241 public boolean isResolveSchemaProperties() {
242 return resolveSchemaProperties;
243 }
244
245 public void setResolveSchemaProperties(boolean resolveSchemaProperties) {
246 this.resolveSchemaProperties = resolveSchemaProperties;
247 }
248 }
249
250 public static class Groups {
251 private boolean enabled;
252
253 public boolean isEnabled() {
254 return enabled;
255 }
256
257 public void setEnabled(boolean enabled) {
258 this.enabled = enabled;
259 }
260 }
261
262 public static class Cache {
263 private boolean disabled;
264
265 public boolean isDisabled() {
266 return disabled;
267 }
268
269 public void setDisabled(boolean disabled) {
270 this.disabled = disabled;
271 }
272 }
273
274 public static class GroupConfig {
275
276 private List<String> pathsToMatch;
277
278 private List<String> packagesToScan;
279
280 private List<String> packagesToExclude;
281
282 private List<String> pathsToExclude;
283
284 private String group;
285
286 public GroupConfig() {
287 }
288
289 public GroupConfig(String group, List<String> pathsToMatch, List<String> packagesToScan, List<String> packagesToExclude, List<String> pathsToExclude) {
290 this.pathsToMatch = pathsToMatch;
291 this.pathsToExclude = pathsToExclude;
292 this.packagesToExclude = packagesToExclude;
293 this.packagesToScan = packagesToScan;
294 this.group = group;
295 }
296
297 public List<String> getPathsToMatch() {
298 return pathsToMatch;
299 }
300
301 public void setPathsToMatch(List<String> pathsToMatch) {
302 this.pathsToMatch = pathsToMatch;
303 }
304
305 public List<String> getPackagesToScan() {
306 return packagesToScan;
307 }
308
309 public void setPackagesToScan(List<String> packagesToScan) {
310 this.packagesToScan = packagesToScan;
311 }
312
313 public String getGroup() {
314 return group;
315 }
316
317 public void setGroup(String group) {
318 this.group = group;
319 }
320
321 public List<String> getPackagesToExclude() {
322 return packagesToExclude;
323 }
324
325 public void setPackagesToExclude(List<String> packagesToExclude) {
326 this.packagesToExclude = packagesToExclude;
327 }
328
329 public List<String> getPathsToExclude() {
330 return pathsToExclude;
331 }
332
333 public void setPathsToExclude(List<String> pathsToExclude) {
334 this.pathsToExclude = pathsToExclude;
335 }
336 }
337 }
338