/
GithubProperties.java
75 lines (69 loc) · 1.95 KB
/
GithubProperties.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package daggerok.github;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.Pattern;
import static com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility.NONE;
import static com.fasterxml.jackson.annotation.JsonProperty.Access.READ_ONLY;
// we have to use @JsonAutoDetect + @JsonProperty(access = READ_ONLY)
// if we wanna show only specifiyed serialization, otherwise, spring will
// generate proxy with additional wrapped fields and you will see this:
/*
{
"advisors": [
{
"advice": {},
"order": 2147483647,
"perInstance": true,
"pointcut": {
"classFilter": {},
"methodMatcher": {
"runtime": false
}
}
}
],
"proxiedInterfaces": [],
"targetClass": "daggerok.github.GithubProperties",
"targetSource": {
"static": true,
"target": {
"token": "my:token"
},
"targetClass": "daggerok.github.GithubProperties"
},
"token": "my:token"
}
*/
@JsonAutoDetect(
fieldVisibility = NONE,
setterVisibility = NONE,
getterVisibility = NONE,
isGetterVisibility = NONE,
creatorVisibility = NONE
)
@Getter
@Setter
@Validated
@ConfigurationProperties(prefix = "github")
public class GithubProperties {
/**
* github base URI
*
* default: https://api.github.com
*/
@JsonProperty(access = READ_ONLY)
String baseUrl;
/**
* github token in format username:password.
*
* username: Several word characters, short for [a-zA-Z_0-9]
* password: Several non-whitespace characters
*/
@JsonProperty(access = READ_ONLY)
@Pattern(regexp = "\\w+:\\S+")
String token;
}