Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade-to-kin-openapi-v0.122.0 #450

Merged
merged 9 commits into from
Dec 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion checker/check-api-added.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func APIAddedCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSour
}

for _, path := range diffReport.PathsDiff.Added {
for opName, op := range diffReport.PathsDiff.Revision[path].Operations() {
for opName, op := range diffReport.PathsDiff.Revision.Value(path).Operations() {
appendErr(path, opName, op)
}
}
Expand Down
6 changes: 3 additions & 3 deletions checker/check-api-operation-id-updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestOperationIdRemoved(t *testing.T) {
s2, err := open("../data/checker/operation_id_removed_base.yaml")
require.NoError(t, err)

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

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -39,7 +39,7 @@ func TestOperationIdUpdated(t *testing.T) {
s2, err := open("../data/checker/operation_id_removed_base.yaml")
require.NoError(t, err)

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

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -65,7 +65,7 @@ func TestOperationIdAdded(t *testing.T) {
s2, err := open("../data/checker/operation_id_added_base.yaml")
require.NoError(t, err)

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

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig().WithCheckBreaking(), s1, s2)
require.NoError(t, err)
Expand Down
6 changes: 3 additions & 3 deletions checker/check-api-removed.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ func APIRemovedCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSo
}

for _, path := range diffReport.PathsDiff.Deleted {
if diffReport.PathsDiff.Base[path] == nil || diffReport.PathsDiff.Base[path].Operations() == nil {
if diffReport.PathsDiff.Base.Value(path) == nil || diffReport.PathsDiff.Base.Value(path).Operations() == nil {
continue
}
for operation := range diffReport.PathsDiff.Base[path].Operations() {
op := diffReport.PathsDiff.Base[path].Operations()[operation]
for operation := range diffReport.PathsDiff.Base.Value(path).Operations() {
op := diffReport.PathsDiff.Base.Value(path).Operations()[operation]
if !op.Deprecated {
source := "original_source=" + (*operationsSources)[op]
result = append(result, ApiChange{
Expand Down
6 changes: 3 additions & 3 deletions checker/check-api-tag-updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestTagAdded(t *testing.T) {
s2, err := open("../data/checker/tag_added_base.yaml")
require.NoError(t, err)

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

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -40,7 +40,7 @@ func TestTagRemoved(t *testing.T) {
s2, err := open("../data/checker/tag_removed_base.yaml")
require.NoError(t, err)

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

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -67,7 +67,7 @@ func TestTagUpdated(t *testing.T) {
s2, err := open("../data/checker/tag_removed_base.yaml")
require.NoError(t, err)

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

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions checker/check-request-body-required-value-updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestRequestBodyBecameRequired(t *testing.T) {
s2, err := open("../data/checker/request_body_became_required_base.yaml")
require.NoError(t, err)

s2.Spec.Paths["/api/v1.0/groups"].Post.RequestBody.Value.Required = true
s2.Spec.Paths.Value("/api/v1.0/groups").Post.RequestBody.Value.Required = true

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -38,7 +38,7 @@ func TestRequestBodyBecameOptional(t *testing.T) {
s2, err := open("../data/checker/request_body_became_optional_base.yaml")
require.NoError(t, err)

s2.Spec.Paths["/api/v1.0/groups"].Post.RequestBody.Value.Required = false
s2.Spec.Paths.Value("/api/v1.0/groups").Post.RequestBody.Value.Required = false

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig().WithCheckBreaking(), s1, s2)
require.NoError(t, err)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestRequestParameterPatternChanged(t *testing.T) {
s2, err := open("../data/checker/request_parameter_pattern_added_or_changed_base.yaml")
require.NoError(t, err)

s2.Spec.Paths["/test"].Post.Parameters[0].Value.Schema.Value.Pattern = "^[\\w\\s]+$"
s2.Spec.Paths.Value("/test").Post.Parameters[0].Value.Schema.Value.Pattern = "^[\\w\\s]+$"
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.RequestParameterPatternAddedOrChangedCheck), d, osm, checker.WARN)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestRequestParameterDefaultValueAdded(t *testing.T) {
s2, err := open("../data/checker/request_parameter_default_value_changed_base.yaml")
require.NoError(t, err)

s1.Spec.Paths["/api/v1.0/groups"].Post.Parameters[1].Value.Schema.Value.Default = nil
s1.Spec.Paths.Value("/api/v1.0/groups").Post.Parameters[1].Value.Schema.Value.Default = nil

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -61,7 +61,7 @@ func TestRequestParameterDefaultValueRemoved(t *testing.T) {
s2, err := open("../data/checker/request_parameter_default_value_changed_base.yaml")
require.NoError(t, err)

s2.Spec.Paths["/api/v1.0/groups"].Post.Parameters[1].Value.Schema.Value.Default = nil
s2.Spec.Paths.Value("/api/v1.0/groups").Post.Parameters[1].Value.Schema.Value.Default = nil

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand Down
12 changes: 6 additions & 6 deletions checker/check-request-parameters-type-changed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestRequestPathParamTypeChanged(t *testing.T) {
s2, err := open("../data/checker/request_parameter_type_changed_base.yaml")
require.NoError(t, err)

s2.Spec.Paths["/api/v1.0/groups"].Post.Parameters[0].Value.Schema.Value.Type = "int"
s2.Spec.Paths.Value("/api/v1.0/groups").Post.Parameters[0].Value.Schema.Value.Type = "int"

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -39,7 +39,7 @@ func TestRequestQueryParamTypeChanged(t *testing.T) {
s2, err := open("../data/checker/request_parameter_type_changed_base.yaml")
require.NoError(t, err)

s2.Spec.Paths["/api/v1.0/groups"].Post.Parameters[1].Value.Schema.Value.Type = "int"
s2.Spec.Paths.Value("/api/v1.0/groups").Post.Parameters[1].Value.Schema.Value.Type = "int"

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -63,7 +63,7 @@ func TestRequestQueryHeaderTypeChanged(t *testing.T) {
s2, err := open("../data/checker/request_parameter_type_changed_base.yaml")
require.NoError(t, err)

s2.Spec.Paths["/api/v1.0/groups"].Post.Parameters[2].Value.Schema.Value.Type = "int"
s2.Spec.Paths.Value("/api/v1.0/groups").Post.Parameters[2].Value.Schema.Value.Type = "int"

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -87,7 +87,7 @@ func TestRequestPathParamFormatChanged(t *testing.T) {
s2, err := open("../data/checker/request_parameter_type_changed_base.yaml")
require.NoError(t, err)

s2.Spec.Paths["/api/v1.0/groups"].Post.Parameters[0].Value.Schema.Value.Format = "uuid"
s2.Spec.Paths.Value("/api/v1.0/groups").Post.Parameters[0].Value.Schema.Value.Format = "uuid"

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -111,7 +111,7 @@ func TestRequestQueryParamFormatChanged(t *testing.T) {
s2, err := open("../data/checker/request_parameter_type_changed_base.yaml")
require.NoError(t, err)

s2.Spec.Paths["/api/v1.0/groups"].Post.Parameters[1].Value.Schema.Value.Format = "uri"
s2.Spec.Paths.Value("/api/v1.0/groups").Post.Parameters[1].Value.Schema.Value.Format = "uri"

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -135,7 +135,7 @@ func TestRequestQueryHeaderFormatChanged(t *testing.T) {
s2, err := open("../data/checker/request_parameter_type_changed_base.yaml")
require.NoError(t, err)

s2.Spec.Paths["/api/v1.0/groups"].Post.Parameters[2].Value.Schema.Value.Format = "uri"
s2.Spec.Paths.Value("/api/v1.0/groups").Post.Parameters[2].Value.Schema.Value.Format = "uri"

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions checker/check-request-property-became-not-nuallable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestRequestBodyBecameNullable(t *testing.T) {
s2, err := open("../data/checker/request_property_became_nullable_base.yaml")
require.NoError(t, err)

s2.Spec.Paths["/products"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Nullable = true
s2.Spec.Paths.Value("/products").Post.RequestBody.Value.Content["application/json"].Schema.Value.Nullable = true

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -84,7 +84,7 @@ func TestRequestBodyBecameNotNullable(t *testing.T) {
s2, err := open("../data/checker/request_property_became_nullable_base.yaml")
require.NoError(t, err)

s1.Spec.Paths["/products"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Nullable = true
s1.Spec.Paths.Value("/products").Post.RequestBody.Value.Content["application/json"].Schema.Value.Nullable = true

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand Down
10 changes: 5 additions & 5 deletions checker/check-request-property-default-value-changed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestRequestPropertyDefaultValueChanged(t *testing.T) {
s2, err := open("../data/checker/request_property_default_value_changed_base.yaml")
require.NoError(t, err)

s2.Spec.Paths["/products"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["price"].Value.Default = 20.0
s2.Spec.Paths.Value("/products").Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["price"].Value.Default = 20.0

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -61,8 +61,8 @@ func TestRequestBodyDefaultValueAdded(t *testing.T) {
s2, err := open("../data/checker/request_body_default_value_changed_base.yaml")
require.NoError(t, err)

s1.Spec.Paths["/products"].Post.RequestBody.Value.Content["text/plain"].Schema.Value.Default = nil
s1.Spec.Paths["/products"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["price"].Value.Default = nil
s1.Spec.Paths.Value("/products").Post.RequestBody.Value.Content["text/plain"].Schema.Value.Default = nil
s1.Spec.Paths.Value("/products").Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["price"].Value.Default = nil

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand Down Expand Up @@ -94,8 +94,8 @@ func TestRequestBodyDefaultValueRemoving(t *testing.T) {
s2, err := open("../data/checker/request_body_default_value_changed_base.yaml")
require.NoError(t, err)

s2.Spec.Paths["/products"].Post.RequestBody.Value.Content["text/plain"].Schema.Value.Default = nil
s2.Spec.Paths["/products"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["price"].Value.Default = nil
s2.Spec.Paths.Value("/products").Post.RequestBody.Value.Content["text/plain"].Schema.Value.Default = nil
s2.Spec.Paths.Value("/products").Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["price"].Value.Default = nil

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand Down
4 changes: 2 additions & 2 deletions checker/check-request-property-enum-value-updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestRequestPropertyEnumValueRemovedCheck(t *testing.T) {
s2, err := open("../data/checker/request_property_enum_value_updated_base.yaml")
require.NoError(t, err)

s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["category"].Value.Enum = []interface{}{"dog", "cat"}
s2.Spec.Paths.Value("/pets").Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["category"].Value.Enum = []interface{}{"dog", "cat"}

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -42,7 +42,7 @@ func TestRequestPropertyEnumValueAddedCheck(t *testing.T) {
s2, err := open("../data/checker/request_property_enum_value_updated_base.yaml")
require.NoError(t, err)

s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["category"].Value.Enum = []interface{}{"dog", "cat"}
s1.Spec.Paths.Value("/pets").Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["category"].Value.Enum = []interface{}{"dog", "cat"}

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand Down
16 changes: 8 additions & 8 deletions checker/check-request-property-max-length-updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func TestRequestBodyMaxLengthDecreasedCheck(t *testing.T) {

maxLength := uint64(50)
newMaxLength := uint64(100)
s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.MaxLength = &maxLength
s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.MaxLength = &newMaxLength
s1.Spec.Paths.Value("/pets").Post.RequestBody.Value.Content["application/json"].Schema.Value.MaxLength = &maxLength
s2.Spec.Paths.Value("/pets").Post.RequestBody.Value.Content["application/json"].Schema.Value.MaxLength = &newMaxLength

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -45,8 +45,8 @@ func TestRequestBodyMaxLengthIncreasedCheck(t *testing.T) {

maxLength := uint64(100)
newMaxLength := uint64(50)
s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.MaxLength = &maxLength
s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.MaxLength = &newMaxLength
s1.Spec.Paths.Value("/pets").Post.RequestBody.Value.Content["application/json"].Schema.Value.MaxLength = &maxLength
s2.Spec.Paths.Value("/pets").Post.RequestBody.Value.Content["application/json"].Schema.Value.MaxLength = &newMaxLength

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -73,8 +73,8 @@ func TestRequestPropertyMaxLengthDecreasedCheck(t *testing.T) {

maxLength := uint64(100)
newMaxLength := uint64(50)
s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["description"].Value.MaxLength = &maxLength
s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["description"].Value.MaxLength = &newMaxLength
s1.Spec.Paths.Value("/pets").Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["description"].Value.MaxLength = &maxLength
s2.Spec.Paths.Value("/pets").Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["description"].Value.MaxLength = &newMaxLength
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)

Expand All @@ -100,8 +100,8 @@ func TestRequestPropertyMaxLengthIncreasedCheck(t *testing.T) {

maxLength := uint64(50)
newMaxLength := uint64(100)
s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["description"].Value.MaxLength = &maxLength
s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["description"].Value.MaxLength = &newMaxLength
s1.Spec.Paths.Value("/pets").Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["description"].Value.MaxLength = &maxLength
s2.Spec.Paths.Value("/pets").Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["description"].Value.MaxLength = &newMaxLength
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)

Expand Down
12 changes: 6 additions & 6 deletions checker/check-request-property-max-updated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func TestRequestPropertyMaxDecreasedCheck(t *testing.T) {
require.NoError(t, err)

max := float64(10)
s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["name"].Value.Max = &max
s2.Spec.Paths.Value("/pets").Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["name"].Value.Max = &max

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -42,7 +42,7 @@ func TestRequestPropertyMaxIncreasingCheck(t *testing.T) {
require.NoError(t, err)

max := float64(20)
s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["name"].Value.Max = &max
s2.Spec.Paths.Value("/pets").Post.RequestBody.Value.Content["application/json"].Schema.Value.Properties["name"].Value.Max = &max

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -69,8 +69,8 @@ func TestRequestBodyMaxIncreasingCheck(t *testing.T) {

max := float64(20)
newMax := float64(25)
s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Max = &max
s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Max = &newMax
s1.Spec.Paths.Value("/pets").Post.RequestBody.Value.Content["application/json"].Schema.Value.Max = &max
s2.Spec.Paths.Value("/pets").Post.RequestBody.Value.Content["application/json"].Schema.Value.Max = &newMax

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand All @@ -97,8 +97,8 @@ func TestRequestBodyMaxDecreasedCheck(t *testing.T) {

max := float64(25)
newMax := float64(20)
s1.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Max = &max
s2.Spec.Paths["/pets"].Post.RequestBody.Value.Content["application/json"].Schema.Value.Max = &newMax
s1.Spec.Paths.Value("/pets").Post.RequestBody.Value.Content["application/json"].Schema.Value.Max = &max
s2.Spec.Paths.Value("/pets").Post.RequestBody.Value.Content["application/json"].Schema.Value.Max = &newMax

d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
Expand Down
Loading