Skip to content

Commit 9ce97d2

Browse files
committed
Fixed panic for ref combinations
Increased converage to >90% (more to do) Refactored check code to improve readability and testability Signed-off-by: Jason Wraxall <wjase@yahoo.com.au>
1 parent bdff91e commit 9ce97d2

15 files changed

+1299
-95
lines changed

diff/fixtures/enum.diff.txt

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
NON-BREAKING CHANGES:
2-
=====================
3-
/a/:get -> 200 Response - array[A1].personality : string - Deleted possible enumeration(s) <crazy>
4-
/a/:get Request - Query.personality - Added possible enumeration(s) <extrovert>
5-
/a/{id}:get -> 200 Response - array[A1].personality : string - Deleted possible enumeration(s) <crazy>
6-
/b/:get -> 200 Response - array[A1].personality : string - Deleted possible enumeration(s) <crazy>
2+
=====================
3+
/a/:get - Request - Query.personality<string> - Added possible enumeration(s) - extrovert
4+
/a/:get -> 200 - Response - Body<array[A1]>.personality<string> - Deleted possible enumeration(s) - crazy
5+
/a/{id}:get -> 200 - Response - Body<array[A1]>.personality<string> - Deleted possible enumeration(s) - crazy
6+
/b/:get -> 200 - Response - Body<array[A1]>.personality<string> - Deleted possible enumeration(s) - crazy
77

8-
BREAKING CHANGES:
9-
=================
10-
/a/:get -> 200 Response - array[A1].personality : string - Added possible enumeration(s) <sane>
11-
/a/:get Request - Query.personality - Deleted possible enumeration(s) <saucy>
12-
/a/{id}:get -> 200 Response - array[A1].personality : string - Added possible enumeration(s) <sane>
13-
/b/:get -> 200 Response - array[A1].personality : string - Added possible enumeration(s) <sane>
14-
15-
compatibility test FAILED: 4 breaking changes detected
8+
BREAKING CHANGES:
9+
=================
10+
/a/:get - Request - Query.personality<string> - Deleted possible enumeration(s) - saucy
11+
/a/:get -> 200 - Response - Body<array[A1]>.personality<string> - Added possible enumeration(s) - sane
12+
/a/{id}:get -> 200 - Response - Body<array[A1]>.personality<string> - Added possible enumeration(s) - sane
13+
/b/:get -> 200 - Response - Body<array[A1]>.personality<string> - Added possible enumeration(s) - sane
14+
compatibility test FAILED: 4 breaking changes detected

diff/fixtures/kitchensink.diff.txt

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
NON-BREAKING CHANGES:
2-
=====================
3-
Metadata - Spec.consumes - Added a consumes format <bob>
4-
Metadata - Spec.produces - Deleted produces format <bill>
5-
Metadata - Spec.schemes - Added schemes <https>
6-
/a/:get -> 200 Response- Added response
7-
/a/:get Request - Header.addedHeaderParam : string - Added optional param
8-
/a/:get Request - Header.deletedHeaderParam : string - Deleted optional param
9-
/a/:get Request - Header.headerParam.headerParam : string - Widened type <string.password -> string>
10-
/a/:get Request - Query.changeMaxInt - Widened type <Maximum 200.000000->300.000000>
11-
/a/:get Request - Query.removeMaxInt - Widened type <Exclusive Maximum Removed:true->false>
12-
/a/:get Request - Query.wideryString - Widened type <integer -> string>
2+
=====================
3+
/a/:get - Request - Header.addedHeaderParam - Added optional param
4+
/a/:get - Request - Header.deletedHeaderParam - Deleted optional param
5+
/a/:get - Request - Header.headerParam<string> - Widened type - string.password -> string
6+
/a/:get - Request - Query.removeMaxInt<integer> - Widened type - Exclusive Maximum Removed:true->false
7+
/a/:get - Request - Query.wideryString<string> - Widened type - integer -> string
8+
/a/:get -> 200 - Response - Body<array[A1]> - Added response
9+
/c/:get -> 200 - Response - Body<array[object]> - Added a schema constraint - MaxItems(1)
10+
Spec Definitions.ThisWasAdded - Added a schema definition
11+
Spec.consumes - Added a consumes format - bob
12+
Spec.produces - Added produces format - bob
13+
Spec.schemes - Added schemes - https
1314

