Skip to content

Commit a70b548

Browse files
authored
Remove deprecated "status" and "instance" properties from InputValidationIssue (#46)
Fix #35
1 parent c04d652 commit a70b548

File tree

5 files changed

+52
-101
lines changed

5 files changed

+52
-101
lines changed

belgif-rest-problem-it/belgif-rest-problem-it-common/src/main/java/io/github/belgif/rest/problem/AbstractJacksonSerializationTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,17 @@ void additionalExceptionProperties() throws JsonProcessingException {
183183
assertSerializationRoundtrip(problem);
184184
}
185185

186+
@Test
187+
void issueWithStatusAndInstance() throws JsonProcessingException {
188+
BadRequestProblem problem = new BadRequestProblem();
189+
problem.setDetail("my detail message");
190+
InputValidationIssue issue = new InputValidationIssue().detail("test");
191+
issue.setAdditionalProperty("status", 400);
192+
issue.setAdditionalProperty("instance", "instance");
193+
problem.addIssue(issue);
194+
assertSerializationRoundtrip(problem);
195+
}
196+
186197
void assertSerializationRoundtrip(Problem problem) throws JsonProcessingException {
187198
String json = mapper.writeValueAsString(problem);
188199
print(json);

belgif-rest-problem/src/main/java/io/github/belgif/rest/problem/api/InputValidationIssue.java

Lines changed: 12 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,17 @@
2121
/**
2222
* Maps to InputValidationIssue in belgif/problem/v1/problem-v1.yaml.
2323
*
24+
* <p>
25+
* Note that this model class intentionally does not include the "status" and "instance" properties.
26+
* In problem-v1.yaml, InputValidationIssue technically inherits these properties from Problem,
27+
* but they are not meant to be used for input validation issues. In the unlikely scenario where these properties
28+
* would be needed, they can still be added/retrieved via the additionalProperties.
29+
* </p>
30+
*
2431
* @see InputValidationProblem
2532
*/
2633
@JsonInclude(value = Include.NON_DEFAULT)
27-
@JsonPropertyOrder(value = { "type", "href", "title", "status", "detail", "instance", "in", "name", "value", "inputs" })
34+
@JsonPropertyOrder(value = { "type", "href", "title", "detail", "in", "name", "value", "inputs" })
2835
public class InputValidationIssue {
2936

3037
public static final Comparator<InputValidationIssue> BY_NAME = Comparator.comparing(InputValidationIssue::getName);
@@ -35,9 +42,7 @@ public class InputValidationIssue {
3542
private URI type;
3643
private URI href;
3744
private String title;
38-
private int status;
3945
private String detail;
40-
private URI instance;
4146
private InEnum in;
4247
private String name;
4348
private Object value;
@@ -87,26 +92,6 @@ public void setTitle(String title) {
8792
this.title = title;
8893
}
8994

90-
/**
91-
* @return the status
92-
* @deprecated this status property is generally not intended to be used, it is only provided because
93-
* InputValidationIssue inherits from Problem in belgif-openapi-problem
94-
*/
95-
@Deprecated
96-
public int getStatus() {
97-
return status;
98-
}
99-
100-
/**
101-
* @param status the status
102-
* @deprecated this status property is generally not intended to be used, it is only provided because
103-
* InputValidationIssue inherits from Problem in belgif-openapi-problem
104-
*/
105-
@Deprecated
106-
public void setStatus(int status) {
107-
this.status = status;
108-
}
109-
11095
public String getDetail() {
11196
return detail;
11297
}
@@ -115,26 +100,6 @@ public void setDetail(String detail) {
115100
this.detail = detail;
116101
}
117102

118-
/**
119-
* @return the instance
120-
* @deprecated this instance property is generally not intended to be used, it is only provided because
121-
* InputValidationIssue inherits from Problem in belgif-openapi-problem
122-
*/
123-
@Deprecated
124-
public URI getInstance() {
125-
return instance;
126-
}
127-
128-
/**
129-
* @param instance the instance
130-
* @deprecated this instance property is generally not intended to be used, it is only provided because
131-
* InputValidationIssue inherits from Problem in belgif-openapi-problem
132-
*/
133-
@Deprecated
134-
public void setInstance(URI instance) {
135-
this.instance = instance;
136-
}
137-
138103
public InEnum getIn() {
139104
return in;
140105
}
@@ -319,16 +284,16 @@ public boolean equals(Object o) {
319284
return false;
320285
}
321286
InputValidationIssue that = (InputValidationIssue) o;
322-
return status == that.status && Objects.equals(type, that.type) && Objects.equals(href, that.href)
287+
return Objects.equals(type, that.type) && Objects.equals(href, that.href)
323288
&& Objects.equals(title, that.title) && Objects.equals(detail, that.detail)
324-
&& Objects.equals(instance, that.instance) && in == that.in && Objects.equals(name, that.name)
325-
&& Objects.equals(value, that.value) && Objects.equals(inputs, that.inputs)
289+
&& in == that.in && Objects.equals(name, that.name) && Objects.equals(value, that.value)
290+
&& Objects.equals(inputs, that.inputs)
326291
&& Objects.equals(additionalProperties, that.additionalProperties);
327292
}
328293

329294
@Override
330295
public int hashCode() {
331-
return Objects.hash(type, href, title, status, detail, instance, in, name, value, inputs, additionalProperties);
296+
return Objects.hash(type, href, title, detail, in, name, value, inputs, additionalProperties);
332297
}
333298

334299
@Override

belgif-rest-problem/src/test/java/io/github/belgif/rest/problem/api/InputValidationIssueTest.java

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,6 @@ void title() {
7070
assertThat(new InputValidationIssue().title("Title").getTitle()).isEqualTo("Title");
7171
}
7272

73-
@Test
74-
void status() {
75-
InputValidationIssue issue = new InputValidationIssue();
76-
issue.setStatus(499);
77-
assertThat(issue.getStatus()).isEqualTo(499);
78-
}
79-
8073
@Test
8174
void detail() {
8275
InputValidationIssue issue = new InputValidationIssue();
@@ -85,13 +78,6 @@ void detail() {
8578
assertThat(new InputValidationIssue().detail("Detail").getDetail()).isEqualTo("Detail");
8679
}
8780

88-
@Test
89-
void instance() {
90-
InputValidationIssue issue = new InputValidationIssue();
91-
issue.setInstance(URI.create("instance"));
92-
assertThat(issue.getInstance()).hasToString("instance");
93-
}
94-
9581
@Test
9682
void in() {
9783
InputValidationIssue issue = new InputValidationIssue();

belgif-rest-problem/src/test/java/io/github/belgif/rest/problem/api/InputValidationIssuesTest.java

Lines changed: 25 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ void schemaViolation() {
2323
assertThat(issue.getName()).isEqualTo("test");
2424
assertThat(issue.getValue()).isEqualTo("value");
2525
assertThat(issue.getDetail()).isEqualTo("detail");
26-
assertThat(issue).extracting("href", "instance", "status", "inputs", "additionalProperties")
27-
.allMatch(this::isEmpty);
26+
assertThat(issue).extracting("href", "inputs", "additionalProperties").allMatch(this::isEmpty);
2827
}
2928

3029
@Test
@@ -37,8 +36,7 @@ void unknownInput() {
3736
assertThat(issue.getName()).isEqualTo("oops");
3837
assertThat(issue.getValue()).isEqualTo("value");
3938
assertThat(issue.getDetail()).isEqualTo("Input oops is unknown");
40-
assertThat(issue).extracting("href", "instance", "status", "inputs", "additionalProperties")
41-
.allMatch(this::isEmpty);
39+
assertThat(issue).extracting("href", "inputs", "additionalProperties").allMatch(this::isEmpty);
4240
}
4341

4442
@Test
@@ -51,8 +49,7 @@ void invalidStructure() {
5149
assertThat(issue.getName()).isEqualTo("test");
5250
assertThat(issue.getValue()).isEqualTo("value");
5351
assertThat(issue.getDetail()).isEqualTo("detail");
54-
assertThat(issue).extracting("href", "instance", "status", "inputs", "additionalProperties")
55-
.allMatch(this::isEmpty);
52+
assertThat(issue).extracting("href", "inputs", "additionalProperties").allMatch(this::isEmpty);
5653
}
5754

5855
@Test
@@ -66,7 +63,7 @@ void outOfRangeMinMax() {
6663
assertThat(issue.getValue()).isEqualTo(6);
6764
assertThat(issue.getDetail()).isEqualTo("Input value test = 6 is out of range [1, 5]");
6865
assertThat(issue.getAdditionalProperties()).containsOnly(entry("minimum", "1"), entry("maximum", "5"));
69-
assertThat(issue).extracting("href", "instance", "status", "inputs").allMatch(this::isEmpty);
66+
assertThat(issue).extracting("href", "inputs").allMatch(this::isEmpty);
7067

7168
}
7269

@@ -81,7 +78,7 @@ void outOfRangeMin() {
8178
assertThat(issue.getValue()).isEqualTo(0);
8279
assertThat(issue.getDetail()).isEqualTo("Input value test = 0 should be at least 1");
8380
assertThat(issue.getAdditionalProperties()).containsExactly(entry("minimum", "1"));
84-
assertThat(issue).extracting("href", "instance", "status", "inputs").allMatch(this::isEmpty);
81+
assertThat(issue).extracting("href", "inputs").allMatch(this::isEmpty);
8582
}
8683

8784
@Test
@@ -95,7 +92,7 @@ void outOfRangeMax() {
9592
assertThat(issue.getValue()).isEqualTo(6);
9693
assertThat(issue.getDetail()).isEqualTo("Input value test = 6 should not exceed 5");
9794
assertThat(issue.getAdditionalProperties()).containsExactly(entry("maximum", "5"));
98-
assertThat(issue).extracting("href", "instance", "status", "inputs").allMatch(this::isEmpty);
95+
assertThat(issue).extracting("href", "inputs").allMatch(this::isEmpty);
9996
}
10097

10198
@Test
@@ -115,8 +112,7 @@ void referencedResourceNotFound() {
115112
assertThat(issue.getName()).isEqualTo("test");
116113
assertThat(issue.getValue()).isEqualTo("value");
117114
assertThat(issue.getDetail()).isEqualTo("Referenced resource test = 'value' does not exist");
118-
assertThat(issue).extracting("href", "instance", "status", "inputs", "additionalProperties")
119-
.allMatch(this::isEmpty);
115+
assertThat(issue).extracting("href", "inputs", "additionalProperties").allMatch(this::isEmpty);
120116
}
121117

122118
@Test
@@ -129,8 +125,7 @@ void rejectedInput() {
129125
assertThat(issue.getName()).isEqualTo("test");
130126
assertThat(issue.getValue()).isEqualTo("value");
131127
assertThat(issue.getDetail()).isEqualTo("Input test is not allowed in this context");
132-
assertThat(issue).extracting("href", "instance", "status", "inputs", "additionalProperties")
133-
.allMatch(this::isEmpty);
128+
assertThat(issue).extracting("href", "inputs", "additionalProperties").allMatch(this::isEmpty);
134129
}
135130

136131
@Test
@@ -143,8 +138,7 @@ void requiredInput() {
143138
assertThat(issue.getName()).isEqualTo("test");
144139
assertThat(issue.getValue()).isNull();
145140
assertThat(issue.getDetail()).isEqualTo("Input test is required in this context");
146-
assertThat(issue).extracting("href", "instance", "status", "inputs", "additionalProperties")
147-
.allMatch(this::isEmpty);
141+
assertThat(issue).extracting("href", "inputs", "additionalProperties").allMatch(this::isEmpty);
148142
}
149143

150144
@Test
@@ -158,8 +152,7 @@ void replacedSsin() {
158152
assertThat(issue.getValue()).isEqualTo("00000000196");
159153
assertThat(issue.getDetail()).isEqualTo("SSIN 00000000196 has been replaced by 00000000295");
160154
assertThat(issue.getAdditionalProperties()).containsExactly(entry("replacedBy", "00000000295"));
161-
assertThat(issue).extracting("href", "instance", "status", "inputs")
162-
.allMatch(this::isEmpty);
155+
assertThat(issue).extracting("href", "inputs").allMatch(this::isEmpty);
163156
}
164157

165158
@Test
@@ -172,8 +165,7 @@ void canceledSsin() {
172165
assertThat(issue.getName()).isEqualTo("ssin");
173166
assertThat(issue.getValue()).isEqualTo("00000000196");
174167
assertThat(issue.getDetail()).isEqualTo("SSIN 00000000196 has been canceled");
175-
assertThat(issue).extracting("href", "instance", "status", "inputs", "additionalProperties")
176-
.allMatch(this::isEmpty);
168+
assertThat(issue).extracting("href", "inputs", "additionalProperties").allMatch(this::isEmpty);
177169
}
178170

179171
@Test
@@ -186,8 +178,7 @@ void invalidSsin() {
186178
assertThat(issue.getName()).isEqualTo("ssin");
187179
assertThat(issue.getValue()).isEqualTo("00000000195");
188180
assertThat(issue.getDetail()).isEqualTo("SSIN 00000000195 is invalid");
189-
assertThat(issue).extracting("href", "instance", "status", "inputs", "additionalProperties")
190-
.allMatch(this::isEmpty);
181+
assertThat(issue).extracting("href", "inputs", "additionalProperties").allMatch(this::isEmpty);
191182
}
192183

193184
@Test
@@ -200,8 +191,7 @@ void unknownSsin() {
200191
assertThat(issue.getName()).isEqualTo("ssin");
201192
assertThat(issue.getValue()).isEqualTo("00000000196");
202193
assertThat(issue.getDetail()).isEqualTo("SSIN 00000000196 does not exist");
203-
assertThat(issue).extracting("href", "instance", "status", "inputs", "additionalProperties")
204-
.allMatch(this::isEmpty);
194+
assertThat(issue).extracting("href", "inputs", "additionalProperties").allMatch(this::isEmpty);
205195
}
206196

207197
@Test
@@ -214,8 +204,7 @@ void invalidPeriod() {
214204
assertThat(issue.getName()).isEqualTo("period");
215205
assertThat(issue.getValue()).isEqualTo("value");
216206
assertThat(issue.getDetail()).isEqualTo("endDate should not precede startDate");
217-
assertThat(issue).extracting("href", "instance", "status", "inputs", "additionalProperties")
218-
.allMatch(this::isEmpty);
207+
assertThat(issue).extracting("href", "inputs", "additionalProperties").allMatch(this::isEmpty);
219208
}
220209

221210
@Test
@@ -227,7 +216,7 @@ void invalidPeriodLocalDate() {
227216
assertThat(issue.getTitle()).isEqualTo("Period is invalid");
228217
assertThat(issue.getInputs()).containsExactly(startDate, endDate);
229218
assertThat(issue.getDetail()).isEqualTo("endDate should not precede startDate");
230-
assertThat(issue).extracting("href", "instance", "status", "in", "name", "value", "additionalProperties")
219+
assertThat(issue).extracting("href", "in", "name", "value", "additionalProperties")
231220
.allMatch(this::isEmpty);
232221
}
233222

@@ -242,7 +231,7 @@ void invalidPeriodOffsetDateTime() {
242231
assertThat(issue.getTitle()).isEqualTo("Period is invalid");
243232
assertThat(issue.getInputs()).containsExactly(startDateTime, endDateTime);
244233
assertThat(issue.getDetail()).isEqualTo("endDateTime should not precede startDateTime");
245-
assertThat(issue).extracting("href", "instance", "status", "in", "name", "value", "additionalProperties")
234+
assertThat(issue).extracting("href", "in", "name", "value", "additionalProperties")
246235
.allMatch(this::isEmpty);
247236
}
248237

@@ -256,8 +245,7 @@ void invalidIncompleteDate() {
256245
assertThat(issue.getName()).isEqualTo("test");
257246
assertThat(issue.getValue()).isEqualTo("2024-00-01");
258247
assertThat(issue.getDetail()).isEqualTo("Incomplete date 2024-00-01 is invalid");
259-
assertThat(issue).extracting("href", "instance", "status", "inputs", "additionalProperties")
260-
.allMatch(this::isEmpty);
248+
assertThat(issue).extracting("href", "inputs", "additionalProperties").allMatch(this::isEmpty);
261249
}
262250

263251
@Test
@@ -270,8 +258,7 @@ void invalidYearMonth() {
270258
assertThat(issue.getName()).isEqualTo("test");
271259
assertThat(issue.getValue()).isEqualTo("2024-13");
272260
assertThat(issue.getDetail()).isEqualTo("Year month 2024-13 is invalid");
273-
assertThat(issue).extracting("href", "instance", "status", "inputs", "additionalProperties")
274-
.allMatch(this::isEmpty);
261+
assertThat(issue).extracting("href", "inputs", "additionalProperties").allMatch(this::isEmpty);
275262
}
276263

277264
@Test
@@ -284,8 +271,7 @@ void invalidEnterpriseNumber() {
284271
assertThat(issue.getName()).isEqualTo("test");
285272
assertThat(issue.getValue()).isEqualTo("0000000001");
286273
assertThat(issue.getDetail()).isEqualTo("Enterprise number 0000000001 is invalid");
287-
assertThat(issue).extracting("href", "instance", "status", "inputs", "additionalProperties")
288-
.allMatch(this::isEmpty);
274+
assertThat(issue).extracting("href", "inputs", "additionalProperties").allMatch(this::isEmpty);
289275
}
290276

291277
@Test
@@ -298,8 +284,7 @@ void invalidEstablishmentUnitNumber() {
298284
assertThat(issue.getName()).isEqualTo("test");
299285
assertThat(issue.getValue()).isEqualTo("0000000001");
300286
assertThat(issue.getDetail()).isEqualTo("Establishment unit number 0000000001 is invalid");
301-
assertThat(issue).extracting("href", "instance", "status", "inputs", "additionalProperties")
302-
.allMatch(this::isEmpty);
287+
assertThat(issue).extracting("href", "inputs", "additionalProperties").allMatch(this::isEmpty);
303288
}
304289

305290
@Test
@@ -310,7 +295,7 @@ void exactlyOneOfExpected() {
310295
assertThat(issue.getTitle()).isEqualTo("Exactly one of these inputs must be present");
311296
assertThat(issue.getInputs()).isEqualTo(inputs);
312297
assertThat(issue.getDetail()).isEqualTo("Exactly one of these inputs must be present: a, b");
313-
assertThat(issue).extracting("href", "instance", "status", "in", "name", "value", "additionalProperties")
298+
assertThat(issue).extracting("href", "in", "name", "value", "additionalProperties")
314299
.allMatch(this::isEmpty);
315300
}
316301

@@ -322,7 +307,7 @@ void anyOfExpected() {
322307
assertThat(issue.getTitle()).isEqualTo("Any of these inputs must be present");
323308
assertThat(issue.getInputs()).isEqualTo(inputs);
324309
assertThat(issue.getDetail()).isEqualTo("Any of these inputs must be present: a, b");
325-
assertThat(issue).extracting("href", "instance", "status", "in", "name", "value", "additionalProperties")
310+
assertThat(issue).extracting("href", "in", "name", "value", "additionalProperties")
326311
.allMatch(this::isEmpty);
327312
}
328313

@@ -334,7 +319,7 @@ void zeroOrExactlyOneOfExpected() {
334319
assertThat(issue.getTitle()).isEqualTo("Exactly one or none of these inputs must be present");
335320
assertThat(issue.getInputs()).isEqualTo(inputs);
336321
assertThat(issue.getDetail()).isEqualTo("Exactly one or none of these inputs must be present: a, b");
337-
assertThat(issue).extracting("href", "instance", "status", "in", "name", "value", "additionalProperties")
322+
assertThat(issue).extracting("href", "in", "name", "value", "additionalProperties")
338323
.allMatch(this::isEmpty);
339324
}
340325

@@ -346,7 +331,7 @@ void zeroOrAllOfExpected() {
346331
assertThat(issue.getTitle()).isEqualTo("All or none of these inputs must be present");
347332
assertThat(issue.getInputs()).isEqualTo(inputs);
348333
assertThat(issue.getDetail()).isEqualTo("All or none of these inputs must be present: a, b");
349-
assertThat(issue).extracting("href", "instance", "status", "in", "name", "value", "additionalProperties")
334+
assertThat(issue).extracting("href", "in", "name", "value", "additionalProperties")
350335
.allMatch(this::isEmpty);
351336
}
352337

@@ -358,7 +343,7 @@ void equalExpected() {
358343
assertThat(issue.getTitle()).isEqualTo("These inputs must be equal");
359344
assertThat(issue.getInputs()).isEqualTo(inputs);
360345
assertThat(issue.getDetail()).isEqualTo("These inputs must be equal: a, b");
361-
assertThat(issue).extracting("href", "instance", "status", "in", "name", "value", "additionalProperties")
346+
assertThat(issue).extracting("href", "in", "name", "value", "additionalProperties")
362347
.allMatch(this::isEmpty);
363348
}
364349

0 commit comments

Comments
 (0)