Skip to content

Commit 494462e

Browse files
Add Diff for OpenAPI Extensions (#515)
1 parent 05b7335 commit 494462e

114 files changed

Lines changed: 995 additions & 663 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/go.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: true
1717
matrix:
18-
go: ['1.22.1']
18+
go: ['1.22.2']
1919
os:
2020
- ubuntu-latest
2121
- windows-latest
@@ -88,10 +88,11 @@ jobs:
8888
run: |
8989
! git grep -InE 'json:"' | grep -v _test.go | grep -v yaml:
9090
91-
- uses: codecov/codecov-action@v3
91+
- uses: codecov/codecov-action@v4
9292
with:
9393
files: ./coverage.txt
9494
flags: unittests # optional
9595
name: codecov-umbrella # optional
96-
fail_ci_if_error: true # optional (default = false)
97-
verbose: true # optional (default = false)
96+
fail_ci_if_error: false # optional (default = false)
97+
verbose: true # optional (default = false)
98+
token: ${{ secrets.CODECOV_TOKEN }} # required

.github/workflows/vuln.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ jobs:
1616
- id: govulncheck
1717
uses: golang/govulncheck-action@v1
1818
with:
19-
go-version-input: 1.22.1
19+
go-version-input: 1.22.2

BREAKING-CHANGES-EXAMPLES.md

Lines changed: 37 additions & 37 deletions
Large diffs are not rendered by default.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
### Go get dependecies and build ###
2-
FROM golang:1.22.1 as builder
2+
FROM golang:1.22.2 as builder
33
ENV PLATFORM docker
44
WORKDIR /go/src/app
55
COPY go.mod go.sum ./

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,13 +254,13 @@ oasdiff diff data/header-case/base.yaml data/header-case/revision.yaml --case-in
254254
## Excluding Specific Kinds of Changes
255255
You can use the `--exclude-elements` flag to exclude certain kinds of changes:
256256
- Use `--exclude-elements examples` to exclude [Examples](https://swagger.io/specification/#example-object)
257+
- Use `--exclude-elements extensions` to exclude [Extensions](https://swagger.io/specification/#specification-extensions)
257258
- Use `--exclude-elements description` to exclude description fields
258259
- Use `--exclude-elements title` to exclude title fields
259260
- Use `--exclude-elements summary` to exclude summary fields
260261
- Use `--exclude-elements endpoints` to exclude the [endpoints diff](#paths-vs-endpoints)
261262
262263
You can ignore multiple elements with a comma-separated list of excluded elements as in [this example](#ignore-changes-to-description-and-examples).
263-
Note that [Extensions](https://swagger.io/specification/#specification-extensions) are always excluded from the diff.
264264
265265
## Excluding Specific Endpoints
266266
You can filter endpoints in two ways:

checker/check-api-added_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func TestApiAdded_DetectsNewPathsAndNewOperations(t *testing.T) {
1616
s2, err := open("../data/new_endpoints/revision.yaml")
1717
require.NoError(t, err)
1818

19-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
19+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
2020
require.NoError(t, err)
2121

2222
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIAddedCheck), d, osm, checker.INFO)
@@ -44,7 +44,7 @@ func TestApiAdded_DetectsModifiedPathsWithPathParam(t *testing.T) {
4444
s2, err := open("../data/new_endpoints/revision_with_path_param.yaml")
4545
require.NoError(t, err)
4646

47-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
47+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
4848
require.NoError(t, err)
4949

5050
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIAddedCheck), d, osm, checker.INFO)

checker/check-api-operation-id-updated_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestOperationIdRemoved(t *testing.T) {
1818

1919
s2.Spec.Paths.Value("/api/v1.0/groups").Post.OperationID = ""
2020

21-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
21+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
2222
require.NoError(t, err)
2323
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIOperationIdUpdatedCheck), d, osm, checker.INFO)
2424
require.Len(t, errs, 1)
@@ -42,7 +42,7 @@ func TestOperationIdUpdated(t *testing.T) {
4242

4343
s2.Spec.Paths.Value("/api/v1.0/groups").Post.OperationID = "newOperationId"
4444

45-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
45+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
4646
require.NoError(t, err)
4747
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIOperationIdUpdatedCheck), d, osm, checker.INFO)
4848
require.Len(t, errs, 1)
@@ -68,7 +68,7 @@ func TestOperationIdAdded(t *testing.T) {
6868

6969
s2.Spec.Paths.Value("/api/v1.0/groups").Post.OperationID = "NewOperationId"
7070

71-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig().WithCheckBreaking(), s1, s2)
71+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
7272
require.NoError(t, err)
7373
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIOperationIdUpdatedCheck), d, osm, checker.INFO)
7474
require.Len(t, errs, 1)