14-
BREAKING CHANGES:
15-
=================
16-
Metadata - Spec Metadata - Changed base path </api -> /apibaby>
17-
Metadata - Spec Metadata - Changed host URL <petstore.swagger.wordnik.com -> petstore.swaggery.wordnik.com>
18-
Metadata - Spec.consumes - Deleted a consumes format <bill>
19-
Metadata - Spec.produces - Added produces format <bob>
20-
Metadata - Spec.schemes - Deleted schemes <http>
21-
/a/:get Request - Query.ObjToPrim - Changed type <obj -> integer>
22-
/a/:get Request - Query.changeMaxInt - Narrowed type <Exclusive Maximum Added:false->true>
23-
/a/:get Request - Query.changeMinInt - Narrowed type <Exclusive Minimum Added:false->true>
24-
/a/:get Request - Query.changeMinInt - Narrowed type <Minimum 200.000000->300.000000>
25-
/a/:get Request - Query.changeyPattern - Changed type <Pattern Changed:*->anewpattern>
26-
/a/:get Request - Query.primToObj : A2 - Changed type <integer -> obj>
27-
28-
compatibility test FAILED: 11 breaking changes detected
15+
BREAKING CHANGES:
16+
=================
17+
/a/:get - Request - Query.ObjToPrim<integer> - Changed type - obj -> integer
18+
/a/:get - Request - Query.changeMaxInt<integer> - Narrowed type - Exclusive Maximum Added:false->true
19+
/a/:get - Request - Query.changeMinInt<integer> - Narrowed type - Exclusive Minimum Added:false->true
20+
/a/:get - Request - Query.changeyPattern<string> - Changed type - Pattern Changed:*->anewpattern
21+
/a/:get - Request - Query.primToObj - Changed type - integer -> obj
22+
/c/:get -> 200 - Response - Body<array[object]> - Deleted a schema constraint - MinItems(1)
23+
Spec Metadata - Changed base path - /api -> /apibaby
24+
Spec Metadata - Changed host URL - petstore.swagger.wordnik.com -> petstore.swaggery.wordnik.com
25+
Spec.consumes - Deleted a consumes format - bill
26+
Spec.produces - Deleted produces format - bill
27+
Spec.schemes - Deleted schemes - http
28+
compatibility test FAILED: 11 breaking changes detected

