File tree Expand file tree Collapse file tree
main/java/springfox/documentation/spring/web
test/groovy/springfox/documentation/spring/web Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2929import static org .springframework .util .StringUtils .*;
3030
3131public class DescriptionResolver {
32- private static final Pattern PATTERN = Pattern .compile ("\\ Q${\\ E(.+?)(:.* )?\\ Q}\\ E" );
32+ private static final Pattern PATTERN = Pattern .compile ("\\ Q${\\ E(.+?)(:(.*) )?\\ Q}\\ E" );
3333 private final Environment environment ;
3434 private Map <String , String > cache ;
3535
@@ -69,6 +69,7 @@ public String resolve(String expression) {
6969
7070 // Store the value
7171 String key = matcher .group (1 );
72+ String defaultValue = matcher .group (3 );
7273
7374 // Get the value
7475 String value = environment .getProperty (key );
@@ -82,6 +83,11 @@ public String resolve(String expression) {
8283 // return the value
8384 return value ;
8485
86+ } else if (defaultValue != null ) {
87+ // use default if value not found
88+ cache .put (expression , defaultValue );
89+
90+ return defaultValue ;
8591 }
8692
8793 }
Original file line number Diff line number Diff line change @@ -22,6 +22,8 @@ class DescriptionResolverSpec extends Specification {
2222 " key2value" | ' ${key2}'
2323 " key2value" | ' ${key2:}'
2424 " key2value" | ' ${key2:key2default}'
25+ " key3default" | ' ${key3:key3default}'
26+ " " | ' ${key3:}'
2527 ' ${unknown}' | ' ${unknown}'
2628 " key1" | ' key1'
2729 " key2" | ' key2'
You can’t perform that action at this time.
0 commit comments