checker/check-api-security-updated_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ func TestAPIGlobalSecurityyAdded(t *testing.T) {
1616
s2, err := open("../data/checker/api_security_global_added_revision.yaml")
1717
require.NoError(t, err)
1818

19-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
19+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
2020
require.NoError(t, err)
2121
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APISecurityUpdatedCheck), d, osm, checker.INFO)
2222
require.Len(t, errs, 1)
@@ -35,7 +35,7 @@ func TestAPIGlobalSecurityyDeleted(t *testing.T) {
3535
s2, err := open("../data/checker/api_security_global_added_base.yaml")
3636
require.NoError(t, err)
3737

38-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
38+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
3939
require.NoError(t, err)
4040
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APISecurityUpdatedCheck), d, osm, checker.INFO)
4141
require.Len(t, errs, 1)
@@ -55,7 +55,7 @@ func TestAPIGlobalSecurityScopeRemoved(t *testing.T) {
5555
require.NoError(t, err)
5656

5757
s2.Spec.Security[0]["petstore_auth"] = s2.Spec.Security[0]["petstore_auth"][:1]
58-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
58+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
5959
require.NoError(t, err)
6060
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APISecurityUpdatedCheck), d, osm, checker.INFO)
6161
require.Len(t, errs, 1)
@@ -75,7 +75,7 @@ func TestAPIGlobalSecurityScopeAdded(t *testing.T) {
7575
require.NoError(t, err)
7676

7777
s1.Spec.Security[0]["petstore_auth"] = s2.Spec.Security[0]["petstore_auth"][:1]
78-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
78+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
7979
require.NoError(t, err)
8080
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APISecurityUpdatedCheck), d, osm, checker.INFO)
8181
require.Len(t, errs, 1)
@@ -94,7 +94,7 @@ func TestAPISecurityAdded(t *testing.T) {
9494
s2, err := open("../data/checker/api_security_added_revision.yaml")
9595
require.NoError(t, err)
9696

97-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
97+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
9898
require.NoError(t, err)
9999
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APISecurityUpdatedCheck), d, osm, checker.INFO)
100100
require.Len(t, errs, 1)
@@ -116,7 +116,7 @@ func TestAPISecurityDeleted(t *testing.T) {
116116
s2, err := open("../data/checker/api_security_added_base.yaml")
117117
require.NoError(t, err)
118118

119-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
119+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
120120
require.NoError(t, err)
121121
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APISecurityUpdatedCheck), d, osm, checker.INFO)
122122
require.Len(t, errs, 1)
@@ -138,7 +138,7 @@ func TestAPISecurityScopeRemoved(t *testing.T) {
138138
s2, err := open("../data/checker/api_security_updated_revision.yaml")
139139
require.NoError(t, err)
140140

141-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
141+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
142142
require.NoError(t, err)
143143
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APISecurityUpdatedCheck), d, osm, checker.INFO)
144144
require.Len(t, errs, 1)
@@ -160,7 +160,7 @@ func TestAPISecurityScopeAdded(t *testing.T) {
160160
s2, err := open("../data/checker/api_security_updated_base.yaml")
161161
require.NoError(t, err)
162162

163-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
163+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
164164
require.NoError(t, err)
165165
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APISecurityUpdatedCheck), d, osm, checker.INFO)
166166
require.Len(t, errs, 1)

checker/check-api-tag-updated_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func TestTagAdded(t *testing.T) {
1818

1919
s2.Spec.Paths.Value("/api/v1.0/groups").Post.Tags = []string{"newTag"}
2020

21-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
21+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
2222
require.NoError(t, err)
2323
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APITagUpdatedCheck), d, osm, checker.INFO)
2424
require.Len(t, errs, 1)
@@ -43,7 +43,7 @@ func TestTagRemoved(t *testing.T) {
4343

4444
s2.Spec.Paths.Value("/api/v1.0/groups").Post.Tags = []string{}
4545

46-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
46+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
4747
require.NoError(t, err)
4848
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APITagUpdatedCheck), d, osm, checker.INFO)
4949
require.NotEmpty(t, errs)
@@ -70,7 +70,7 @@ func TestTagUpdated(t *testing.T) {
7070

7171
s2.Spec.Paths.Value("/api/v1.0/groups").Post.Tags = []string{"newTag"}
7272

73-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
73+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
7474
require.NoError(t, err)
7575
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APITagUpdatedCheck), d, osm, checker.INFO)
7676
require.NotEmpty(t, errs)

