|
24 | 24 |
|
25 | 25 | package org.springdoc.core.utils;
|
26 | 26 |
|
27 |
| -import java.util.LinkedHashMap; |
28 |
| -import java.util.List; |
29 | 27 | import java.util.Locale;
|
30 |
| -import java.util.Map; |
31 |
| -import java.util.Map.Entry; |
32 |
| -import java.util.function.Consumer; |
33 |
| -import java.util.function.Supplier; |
34 |
| -import java.util.stream.Collectors; |
35 | 28 |
|
36 |
| -import io.swagger.v3.oas.models.info.Contact; |
37 |
| -import io.swagger.v3.oas.models.info.Info; |
38 |
| -import io.swagger.v3.oas.models.info.License; |
39 |
| -import io.swagger.v3.oas.models.media.Schema; |
40 |
| -import io.swagger.v3.oas.models.servers.Server; |
41 |
| -import org.apache.commons.lang3.StringUtils; |
42 | 29 | import org.slf4j.Logger;
|
43 | 30 | import org.slf4j.LoggerFactory;
|
44 | 31 | import org.springdoc.core.properties.SpringDocConfigProperties;
|
45 | 32 |
|
46 | 33 | import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
47 | 34 | import org.springframework.context.MessageSource;
|
48 | 35 | import org.springframework.context.NoSuchMessageException;
|
49 |
| -import org.springframework.util.CollectionUtils; |
50 | 36 |
|
51 | 37 | /**
|
52 | 38 | * The type Property resolver utils.
|
@@ -115,93 +101,6 @@ public String resolve(String parameterProperty, Locale locale) {
|
115 | 101 | return result;
|
116 | 102 | }
|
117 | 103 |
|
118 |
| - /** |
119 |
| - * Resolve properties info. |
120 |
| - * |
121 |
| - * @param servers the servers |
122 |
| - * @param locale the locale |
123 |
| - * @return the servers |
124 |
| - */ |
125 |
| - public List<Server> resolveProperties(List<Server> servers, Locale locale) { |
126 |
| - servers.forEach(server -> { |
127 |
| - resolveProperty(server::getUrl, server::url, this, locale); |
128 |
| - resolveProperty(server::getDescription, server::description, this, locale); |
129 |
| - if (CollectionUtils.isEmpty(server.getVariables())) |
130 |
| - server.setVariables(null); |
131 |
| - }); |
132 |
| - return servers; |
133 |
| - } |
134 |
| - |
135 |
| - /** |
136 |
| - * Resolve properties info. |
137 |
| - * |
138 |
| - * @param info the info |
139 |
| - * @param locale the locale |
140 |
| - * @return the info |
141 |
| - */ |
142 |
| - public Info resolveProperties(Info info, Locale locale) { |
143 |
| - resolveProperty(info::getTitle, info::title, this, locale); |
144 |
| - resolveProperty(info::getDescription, info::description, this, locale); |
145 |
| - resolveProperty(info::getVersion, info::version, this, locale); |
146 |
| - resolveProperty(info::getTermsOfService, info::termsOfService, this, locale); |
147 |
| - |
148 |
| - License license = info.getLicense(); |
149 |
| - if (license != null) { |
150 |
| - resolveProperty(license::getName, license::name, this, locale); |
151 |
| - resolveProperty(license::getUrl, license::url, this, locale); |
152 |
| - } |
153 |
| - |
154 |
| - Contact contact = info.getContact(); |
155 |
| - if (contact != null) { |
156 |
| - resolveProperty(contact::getName, contact::name, this, locale); |
157 |
| - resolveProperty(contact::getEmail, contact::email, this, locale); |
158 |
| - resolveProperty(contact::getUrl, contact::url, this, locale); |
159 |
| - } |
160 |
| - return info; |
161 |
| - } |
162 |
| - |
163 |
| - /** |
164 |
| - * Resolve properties schema. |
165 |
| - * |
166 |
| - * @param schema the schema |
167 |
| - * @param locale the locale |
168 |
| - * @return the schema |
169 |
| - */ |
170 |
| - @SuppressWarnings("unchecked") |
171 |
| - public Schema resolveProperties(Schema<?> schema, Locale locale) { |
172 |
| - resolveProperty(schema::getName, schema::name, this, locale); |
173 |
| - resolveProperty(schema::getTitle, schema::title, this, locale); |
174 |
| - resolveProperty(schema::getDescription, schema::description, this, locale); |
175 |
| - |
176 |
| - Map<String, Schema> properties = schema.getProperties(); |
177 |
| - if (!CollectionUtils.isEmpty(properties)) { |
178 |
| - LinkedHashMap<String, Schema> resolvedSchemas = properties.entrySet().stream().map(es -> { |
179 |
| - es.setValue(resolveProperties(es.getValue(), locale)); |
180 |
| - return es; |
181 |
| - }).collect(Collectors.toMap(Entry::getKey, Entry::getValue, (e1, e2) -> e2, |
182 |
| - LinkedHashMap::new)); |
183 |
| - schema.setProperties(resolvedSchemas); |
184 |
| - } |
185 |
| - |
186 |
| - return schema; |
187 |
| - } |
188 |
| - |
189 |
| - /** |
190 |
| - * Resolve property. |
191 |
| - * |
192 |
| - * @param getProperty the get property |
193 |
| - * @param setProperty the set property |
194 |
| - * @param propertyResolverUtils the property resolver utils |
195 |
| - * @param locale the locale |
196 |
| - */ |
197 |
| - private void resolveProperty(Supplier<String> getProperty, Consumer<String> setProperty, |
198 |
| - PropertyResolverUtils propertyResolverUtils, Locale locale) { |
199 |
| - String value = getProperty.get(); |
200 |
| - if (StringUtils.isNotBlank(value)) { |
201 |
| - setProperty.accept(propertyResolverUtils.resolve(value, locale)); |
202 |
| - } |
203 |
| - } |
204 |
| - |
205 | 104 | /**
|
206 | 105 | * Gets factory.
|
207 | 106 | *
|
|
0 commit comments