-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changelog: request param required flag changed (#288)
* Add request param required property update checker * Update breaking changes * Update localizations * Lint * Handle info logs * update examples * Extend check backward compatibility to use levels * Update examples * rm "is not breaking" from changelog comments --------- Co-authored-by: Reuven <[email protected]>
- Loading branch information
Showing
12 changed files
with
113 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
checker/checker_request_parameter_required_value_updated_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package checker_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/getkin/kin-openapi/openapi3" | ||
"github.com/stretchr/testify/require" | ||
"github.com/tufin/oasdiff/checker" | ||
"github.com/tufin/oasdiff/diff" | ||
) | ||
|
||
// BC: changing an existing header param from optional to required is breaking | ||
func TestBreaking_HeaderParamBecameRequired(t *testing.T) { | ||
s1 := l(t, 1) | ||
s2 := l(t, 1) | ||
|
||
s1.Spec.Paths[installCommandPath].Get.Parameters.GetByInAndName(openapi3.ParameterInHeader, "network-policies").Required = false | ||
s2.Spec.Paths[installCommandPath].Get.Parameters.GetByInAndName(openapi3.ParameterInHeader, "network-policies").Required = true | ||
|
||
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), &s1, &s2) | ||
require.NoError(t, err) | ||
errs := checker.CheckBackwardCompatibility(singleCheckConfig(checker.RequestParameterRequiredValueUpdatedCheck), d, osm) | ||
require.NotEmpty(t, errs) | ||
require.Equal(t, checker.BackwardCompatibilityErrors{ | ||
{ | ||
Id: "request-parameter-became-required", | ||
Text: "the 'header' request parameter 'network-policies' became required", | ||
Comment: "", | ||
Level: checker.ERR, | ||
Operation: "GET", | ||
Path: "/api/{domain}/{project}/install-command", | ||
Source: "../data/openapi-test1.yaml", | ||
}}, errs) | ||
} | ||
|
||
// CL: changing an existing header param from required to optional | ||
func TestBreaking_HeaderParamBecameOptional(t *testing.T) { | ||
s1 := l(t, 1) | ||
s2 := l(t, 1) | ||
|
||
s1.Spec.Paths[installCommandPath].Get.Parameters.GetByInAndName(openapi3.ParameterInHeader, "network-policies").Required = true | ||
s2.Spec.Paths[installCommandPath].Get.Parameters.GetByInAndName(openapi3.ParameterInHeader, "network-policies").Required = false | ||
|
||
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), &s1, &s2) | ||
require.NoError(t, err) | ||
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestParameterRequiredValueUpdatedCheck), d, osm, checker.INFO) | ||
require.NotEmpty(t, errs) | ||
require.Equal(t, checker.BackwardCompatibilityErrors{ | ||
{ | ||
Id: "request-parameter-became-optional", | ||
Text: "the 'header' request parameter 'network-policies' became optional", | ||
Comment: "", | ||
Level: checker.INFO, | ||
Operation: "GET", | ||
Path: "/api/{domain}/{project}/install-command", | ||
Source: "../data/openapi-test1.yaml", | ||
}}, errs) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.