Skip to content

Commit

Permalink
fix formatting for bool fields
Browse files Browse the repository at this point in the history
  • Loading branch information
tibulca committed Aug 2, 2023
1 parent 8de74ef commit af683be
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 19 deletions.
2 changes: 1 addition & 1 deletion BREAKING-CHANGES-EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ These examples are automatically generated from unit tests.
[changing required response property to optional](checker/check-response-property-became-optional_test.go?plain=1#L11)
[changing required response property to read-only](checker/check-response-required-property-write-only-read-only_test.go?plain=1#L63)
[changing required response property to write-only](checker/check-response-required-property-write-only-read-only_test.go?plain=1#L11)
[changing response body default value](checker/check-response-property-default-value-changed_test.go?plain=1#L33)
[changing response body default value](checker/check-response-property-default-value-changed_test.go?plain=1#L42)
[changing response body property default value](checker/check-response-property-default-value-changed_test.go?plain=1#L11)
[changing response property pattern](checker/check-response-pattern-added-or-changed_test.go?plain=1#L11)
[changing schema discriminator mapping in the request body or request body property](checker/check-request-discriminator-updated_test.go?plain=1#L119)
Expand Down
15 changes: 12 additions & 3 deletions checker/check-response-property-default-value-changed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ func TestResponsePropertyDefaultValueUpdatedCheck(t *testing.T) {
d, osm, err := diff.GetWithOperationsSourcesMap(getConfig(), s1, s2)
require.NoError(t, err)
errs := checker.CheckBackwardCompatibilityUntilLevel(singleCheckConfig(checker.ResponsePropertyDefaultValueChangedCheck), d, osm, checker.INFO)
require.Len(t, errs, 1)
require.Equal(t, checker.ApiChange{
require.Len(t, errs, 2)
require.ElementsMatch(t, []checker.ApiChange{{
Id: "response-property-default-value-changed",
Text: "the 'created' response's property default value changed from '2020-01-01T00:00:00Z' to '2020-02-01T00:00:00Z' for the status '200'",
Comment: "",
Expand All @@ -27,7 +27,16 @@ func TestResponsePropertyDefaultValueUpdatedCheck(t *testing.T) {
Path: "/api/v1.0/groups",
Source: "../data/checker/response_property_default_value_changed_revision.yaml",
OperationId: "createOneGroup",
}, errs[0])
}, {
Id: "response-property-default-value-changed",
Text: "the 'enabled' response's property default value changed from 'false' to 'true' for the status '200'",
Comment: "",
Level: checker.INFO,
Operation: "POST",
Path: "/api/v1.0/groups",
Source: "../data/checker/response_property_default_value_changed_revision.yaml",
OperationId: "createOneGroup",
}}, errs)
}

// CL: changing response body default value
Expand Down
15 changes: 8 additions & 7 deletions checker/checks-utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,23 @@ func interfaceToString(arg interface{}) string {
return "undefined"
}

argString, ok := arg.(string)
if ok {
if argString, ok := arg.(string); ok {
return argString
}

argUint64, ok := arg.(uint64)
if ok {
if argUint64, ok := arg.(uint64); ok {
return fmt.Sprintf("%d", argUint64)
}

argFloat64, ok := arg.(float64)
if ok {
if argFloat64, ok := arg.(float64); ok {
return fmt.Sprintf("%.2f", argFloat64)
}

return fmt.Sprintf("%s", arg)
if argBool, ok := arg.(bool); ok {
return fmt.Sprintf("%t", argBool)
}

return fmt.Sprintf("%v", arg)
}

func CheckModifiedPropertiesDiff(schemaDiff *diff.SchemaDiff, processor func(propertyPath string, propertyName string, propertyItem *diff.SchemaDiff, propertyParentItem *diff.SchemaDiff)) {
Expand Down
11 changes: 7 additions & 4 deletions data/checker/response_property_default_value_changed_base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ info:
title: Tufin
version: "2.0"
servers:
- url: https://localhost:9080
- url: https://localhost:9080
paths:
/api/v1.0/groups:
post:
Expand All @@ -13,15 +13,15 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/GroupView'
$ref: "#/components/schemas/GroupView"
description: OK
"404":
content:
text/plain:
schema:
type: string
default: "Error"
description: Error
description: Error
summary: Create One Project
components:
parameters:
Expand Down Expand Up @@ -49,5 +49,8 @@ components:
readOnly: true
name:
type: string
enabled:
default: false
type: boolean
required:
- name
- name
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ info:
title: Tufin
version: "2.0"
servers:
- url: https://localhost:9080
- url: https://localhost:9080
paths:
/api/v1.0/groups:
post:
Expand All @@ -13,15 +13,15 @@ paths:
content:
application/json:
schema:
$ref: '#/components/schemas/GroupView'
$ref: "#/components/schemas/GroupView"
description: OK
"404":
content:
text/plain:
schema:
type: string
default: "Error"
description: Error
description: Error
summary: Create One Project
components:
parameters:
Expand Down Expand Up @@ -49,5 +49,8 @@ components:
readOnly: true
name:
type: string
enabled:
default: true
type: boolean
required:
- name
- name

0 comments on commit af683be

Please sign in to comment.