checker/check-components-security-updated_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func TestComponentSecurityOauthURLUpdated(t *testing.T) {
1717

1818
s2.Spec.Components.SecuritySchemes["petstore_auth"].Value.Flows.Implicit.AuthorizationURL = "http://example.new.org/api/oauth/dialog"
1919

20-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
20+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
2121
require.NoError(t, err)
2222
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIComponentsSecurityUpdatedCheck), d, osm, checker.INFO)
2323
require.Len(t, errs, 1)
@@ -39,7 +39,7 @@ func TestComponentSecurityOauthTokenUpdated(t *testing.T) {
3939

4040
s2.Spec.Components.SecuritySchemes["petstore_auth"].Value.Flows.Implicit.TokenURL = "http://example.new.org/api/oauth/dialog"
4141

42-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
42+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
4343
require.NoError(t, err)
4444
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIComponentsSecurityUpdatedCheck), d, osm, checker.INFO)
4545
require.Len(t, errs, 1)
@@ -61,7 +61,7 @@ func TestComponentSecurityTypeUpdated(t *testing.T) {
6161

6262
s2.Spec.Components.SecuritySchemes["petstore_auth"].Value.Type = "http"
6363

64-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
64+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
6565
require.NoError(t, err)
6666
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIComponentsSecurityUpdatedCheck), d, osm, checker.INFO)
6767
require.Len(t, errs, 1)
@@ -81,7 +81,7 @@ func TestComponentSecurityAdded(t *testing.T) {
8181
s2, err := open("../data/checker/component_security_updated_revision.yaml")
8282
require.NoError(t, err)
8383

84-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
84+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
8585
require.NoError(t, err)
8686
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIComponentsSecurityUpdatedCheck), d, osm, checker.INFO)
8787
require.Len(t, errs, 1)
@@ -101,7 +101,7 @@ func TestComponentSecurityRemoved(t *testing.T) {
101101
s2, err := open("../data/checker/component_security_updated_base.yaml")
102102
require.NoError(t, err)
103103

104-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
104+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
105105
require.NoError(t, err)
106106
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIComponentsSecurityUpdatedCheck), d, osm, checker.INFO)
107107
require.Len(t, errs, 1)
@@ -123,7 +123,7 @@ func TestComponentSecurityOauthScopeAdded(t *testing.T) {
123123

124124
s2.Spec.Components.SecuritySchemes["petstore_auth"].Value.Flows.Implicit.Scopes["admin:pets"] = "grants access to admin operations"
125125

126-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
126+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
127127
require.NoError(t, err)
128128
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIComponentsSecurityUpdatedCheck), d, osm, checker.INFO)
129129
require.Len(t, errs, 1)
@@ -146,7 +146,7 @@ func TestComponentSecurityOauthScopeRemoved(t *testing.T) {
146146
// Add to s1 so that it's deletion is identified
147147
s1.Spec.Components.SecuritySchemes["petstore_auth"].Value.Flows.Implicit.Scopes["admin:pets"] = "grants access to admin operations"
148148

149-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
149+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
150150
require.NoError(t, err)
151151
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIComponentsSecurityUpdatedCheck), d, osm, checker.INFO)
152152
require.Len(t, errs, 1)
@@ -168,7 +168,7 @@ func TestComponentSecurityOauthScopeUpdated(t *testing.T) {
168168

169169
s2.Spec.Components.SecuritySchemes["petstore_auth"].Value.Flows.Implicit.Scopes["read:pets"] = "grants access to pets (deprecated)"
170170

171-
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
171+
d, osm, err := diff.GetWithOperationsSourcesMap(diff.NewConfig(), s1, s2)
172172
require.NoError(t, err)
173173
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.APIComponentsSecurityUpdatedCheck), d, osm, checker.INFO)
174174
require.Len(t, errs, 1)

0 commit comments

Comments
 (0)