Skip to content

Commit 7d51311

Browse files
committed
fix #461: add minlength breaking change detection
1 parent e92f6de commit 7d51311

File tree

4 files changed

+74
-2
lines changed

4 files changed

+74
-2
lines changed

core/src/main/java/org/openapitools/openapidiff/core/model/BackwardIncompatibleProp.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public enum BackwardIncompatibleProp {
1414
REQUEST_CONTENT_DECREASED("incompatible.request.content.decreased", true),
1515
REQUEST_ENUM_DECREASED("incompatible.request.enum.decreased", true),
1616
REQUEST_MAX_LENGTH_DECREASED("incompatible.request.max.length.decreased", true),
17-
REQUEST_MIN_LENGTH_INCREASED("incompatible.request.min.length.increased", true),
17+
REQUEST_MIN_LENGTH_INCREASED("incompatible.request.min.length.increased", false),
1818
REQUEST_NUMERIC_RANGE_DECREASED("incompatible.request.numeric.range.decreased", true),
1919
REQUEST_ONEOF_DECREASED("incompatible.request.oneof.decreased", true),
2020
REQUEST_PARAM_ALLOWEMPTY_DECREASED("incompatible.request.param.allowempty.decreased", true),
@@ -32,7 +32,7 @@ public enum BackwardIncompatibleProp {
3232
RESPONSE_HEADER_REQUIRED_INCREASED("incompatible.response.header.required.increased", true),
3333
RESPONSE_HEADERS_DECREASED("incompatible.response.headers.decreased", true),
3434
RESPONSE_MAX_LENGTH_INCREASED("incompatible.response.max.length.increased", true),
35-
RESPONSE_MIN_LENGTH_INCREASED("incompatible.response.min.length.increased", true),
35+
RESPONSE_MIN_LENGTH_INCREASED("incompatible.response.min.length.increased", false),
3636
RESPONSE_NUMERIC_RANGE_INCREASED("incompatible.response.numeric.range.increased", false),
3737
RESPONSE_ONEOF_INCREASED("incompatible.response.oneof.increased", true),
3838
RESPONSE_REQUIRED_DECREASED("incompatible.response.required.decreased", true),

core/src/test/java/org/openapitools/openapidiff/core/backcompat/MinLengthBCTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.openapitools.openapidiff.core.backcompat;
22

3+
import static org.openapitools.openapidiff.core.TestUtils.assertSpecChangedButCompatible;
34
import static org.openapitools.openapidiff.core.TestUtils.assertSpecIncompatible;
45
import static org.openapitools.openapidiff.core.TestUtils.assertSpecUnchanged;
56
import static org.openapitools.openapidiff.core.model.BackwardIncompatibleProp.REQUEST_MIN_LENGTH_INCREASED;
@@ -22,9 +23,19 @@ public void requestMinLengthIncreased() {
2223
assertSpecIncompatible(BASE, "bc_request_minlength_increased.yaml", prop);
2324
}
2425

26+
@Test
27+
public void requestMinLengthDecreasedButCompatible() {
28+
assertSpecChangedButCompatible(BASE, "bc_request_minlength_changed_but_compatible.yaml");
29+
}
30+
2531
@Test
2632
public void responseMinLengthIncreased() {
2733
BackwardIncompatibleProp prop = RESPONSE_MIN_LENGTH_INCREASED;
2834
assertSpecIncompatible(BASE, "bc_response_minlength_increased.yaml", prop);
2935
}
36+
37+
@Test
38+
public void responseMinLengthDecreasedButCompatible() {
39+
assertSpecChangedButCompatible(BASE, "bc_response_minlength_changed_but_compatible.yaml");
40+
}
3041
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
openapi: 3.0.0
2+
info:
3+
description: myDesc
4+
title: myTitle
5+
version: 1.0.0
6+
paths:
7+
/widgets:
8+
post:
9+
operationId: widgetCreate
10+
requestBody:
11+
content:
12+
application/json:
13+
schema:
14+
type: string
15+
minLength: 3
16+
application/xml:
17+
schema:
18+
type: string
19+
responses:
20+
'200':
21+
description: successful operation
22+
content:
23+
application/json:
24+
schema:
25+
type: string
26+
minLength: 5
27+
application/xml:
28+
schema:
29+
type: string
30+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
openapi: 3.0.0
2+
info:
3+
description: myDesc
4+
title: myTitle
5+
version: 1.0.0
6+
paths:
7+
/widgets:
8+
post:
9+
operationId: widgetCreate
10+
requestBody:
11+
content:
12+
application/json:
13+
schema:
14+
type: string
15+
minLength: 5
16+
application/xml:
17+
schema:
18+
type: string
19+
responses:
20+
'200':
21+
description: successful operation
22+
content:
23+
application/json:
24+
schema:
25+
type: string
26+
minLength: 3
27+
application/xml:
28+
schema:
29+
type: string
30+
minLength: 3
31+

0 commit comments

Comments
 (0)