diff/fixtures/kitchensink.v1.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,25 @@
230230
}
231231
}
232232
}
233+
},
234+
"/c/": {
235+
"get": {
236+
"responses": {
237+
"200": {
238+
"description": "200 response",
239+
"schema": {
240+
"type": "array",
241+
"minItems": 1,
242+
"items": {
243+
"type": "object",
244+
"properties":{
245+
"id": {"type": "integer"}
246+
}
247+
}
248+
}
249+
}
250+
}
251+
}
233252
}
234253
},
235254
"definitions": {

diff/fixtures/kitchensink.v2.json

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,31 @@
223223
}
224224
}
225225
}
226+
},
227+
"/c/": {
228+
"get": {
229+
"responses": {
230+
"200": {
231+
"description": "200 response",
232+
"schema": {
233+
"type": "array",
234+
"maxItems": 1,
235+
"items": {
236+
"type": "object",
237+
"properties":{
238+
"id": {"type": "integer"}
239+
}
240+
}
241+
}
242+
}
243+
}
244+
}
226245
}
227246
},
228247
"definitions": {
229248
"A1": {
230249
"type": "object",
250+
"required": ["id"],
231251
"properties": {
232252
"id": {
233253
"type": "integer"
@@ -248,8 +268,21 @@
248268
"A2": {
249269
"type": "object",
250270
"required": [
251-
"name",
252-
"description"
271+
"name"
272+
],
273+
"properties": {
274+
"name": {
275+
"type": "string"
276+
},
277+
"description": {
278+
"type": "string"
279+
}
280+
}
281+
},
282+
"ThisWasAdded": {
283+
"type": "object",
284+
"required": [
285+
"name"
253286
],
254287
"properties": {
255288
"name": {

diff/fixtures/param.diff.txt

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
11
NON-BREAKING CHANGES:
2-
=====================
3-
/a/:get Request - Query.limit - Deleted optional param
4-
/a/{id}:get -> 200 Response - Headers.newResponseHeader - Added response header
5-
/a/{id}:get Request - Query.newOptParam - Added optional param
6-
/a/{id}:get Request - Query.widenedParam - Widened type <integer.int32 -> integer.int64>
7-
/a/{id}:post Request - Header.newboris - Added optional param
8-
/a/{id}:post Request - Header.optboris - Deleted optional param
9-
/a/{id}:post Request - Header.reqdboris - Deleted required param
2+
=====================
3+
/a/:get - Request - Query.limit<integer> - Deleted optional param
4+
/a/{id}:get - Request - Query.newOptParam<string> - Added optional param
5+
/a/{id}:get - Request - Query.widenedParam<integer.int64> - Widened type - integer.int32 -> integer.int64
6+
/a/{id}:get -> 200 - Response - Headers.newResponseHeader - Added response header
7+
/a/{id}:post - Request - Header.newboris<string> - Added optional param
8+
/a/{id}:post - Request - Header.optboris<string> - Deleted optional param
9+
/a/{id}:post - Request - Header.reqdboris<string> - Deleted required param
1010

11-
BREAKING CHANGES:
12-
=================
13-
/a/:post -> 200 Response - otherDeletedName : string - Deleted property
14-
/a/{id}:get -> 200 Response - Headers.optResponseHeader - Deleted response header
15-
/a/{id}:get Request - Path.id - Narrowed type <string -> integer>
16-
/a/{id}:get Request - Query.flavour - Changed optional param to required
17-
/a/{id}:get Request - Query.newReqParam - Added required param
18-
/a/{id}:post -> 200 Response - otherDeletedName : string - Deleted property
19-
/a/{id}:post Request - Header.changedboris - Narrowed type <string -> integer>
20-
/b/:post -> 200 Response - otherDeletedName : string - Deleted property
21-
22-
compatibility test FAILED: 8 breaking changes detected
11+
BREAKING CHANGES:
12+
=================
13+
/a/:post -> 200 - Response - Body<A3>.otherDeletedName<string> - Deleted property
14+
/a/{id}:get - Request - Path.id<integer> - Narrowed type - string -> integer
15+
/a/{id}:get - Request - Query.flavour<string> - Added required property
16+
/a/{id}:get - Request - Query.newReqParam<string> - Added required param
17+
/a/{id}:get -> 200 - Response - Headers.optResponseHeader - Deleted response header
18+
/a/{id}:post - Request - Header.changedboris<integer> - Narrowed type - string -> integer
19+
/a/{id}:post -> 200 - Response - Body<A3>.otherDeletedName<string> - Deleted property
20+
/b/:post -> 200 - Response - Body<A3>.otherDeletedName<string> - Deleted property
21+
compatibility test FAILED: 8 breaking changes detected

diff/fixtures/path.diff.txt

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
NON-BREAKING CHANGES:
2-
=====================
3-
/a/:put Request- Added endpoint
4-
/a/{id}:post Request- Deleted a deprecated endpoint
5-
/newpath/:post Request- Added endpoint
2+
=====================
3+
/a/:put - Request - Added endpoint
4+
/a/{id}:post - Request - Deleted a deprecated endpoint
5+
/newpath/:post - Request - Added endpoint
66

7-
BREAKING CHANGES:
8-
=================
9-
/a/:post Request- Deleted endpoint
10-
/b/:post Request- Deleted endpoint
11-
12-
compatibility test FAILED: 2 breaking changes detected
7+
BREAKING CHANGES:
8+
=================
9+
/a/:post - Request - Deleted endpoint
10+
/b/:post - Request - Deleted endpoint
11+
compatibility test FAILED: 2 breaking changes detected

diff/fixtures/refprop.diff.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
BREAKING CHANGES:
2+
=================
3+
/a/:get -> 200 - Response - Body<array[A1]>.wasRef<A5> - Changed type - <A5> -> <string>
4+
/a/{id}:patch - Request - Body.changeRef<A5> - Changed ref to different object - <A5> -> <A1>
5+
/b/:post - Request - Body.wasRef<A5> - Changed type - <A5> -> <string>
6+
/b/:post -> 200 - Response - Body<A1>.wasRef<A5> - Changed type - <A5> -> <string>
7+
compatibility test FAILED: 4 breaking changes detected

0 commit comments

Comments
 (0)