diff --git a/BREAKING-CHANGES-EXAMPLES.md b/BREAKING-CHANGES-EXAMPLES.md index c59cd3c6..a6580dd3 100644 --- a/BREAKING-CHANGES-EXAMPLES.md +++ b/BREAKING-CHANGES-EXAMPLES.md @@ -39,18 +39,18 @@ These examples are automatically generated from unit tests. [changing response's embedded property schema type from string/none to integer/int32 is breaking](checker/checker_breaking_response_type_changed_test.go?plain=1#L108) [deleting a media-type from response is breaking](checker/checker_breaking_test.go?plain=1#L429) [deleting a path is breaking](checker/checker_breaking_test.go?plain=1#L43) -[deleting a path with some operations having sunset date in the future is breaking](checker/checker_deprecation_test.go?plain=1#L273) +[deleting a path with some operations having sunset date in the future is breaking](checker/checker_deprecation_test.go?plain=1#L272) [deleting a required property in request is breaking with warn](checker/checker_breaking_property_test.go?plain=1#L368) [deleting a required property in response body is breaking](checker/checker_breaking_property_test.go?plain=1#L416) [deleting a required property under AllOf in response body is breaking](checker/checker_breaking_property_test.go?plain=1#L446) [deleting a required property within another property in request is breaking with warn](checker/checker_breaking_property_test.go?plain=1#L385) [deleting an enum value is breaking](checker/checker_breaking_test.go?plain=1#L103) -[deleting an operation before sunset date is breaking](checker/checker_deprecation_test.go?plain=1#L35) +[deleting an operation before sunset date is breaking](checker/checker_deprecation_test.go?plain=1#L34) [deleting an operation is breaking](checker/checker_breaking_test.go?plain=1#L50) -[deleting an operation without sunset date is breaking](checker/checker_deprecation_test.go?plain=1#L52) -[deleting sunset header for a deprecated endpoint is breaking](checker/checker_deprecation_test.go?plain=1#L290) -[deprecating an operation with a deprecation policy and sunset date before required deprecation period is breaking](checker/checker_deprecation_test.go?plain=1#L218) -[deprecating an operation with a deprecation policy but without specifying sunset date is breaking](checker/checker_deprecation_test.go?plain=1#L84) +[deleting an operation without sunset date is breaking](checker/checker_deprecation_test.go?plain=1#L51) +[deleting sunset header for a deprecated endpoint is breaking](checker/checker_deprecation_test.go?plain=1#L289) +[deprecating an operation with a deprecation policy and sunset date before required deprecation period is breaking](checker/checker_deprecation_test.go?plain=1#L217) +[deprecating an operation with a deprecation policy but without specifying sunset date is breaking](checker/checker_deprecation_test.go?plain=1#L83) [increasing max length in response is breaking](checker/checker_breaking_min_max_test.go?plain=1#L93) [increasing min items in request is breaking](checker/checker_breaking_min_max_test.go?plain=1#L236) [modifying a pattern in a schema is breaking](checker/checker_breaking_test.go?plain=1#L491) @@ -74,8 +74,8 @@ These examples are automatically generated from unit tests. [removing an existing response with successful status is breaking](checker/checker_breaking_test.go?plain=1#L246) [removing an schema object from components is breaking (optional)](checker/checker_breaking_test.go?plain=1#L610) [removing the default value of an optional request parameter is breaking](checker/checker_breaking_test.go?plain=1#L573) -[removing the path without a deprecation policy and without specifying sunset date is breaking if some APIs are not alpha stability level](checker/checker_deprecation_test.go?plain=1#L137) -[removing the path without a deprecation policy and without specifying sunset date is breaking if some APIs are not draft stability level](checker/checker_deprecation_test.go?plain=1#L191) +[removing the path without a deprecation policy and without specifying sunset date is breaking if some APIs are not alpha stability level](checker/checker_deprecation_test.go?plain=1#L136) +[removing the path without a deprecation policy and without specifying sunset date is breaking if some APIs are not draft stability level](checker/checker_deprecation_test.go?plain=1#L190) [removing/updating a property enum in response is breaking (optional)](checker/checker_breaking_test.go?plain=1#L324) [removing/updating a tag is breaking (optional)](checker/checker_breaking_test.go?plain=1#L341) [removing/updating an enum in request body is breaking (optional)](checker/checker_breaking_test.go?plain=1#L302) @@ -113,17 +113,17 @@ These examples are automatically generated from unit tests. [changing response's body schema type from number/none to integer/int32 is not breaking](checker/checker_breaking_response_type_changed_test.go?plain=1#L89) [changing servers is not breaking](checker/checker_not_breaking_test.go?plain=1#L253) [deleting a non-required non-write-only property in response body is not breaking](checker/checker_breaking_property_test.go?plain=1#L531) -[deleting a path after sunset date of all contained operations is not breaking](checker/checker_deprecation_test.go?plain=1#L258) +[deleting a path after sunset date of all contained operations is not breaking](checker/checker_deprecation_test.go?plain=1#L257) [deleting a pattern from a schema is not breaking](checker/checker_breaking_test.go?plain=1#L445) [deleting a required write-only property in response body is not breaking](checker/checker_breaking_property_test.go?plain=1#L514) [deleting a tag is not breaking](checker/checker_not_breaking_test.go?plain=1#L71) -[deleting an operation after sunset date is not breaking](checker/checker_deprecation_test.go?plain=1#L69) +[deleting an operation after sunset date is not breaking](checker/checker_deprecation_test.go?plain=1#L68) [deprecating a header is not breaking](checker/checker_not_breaking_test.go?plain=1#L227) [deprecating a parameter is not breaking](checker/checker_not_breaking_test.go?plain=1#L214) [deprecating a schema is not breaking](checker/checker_not_breaking_test.go?plain=1#L240) -[deprecating an operation with a deprecation policy and sunset date after required deprecation period is not breaking](checker/checker_deprecation_test.go?plain=1#L237) -[deprecating an operation without a deprecation policy and without specifying sunset date is not breaking for draft level](checker/checker_deprecation_test.go?plain=1#L155) -[deprecating an operation without a deprecation policy and without specifying sunset date is not breaking](checker/checker_deprecation_test.go?plain=1#L103) +[deprecating an operation with a deprecation policy and sunset date after required deprecation period is not breaking](checker/checker_deprecation_test.go?plain=1#L236) +[deprecating an operation without a deprecation policy and without specifying sunset date is not breaking for draft level](checker/checker_deprecation_test.go?plain=1#L154) +[deprecating an operation without a deprecation policy and without specifying sunset date is not breaking](checker/checker_deprecation_test.go?plain=1#L102) [increasing max length in request is not breaking](checker/checker_breaking_min_max_test.go?plain=1#L76) [increasing min items in response is not breaking](checker/checker_breaking_min_max_test.go?plain=1#L250) [modifying a pattern to ".*" in a schema is not breaking](checker/checker_breaking_test.go?plain=1#L523) @@ -138,8 +138,8 @@ These examples are automatically generated from unit tests. [reducing min length in request is not breaking](checker/checker_breaking_min_max_test.go?plain=1#L48) [removing an existing response with error status is not breaking](checker/checker_breaking_test.go?plain=1#L394) [removing an existing response with unparseable status is not breaking](checker/checker_breaking_test.go?plain=1#L378) -[removing the path without a deprecation policy and without specifying sunset date is not breaking for alpha level](checker/checker_deprecation_test.go?plain=1#L118) -[removing the path without a deprecation policy and without specifying sunset date is not breaking for draft level](checker/checker_deprecation_test.go?plain=1#L172) +[removing the path without a deprecation policy and without specifying sunset date is not breaking for alpha level](checker/checker_deprecation_test.go?plain=1#L117) +[removing the path without a deprecation policy and without specifying sunset date is not breaking for draft level](checker/checker_deprecation_test.go?plain=1#L171) [renaming a path parameter is not breaking](checker/checker_breaking_test.go?plain=1#L135) ## Examples of info-level changes for changelog @@ -268,8 +268,8 @@ These examples are automatically generated from unit tests. [increasing request property maximum value](checker/check-request-property-max-updated_test.go?plain=1#L37) [new header, query and cookie request params](checker/check-new-request-non-path-parameter_test.go?plain=1#L11) [new paths or path operations](checker/check-api-added_test.go?plain=1#L11) -[path operations that became deprecated](checker/checker_deprecation_test.go?plain=1#L324) -[path operations that were re-activated](checker/checker_deprecation_test.go?plain=1#L346) +[path operations that became deprecated](checker/checker_deprecation_test.go?plain=1#L323) +[path operations that were re-activated](checker/checker_deprecation_test.go?plain=1#L345) [removing 'allOf' schema from the request body or request body property](checker/check-request-property-all-of-updated_test.go?plain=1#L47) [removing 'allOf' schema from the response body or response body property](checker/check-response-property-all-of-updated_test.go?plain=1#L47) [removing 'anyOf' schema from the request body or request body property](checker/check-request-property-any-of-updated_test.go?plain=1#L47) diff --git a/checker/api_change.go b/checker/api_change.go index e6b47063..c488aa1a 100644 --- a/checker/api_change.go +++ b/checker/api_change.go @@ -5,7 +5,6 @@ import ( "strings" "github.com/TwiN/go-color" - "github.com/tufin/oasdiff/checker/localizations" ) // ApiChange represnts a change in the Paths Section of an OpenAPI spec @@ -59,11 +58,11 @@ func (c ApiChange) GetPath() string { return c.Path } -func (c ApiChange) LocalizedError(l localizations.Localizer) string { - return fmt.Sprintf("%s %s %s, %s API %s %s %s [%s]. %s", c.Level, l.Get("messages.at"), c.Source, l.Get("messages.in"), c.Operation, c.Path, c.Text, c.Id, c.Comment) +func (c ApiChange) LocalizedError(l Localizer) string { + return fmt.Sprintf("%s %s %s, %s API %s %s %s [%s]. %s", c.Level, l("at"), c.Source, l("in"), c.Operation, c.Path, c.Text, c.Id, c.Comment) } -func (c ApiChange) PrettyErrorText(l localizations.Localizer) string { +func (c ApiChange) PrettyErrorText(l Localizer) string { if IsPipedOutput() { return c.LocalizedError(l) } @@ -72,7 +71,7 @@ func (c ApiChange) PrettyErrorText(l localizations.Localizer) string { if c.Comment != "" { comment = fmt.Sprintf("\n\t\t%s", c.Comment) } - return fmt.Sprintf("%s\t[%s] %s %s\t\n\t%s API %s %s\n\t\t%s%s", c.Level.PrettyString(), color.InYellow(c.Id), l.Get("messages.at"), c.Source, l.Get("messages.in"), color.InGreen(c.Operation), color.InGreen(c.Path), c.Text, comment) + return fmt.Sprintf("%s\t[%s] %s %s\t\n\t%s API %s %s\n\t\t%s%s", c.Level.PrettyString(), color.InYellow(c.Id), l("at"), c.Source, l("in"), color.InGreen(c.Operation), color.InGreen(c.Path), c.Text, comment) } func (c ApiChange) Error() string { diff --git a/checker/change.go b/checker/change.go index 37ace292..50c0599a 100644 --- a/checker/change.go +++ b/checker/change.go @@ -1,7 +1,5 @@ package checker -import "github.com/tufin/oasdiff/checker/localizations" - type Change interface { GetId() string GetText() string @@ -12,7 +10,7 @@ type Change interface { GetPath() string MatchIgnore(ignorePath, ignoreLine string) bool - LocalizedError(l localizations.Localizer) string - PrettyErrorText(l localizations.Localizer) string + LocalizedError(l Localizer) string + PrettyErrorText(l Localizer) string Error() string } diff --git a/checker/check-added-required-request-body.go b/checker/check-added-required-request-body.go index 3e155ed3..bc8d4ea5 100644 --- a/checker/check-added-required-request-body.go +++ b/checker/check-added-required-request-body.go @@ -23,7 +23,7 @@ func AddedRequiredRequestBodyCheck(diffReport *diff.Diff, operationsSources *dif result = append(result, ApiChange{ Id: "added-required-request-body", Level: ERR, - Text: config.i18n("added-required-request-body"), + Text: config.Localize("added-required-request-body"), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-api-added.go b/checker/check-api-added.go index a8e75cdc..68ba3262 100644 --- a/checker/check-api-added.go +++ b/checker/check-api-added.go @@ -15,7 +15,7 @@ func APIAddedCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSour result = append(result, ApiChange{ Id: "endpoint-added", Level: INFO, - Text: config.i18n("endpoint-added"), + Text: config.Localize("endpoint-added"), Operation: opName, OperationId: opConfig.OperationID, Path: path, diff --git a/checker/check-api-deprecation.go b/checker/check-api-deprecation.go index 1eebe6dd..7620e095 100644 --- a/checker/check-api-deprecation.go +++ b/checker/check-api-deprecation.go @@ -31,7 +31,7 @@ func APIDeprecationCheck(diffReport *diff.Diff, operationsSources *diff.Operatio result = append(result, ApiChange{ Id: "endpoint-reactivated", Level: INFO, - Text: config.i18n("endpoint-reactivated"), + Text: config.Localize("endpoint-reactivated"), Operation: operation, OperationId: op.OperationID, Path: path, @@ -45,7 +45,7 @@ func APIDeprecationCheck(diffReport *diff.Diff, operationsSources *diff.Operatio result = append(result, ApiChange{ Id: "api-deprecated-sunset-parse", Level: ERR, - Text: fmt.Sprintf(config.i18n("api-deprecated-sunset-parse"), rawDate, err), + Text: config.Localize("api-deprecated-sunset-parse", rawDate, err), Operation: operation, OperationId: op.OperationID, Path: path, @@ -76,7 +76,7 @@ func APIDeprecationCheck(diffReport *diff.Diff, operationsSources *diff.Operatio result = append(result, ApiChange{ Id: "api-sunset-date-too-small", Level: ERR, - Text: fmt.Sprintf(config.i18n("api-sunset-date-too-small"), date, deprecationDays), + Text: config.Localize("api-sunset-date-too-small", date, deprecationDays), Operation: operation, OperationId: op.OperationID, Path: path, @@ -89,7 +89,7 @@ func APIDeprecationCheck(diffReport *diff.Diff, operationsSources *diff.Operatio result = append(result, ApiChange{ Id: "endpoint-deprecated", Level: INFO, - Text: config.i18n("endpoint-deprecated"), + Text: config.Localize("endpoint-deprecated"), Operation: operation, OperationId: op.OperationID, Path: path, diff --git a/checker/check-api-operation-id-updated.go b/checker/check-api-operation-id-updated.go index f28c5bcf..b0b514f7 100644 --- a/checker/check-api-operation-id-updated.go +++ b/checker/check-api-operation-id-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -33,11 +31,11 @@ func APIOperationIdUpdatedCheck(diffReport *diff.Diff, operationsSources *diff.O level := INFO id := apiOperationRemovedCheckId - text := fmt.Sprintf(config.i18n(id), ColorizedValue(operationItem.Base.OperationID), ColorizedValue(operationItem.Revision.OperationID)) + text := config.Localize(id, ColorizedValue(operationItem.Base.OperationID), ColorizedValue(operationItem.Revision.OperationID)) if operationItem.OperationIDDiff.From == nil || operationItem.OperationIDDiff.From == "" { id = apiOperationAddCheckId op = pathItem.Revision.Operations()[operation] - text = fmt.Sprintf(config.i18n(id), ColorizedValue(operationItem.Revision.OperationID)) + text = config.Localize(id, ColorizedValue(operationItem.Revision.OperationID)) } result = append(result, ApiChange{ diff --git a/checker/check-api-removed.go b/checker/check-api-removed.go index 8957d502..3eb03a14 100644 --- a/checker/check-api-removed.go +++ b/checker/check-api-removed.go @@ -1,7 +1,6 @@ package checker import ( - "fmt" "time" "cloud.google.com/go/civil" @@ -25,7 +24,7 @@ func APIRemovedCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSo result = append(result, ApiChange{ Id: "api-path-removed-without-deprecation", Level: ERR, - Text: config.i18n("api-path-removed-without-deprecation"), + Text: config.Localize("api-path-removed-without-deprecation"), Operation: operation, OperationId: op.OperationID, Path: path, @@ -39,7 +38,7 @@ func APIRemovedCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSo result = append(result, ApiChange{ Id: "api-path-sunset-parse", Level: ERR, - Text: fmt.Sprintf(config.i18n("api-deprecated-sunset-parse"), rawDate, err), + Text: config.Localize("api-deprecated-sunset-parse", rawDate, err), Operation: operation, OperationId: op.OperationID, Path: path, @@ -52,7 +51,7 @@ func APIRemovedCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSo result = append(result, ApiChange{ Id: "api-path-removed-before-sunset", Level: ERR, - Text: fmt.Sprintf(config.i18n("api-path-removed-before-sunset"), date), + Text: config.Localize("api-path-removed-before-sunset", date), Operation: operation, OperationId: op.OperationID, Path: path, @@ -73,7 +72,7 @@ func APIRemovedCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSo result = append(result, ApiChange{ Id: "api-removed-without-deprecation", Level: ERR, - Text: config.i18n("api-removed-without-deprecation"), + Text: config.Localize("api-removed-without-deprecation"), Operation: operation, OperationId: op.OperationID, Path: path, @@ -87,7 +86,7 @@ func APIRemovedCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSo result = append(result, ApiChange{ Id: "api-path-sunset-parse", Level: ERR, - Text: fmt.Sprintf(config.i18n("api-deprecated-sunset-parse"), rawDate, err), + Text: config.Localize("api-deprecated-sunset-parse", rawDate, err), Operation: operation, OperationId: op.OperationID, Path: path, @@ -100,7 +99,7 @@ func APIRemovedCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSo result = append(result, ApiChange{ Id: "api-removed-before-sunset", Level: ERR, - Text: fmt.Sprintf(config.i18n("api-removed-before-sunset"), date), + Text: config.Localize("api-removed-before-sunset", date), Operation: operation, OperationId: op.OperationID, Path: path, diff --git a/checker/check-api-security-updated.go b/checker/check-api-security-updated.go index 1a561590..42b2cebc 100644 --- a/checker/check-api-security-updated.go +++ b/checker/check-api-security-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -27,7 +25,7 @@ func checkGlobalSecurity(diffReport *diff.Diff, operationsSources *diff.Operatio result = append(result, SecurityChange{ Id: APIGlobalSecurityAddedCheckId, Level: INFO, - Text: fmt.Sprintf(config.i18n(APIGlobalSecurityAddedCheckId), ColorizedValue(addedSecurity)), + Text: config.Localize(APIGlobalSecurityAddedCheckId, ColorizedValue(addedSecurity)), Source: "", }) } @@ -36,7 +34,7 @@ func checkGlobalSecurity(diffReport *diff.Diff, operationsSources *diff.Operatio result = append(result, SecurityChange{ Id: APIGlobalSecurityRemovedCheckId, Level: INFO, - Text: fmt.Sprintf(config.i18n(APIGlobalSecurityRemovedCheckId), ColorizedValue(removedSecurity)), + Text: config.Localize(APIGlobalSecurityRemovedCheckId, ColorizedValue(removedSecurity)), Source: "", }) } @@ -47,7 +45,7 @@ func checkGlobalSecurity(diffReport *diff.Diff, operationsSources *diff.Operatio result = append(result, SecurityChange{ Id: APIGlobalSecurityScopeAddedId, Level: INFO, - Text: fmt.Sprintf(config.i18n(APIGlobalSecurityScopeAddedId), ColorizedValue(addedScope), ColorizedValue(securitySchemeName)), + Text: config.Localize(APIGlobalSecurityScopeAddedId, ColorizedValue(addedScope), ColorizedValue(securitySchemeName)), Source: "", }) } @@ -55,7 +53,7 @@ func checkGlobalSecurity(diffReport *diff.Diff, operationsSources *diff.Operatio result = append(result, SecurityChange{ Id: APIGlobalSecurityScopeRemovedId, Level: INFO, - Text: fmt.Sprintf(config.i18n(APIGlobalSecurityScopeRemovedId), ColorizedValue(deletedScope), ColorizedValue(securitySchemeName)), + Text: config.Localize(APIGlobalSecurityScopeRemovedId, ColorizedValue(deletedScope), ColorizedValue(securitySchemeName)), Source: "", }) } @@ -94,7 +92,7 @@ func APISecurityUpdatedCheck(diffReport *diff.Diff, operationsSources *diff.Oper result = append(result, ApiChange{ Id: APISecurityAddedCheckId, Level: INFO, - Text: fmt.Sprintf(config.i18n(APISecurityAddedCheckId), ColorizedValue(addedSecurity)), + Text: config.Localize(APISecurityAddedCheckId, ColorizedValue(addedSecurity)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -109,7 +107,7 @@ func APISecurityUpdatedCheck(diffReport *diff.Diff, operationsSources *diff.Oper result = append(result, ApiChange{ Id: APISecurityRemovedCheckId, Level: INFO, - Text: fmt.Sprintf(config.i18n(APISecurityRemovedCheckId), ColorizedValue(deletedSecurity)), + Text: config.Localize(APISecurityRemovedCheckId, ColorizedValue(deletedSecurity)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -126,7 +124,7 @@ func APISecurityUpdatedCheck(diffReport *diff.Diff, operationsSources *diff.Oper result = append(result, ApiChange{ Id: APISecurityScopeAddedId, Level: INFO, - Text: fmt.Sprintf(config.i18n(APISecurityScopeAddedId), ColorizedValue(addedScope), ColorizedValue(securitySchemeName)), + Text: config.Localize(APISecurityScopeAddedId, ColorizedValue(addedScope), ColorizedValue(securitySchemeName)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -137,7 +135,7 @@ func APISecurityUpdatedCheck(diffReport *diff.Diff, operationsSources *diff.Oper result = append(result, ApiChange{ Id: APISecurityScopeRemovedId, Level: INFO, - Text: fmt.Sprintf(config.i18n(APISecurityScopeRemovedId), ColorizedValue(deletedScope), ColorizedValue(securitySchemeName)), + Text: config.Localize(APISecurityScopeRemovedId, ColorizedValue(deletedScope), ColorizedValue(securitySchemeName)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-api-sunset-changed.go b/checker/check-api-sunset-changed.go index 4c125f01..22b26406 100644 --- a/checker/check-api-sunset-changed.go +++ b/checker/check-api-sunset-changed.go @@ -30,7 +30,7 @@ func APISunsetChangedCheck(diffReport *diff.Diff, operationsSources *diff.Operat result = append(result, ApiChange{ Id: "sunset-deleted", Level: ERR, - Text: config.i18n("sunset-deleted"), + Text: config.Localize("sunset-deleted"), Operation: operation, OperationId: op.OperationID, Path: path, @@ -49,7 +49,7 @@ func APISunsetChangedCheck(diffReport *diff.Diff, operationsSources *diff.Operat result = append(result, ApiChange{ Id: "api-deprecated-sunset-parse", Level: ERR, - Text: fmt.Sprintf(config.i18n("api-deprecated-sunset-parse"), rawDate, err), + Text: config.Localize("api-deprecated-sunset-parse", rawDate, err), Operation: operation, OperationId: op.OperationID, Path: path, @@ -63,7 +63,7 @@ func APISunsetChangedCheck(diffReport *diff.Diff, operationsSources *diff.Operat result = append(result, ApiChange{ Id: "api-deprecated-sunset-parse", Level: ERR, - Text: fmt.Sprintf(config.i18n("api-deprecated-sunset-parse"), rawDate, err), + Text: config.Localize("api-deprecated-sunset-parse", rawDate, err), Operation: operation, OperationId: op.OperationID, Path: path, @@ -94,7 +94,7 @@ func APISunsetChangedCheck(diffReport *diff.Diff, operationsSources *diff.Operat result = append(result, ApiChange{ Id: "api-sunset-date-changed-too-small", Level: ERR, - Text: fmt.Sprintf(config.i18n("api-sunset-date-changed-too-small"), baseDate, date, baseDate, deprecationDays), + Text: config.Localize("api-sunset-date-changed-too-small", baseDate, date, baseDate, deprecationDays), Operation: operation, OperationId: op.OperationID, Path: path, diff --git a/checker/check-api-tag-updated.go b/checker/check-api-tag-updated.go index 6307215d..d07a3646 100644 --- a/checker/check-api-tag-updated.go +++ b/checker/check-api-tag-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -34,7 +32,7 @@ func APITagUpdatedCheck(diffReport *diff.Diff, operationsSources *diff.Operation result = append(result, ApiChange{ Id: APITagRemovedCheckId, Level: config.getLogLevel(APITagRemovedCheckId, INFO), - Text: fmt.Sprintf(config.i18n(APITagRemovedCheckId), ColorizedValue(tag)), + Text: config.Localize(APITagRemovedCheckId, ColorizedValue(tag)), Operation: operation, OperationId: op.OperationID, Path: path, @@ -47,7 +45,7 @@ func APITagUpdatedCheck(diffReport *diff.Diff, operationsSources *diff.Operation result = append(result, ApiChange{ Id: APITagAddedCheckId, Level: config.getLogLevel(APITagAddedCheckId, INFO), - Text: fmt.Sprintf(config.i18n(APITagAddedCheckId), ColorizedValue(tag)), + Text: config.Localize(APITagAddedCheckId, ColorizedValue(tag)), Operation: operation, OperationId: op.OperationID, Path: path, diff --git a/checker/check-components-schemas-removed.go b/checker/check-components-schemas-removed.go index 2033e9c2..e16ef7d3 100644 --- a/checker/check-components-schemas-removed.go +++ b/checker/check-components-schemas-removed.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -20,7 +18,7 @@ func APIComponentsSchemaRemovedCheck(diffReport *diff.Diff, operationsSources *d result = append(result, ComponentChange{ Id: apiSchemasRemovedCheckId, Level: config.getLogLevel(apiSchemasRemovedCheckId, INFO), - Text: fmt.Sprintf(config.i18n(apiSchemasRemovedCheckId), ColorizedValue(deletedSchema)), + Text: config.Localize(apiSchemasRemovedCheckId, ColorizedValue(deletedSchema)), Source: "", // TODO: get the file name }) } diff --git a/checker/check-components-security-updated.go b/checker/check-components-security-updated.go index 7f705828..146f1359 100644 --- a/checker/check-components-security-updated.go +++ b/checker/check-components-security-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -32,7 +30,7 @@ func checkOAuthUpdates(updatedSecurity *diff.SecuritySchemeDiff, config Config, result = append(result, ComponentChange{ Id: APIComponentsSecurityComponentOauthUrlUpdated, Level: INFO, - Text: fmt.Sprintf(config.i18n(APIComponentsSecurityComponentOauthUrlUpdated), ColorizedValue(updatedSecurityName), ColorizedValue(urlDiff.From), ColorizedValue(urlDiff.To)), + Text: config.Localize(APIComponentsSecurityComponentOauthUrlUpdated, ColorizedValue(updatedSecurityName), ColorizedValue(urlDiff.From), ColorizedValue(urlDiff.To)), Source: "", }) } @@ -41,7 +39,7 @@ func checkOAuthUpdates(updatedSecurity *diff.SecuritySchemeDiff, config Config, result = append(result, ComponentChange{ Id: APIComponentsSecurityOauthTokenUrlUpdated, Level: INFO, - Text: fmt.Sprintf(config.i18n(APIComponentsSecurityOauthTokenUrlUpdated), ColorizedValue(updatedSecurityName), ColorizedValue(tokenDiff.From), ColorizedValue(tokenDiff.To)), + Text: config.Localize(APIComponentsSecurityOauthTokenUrlUpdated, ColorizedValue(updatedSecurityName), ColorizedValue(tokenDiff.From), ColorizedValue(tokenDiff.To)), Source: "", }) } @@ -51,7 +49,7 @@ func checkOAuthUpdates(updatedSecurity *diff.SecuritySchemeDiff, config Config, result = append(result, ComponentChange{ Id: APIComponentSecurityOauthScopeAdded, Level: INFO, - Text: fmt.Sprintf(config.i18n(APIComponentSecurityOauthScopeAdded), ColorizedValue(updatedSecurityName), ColorizedValue(addedScope)), + Text: config.Localize(APIComponentSecurityOauthScopeAdded, ColorizedValue(updatedSecurityName), ColorizedValue(addedScope)), Source: "", }) } @@ -60,7 +58,7 @@ func checkOAuthUpdates(updatedSecurity *diff.SecuritySchemeDiff, config Config, result = append(result, ComponentChange{ Id: APIComponentSecurityOauthScopeRemoved, Level: INFO, - Text: fmt.Sprintf(config.i18n(APIComponentSecurityOauthScopeRemoved), ColorizedValue(updatedSecurityName), ColorizedValue(removedScope)), + Text: config.Localize(APIComponentSecurityOauthScopeRemoved, ColorizedValue(updatedSecurityName), ColorizedValue(removedScope)), Source: "", }) } @@ -69,7 +67,7 @@ func checkOAuthUpdates(updatedSecurity *diff.SecuritySchemeDiff, config Config, result = append(result, ComponentChange{ Id: APIComponentSecurityOauthScopeUpdated, Level: INFO, - Text: fmt.Sprintf(config.i18n(APIComponentSecurityOauthScopeUpdated), ColorizedValue(updatedSecurityName), ColorizedValue(name), ColorizedValue(modifiedScope.From), ColorizedValue(modifiedScope.To)), + Text: config.Localize(APIComponentSecurityOauthScopeUpdated, ColorizedValue(updatedSecurityName), ColorizedValue(name), ColorizedValue(modifiedScope.From), ColorizedValue(modifiedScope.To)), Source: "", }) } @@ -89,7 +87,7 @@ func APIComponentsSecurityUpdatedCheck(diffReport *diff.Diff, operationsSources result = append(result, ComponentChange{ Id: APIComponentsSecurityAddedCheckId, Level: INFO, - Text: fmt.Sprintf(config.i18n(APIComponentsSecurityAddedCheckId), ColorizedValue(updatedSecurity)), + Text: config.Localize(APIComponentsSecurityAddedCheckId, ColorizedValue(updatedSecurity)), Source: "", }) } @@ -98,7 +96,7 @@ func APIComponentsSecurityUpdatedCheck(diffReport *diff.Diff, operationsSources result = append(result, ComponentChange{ Id: APIComponentsSecurityRemovedCheckId, Level: INFO, - Text: fmt.Sprintf(config.i18n(APIComponentsSecurityRemovedCheckId), ColorizedValue(updatedSecurity)), + Text: config.Localize(APIComponentsSecurityRemovedCheckId, ColorizedValue(updatedSecurity)), Source: "", }) } @@ -110,7 +108,7 @@ func APIComponentsSecurityUpdatedCheck(diffReport *diff.Diff, operationsSources result = append(result, ComponentChange{ Id: APIComponentsSecurityTyepUpdated, Level: INFO, - Text: fmt.Sprintf(config.i18n(APIComponentsSecurityTyepUpdated), ColorizedValue(updatedSecurityName), ColorizedValue(updatedSecurity.TypeDiff.From), ColorizedValue(updatedSecurity.TypeDiff.To)), + Text: config.Localize(APIComponentsSecurityTyepUpdated, ColorizedValue(updatedSecurityName), ColorizedValue(updatedSecurity.TypeDiff.From), ColorizedValue(updatedSecurity.TypeDiff.To)), Source: "", }) } diff --git a/checker/check-new-request-non-path-parameter.go b/checker/check-new-request-non-path-parameter.go index 39e1856b..60e1a9b5 100644 --- a/checker/check-new-request-non-path-parameter.go +++ b/checker/check-new-request-non-path-parameter.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -38,7 +36,7 @@ func NewRequestNonPathParameterCheck(diffReport *diff.Diff, operationsSources *d result = append(result, ApiChange{ Id: id, Level: level, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(paramLocation), ColorizedValue(paramName)), + Text: config.Localize(id, ColorizedValue(paramLocation), ColorizedValue(paramName)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-new-requried-request-header-property.go b/checker/check-new-requried-request-header-property.go index 3e969111..41829bd7 100644 --- a/checker/check-new-requried-request-header-property.go +++ b/checker/check-new-requried-request-header-property.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/getkin/kin-openapi/openapi3" "github.com/tufin/oasdiff/diff" "golang.org/x/exp/slices" @@ -44,7 +42,7 @@ func NewRequiredRequestHeaderPropertyCheck(diffReport *diff.Diff, operationsSour result = append(result, ApiChange{ Id: "new-required-request-header-property", Level: ERR, - Text: fmt.Sprintf(config.i18n("new-required-request-header-property"), ColorizedValue(paramName), ColorizedValue(propertyFullName(propertyPath, newPropertyName))), + Text: config.Localize("new-required-request-header-property", ColorizedValue(paramName), ColorizedValue(propertyFullName(propertyPath, newPropertyName))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-body-became-enum.go b/checker/check-request-body-became-enum.go index 6153362e..248de541 100644 --- a/checker/check-request-body-became-enum.go +++ b/checker/check-request-body-became-enum.go @@ -37,7 +37,7 @@ func RequestBodyBecameEnumCheck(diffReport *diff.Diff, operationsSources *diff.O result = append(result, ApiChange{ Id: requestBodyBecameEnumId, Level: ERR, - Text: config.i18n(requestBodyBecameEnumId), + Text: config.Localize(requestBodyBecameEnumId), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-body-enum-deleted.go b/checker/check-request-body-enum-deleted.go index 619d0165..10e98e98 100644 --- a/checker/check-request-body-enum-deleted.go +++ b/checker/check-request-body-enum-deleted.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -44,7 +42,7 @@ func RequestBodyEnumValueRemovedCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: requestBodyEnumRemovedId, Level: config.getLogLevel(requestBodyEnumRemovedId, INFO), - Text: fmt.Sprintf(config.i18n(requestBodyEnumRemovedId), ColorizedValue(enumVal)), + Text: config.Localize(requestBodyEnumRemovedId, ColorizedValue(enumVal)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-body-mediatype-updated.go b/checker/check-request-body-mediatype-updated.go index 2360513b..3fc59b64 100644 --- a/checker/check-request-body-mediatype-updated.go +++ b/checker/check-request-body-mediatype-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -33,7 +31,7 @@ func RequestBodyMediaTypeChangedCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: RequestBodyMediaTypeAdded, Level: INFO, - Text: fmt.Sprintf(config.i18n(RequestBodyMediaTypeAdded), mediaType), + Text: config.Localize(RequestBodyMediaTypeAdded, mediaType), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -46,7 +44,7 @@ func RequestBodyMediaTypeChangedCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: RequestBodyMediaTypeRemoved, Level: ERR, - Text: fmt.Sprintf(config.i18n(RequestBodyMediaTypeRemoved), mediaType), + Text: config.Localize(RequestBodyMediaTypeRemoved, mediaType), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-body-required-value-updated.go b/checker/check-request-body-required-value-updated.go index 6e759b33..78f3d0fe 100644 --- a/checker/check-request-body-required-value-updated.go +++ b/checker/check-request-body-required-value-updated.go @@ -34,7 +34,7 @@ func RequestBodyRequiredUpdatedCheck(diffReport *diff.Diff, operationsSources *d result = append(result, ApiChange{ Id: id, Level: logLevel, - Text: config.i18n(id), + Text: config.Localize(id), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-discriminator-updated.go b/checker/check-request-discriminator-updated.go index 18ef0133..b1b69d80 100644 --- a/checker/check-request-discriminator-updated.go +++ b/checker/check-request-discriminator-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -29,7 +27,7 @@ func RequestDiscriminatorUpdatedCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: messageId, Level: INFO, - Text: fmt.Sprintf(config.i18n(messageId), a...), + Text: config.Localize(messageId, a...), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-header-property-became-enum.go b/checker/check-request-header-property-became-enum.go index e06d6eca..693695f1 100644 --- a/checker/check-request-header-property-became-enum.go +++ b/checker/check-request-header-property-became-enum.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -39,7 +37,7 @@ func RequestHeaderPropertyBecameEnumCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: requestHeaderPropertyBecameEnumId, Level: ERR, - Text: fmt.Sprintf(config.i18n(requestHeaderPropertyBecameEnumId), ColorizedValue(paramName)), + Text: config.Localize(requestHeaderPropertyBecameEnumId, ColorizedValue(paramName)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -58,7 +56,7 @@ func RequestHeaderPropertyBecameEnumCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: requestHeaderPropertyBecameEnumId, Level: ERR, - Text: fmt.Sprintf(config.i18n(requestHeaderPropertyBecameEnumId), ColorizedValue(paramName), ColorizedValue(propertyFullName(propertyPath, propertyName))), + Text: config.Localize(requestHeaderPropertyBecameEnumId, ColorizedValue(paramName), ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-header-property-became-required.go b/checker/check-request-header-property-became-required.go index b053d00a..93bc560a 100644 --- a/checker/check-request-header-property-became-required.go +++ b/checker/check-request-header-property-became-required.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -50,7 +48,7 @@ func RequestHeaderPropertyBecameRequiredCheck(diffReport *diff.Diff, operationsS result = append(result, ApiChange{ Id: "request-header-property-became-required", Level: ERR, - Text: fmt.Sprintf(config.i18n("request-header-property-became-required"), ColorizedValue(paramName), ColorizedValue(changedRequiredPropertyName)), + Text: config.Localize("request-header-property-became-required", ColorizedValue(paramName), ColorizedValue(changedRequiredPropertyName)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -76,7 +74,7 @@ func RequestHeaderPropertyBecameRequiredCheck(diffReport *diff.Diff, operationsS result = append(result, ApiChange{ Id: "request-header-property-became-required", Level: ERR, - Text: fmt.Sprintf(config.i18n("request-header-property-became-required"), ColorizedValue(paramName), ColorizedValue(propertyFullName(propertyPath, propertyFullName(propertyName, changedRequiredPropertyName)))), + Text: config.Localize("request-header-property-became-required", ColorizedValue(paramName), ColorizedValue(propertyFullName(propertyPath, propertyFullName(propertyName, changedRequiredPropertyName)))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameter-became-enum.go b/checker/check-request-parameter-became-enum.go index f6a249ca..5cff2f96 100644 --- a/checker/check-request-parameter-became-enum.go +++ b/checker/check-request-parameter-became-enum.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -38,7 +36,7 @@ func RequestParameterBecameEnumCheck(diffReport *diff.Diff, operationsSources *d result = append(result, ApiChange{ Id: requestParameterBecameEnumId, Level: ERR, - Text: fmt.Sprintf(config.i18n(requestParameterBecameEnumId), ColorizedValue(paramLocation), ColorizedValue(paramName)), + Text: config.Localize(requestParameterBecameEnumId, ColorizedValue(paramLocation), ColorizedValue(paramName)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameter-enum-value-updated.go b/checker/check-request-parameter-enum-value-updated.go index 7dcea6cb..d1d0e471 100644 --- a/checker/check-request-parameter-enum-value-updated.go +++ b/checker/check-request-parameter-enum-value-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -36,7 +34,7 @@ func RequestParameterEnumValueUpdatedCheck(diffReport *diff.Diff, operationsSour result = append(result, ApiChange{ Id: "request-parameter-enum-value-removed", Level: ERR, - Text: fmt.Sprintf(config.i18n("request-parameter-enum-value-removed"), ColorizedValue(enumVal), ColorizedValue(paramLocation), ColorizedValue(paramName)), + Text: config.Localize("request-parameter-enum-value-removed", ColorizedValue(enumVal), ColorizedValue(paramLocation), ColorizedValue(paramName)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -47,7 +45,7 @@ func RequestParameterEnumValueUpdatedCheck(diffReport *diff.Diff, operationsSour result = append(result, ApiChange{ Id: "request-parameter-enum-value-added", Level: INFO, - Text: fmt.Sprintf(config.i18n("request-parameter-enum-value-added"), ColorizedValue(enumVal), ColorizedValue(paramLocation), ColorizedValue(paramName)), + Text: config.Localize("request-parameter-enum-value-added", ColorizedValue(enumVal), ColorizedValue(paramLocation), ColorizedValue(paramName)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameter-pattern-added-or-changed.go b/checker/check-request-parameter-pattern-added-or-changed.go index 5a7ace67..6bbf29e1 100644 --- a/checker/check-request-parameter-pattern-added-or-changed.go +++ b/checker/check-request-parameter-pattern-added-or-changed.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -37,8 +35,8 @@ func RequestParameterPatternAddedOrChangedCheck(diffReport *diff.Diff, operation result = append(result, ApiChange{ Id: "request-parameter-pattern-added", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-parameter-pattern-added"), patternDiff.To, ColorizedValue(paramLocation), ColorizedValue(paramName)), - Comment: config.i18n("pattern-changed-warn-comment"), + Text: config.Localize("request-parameter-pattern-added", patternDiff.To, ColorizedValue(paramLocation), ColorizedValue(paramName)), + Comment: config.Localize("pattern-changed-warn-comment"), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -48,7 +46,7 @@ func RequestParameterPatternAddedOrChangedCheck(diffReport *diff.Diff, operation result = append(result, ApiChange{ Id: "request-parameter-pattern-removed", Level: INFO, - Text: fmt.Sprintf(config.i18n("request-parameter-pattern-removed"), patternDiff.From, ColorizedValue(paramLocation), ColorizedValue(paramName)), + Text: config.Localize("request-parameter-pattern-removed", patternDiff.From, ColorizedValue(paramLocation), ColorizedValue(paramName)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -56,7 +54,7 @@ func RequestParameterPatternAddedOrChangedCheck(diffReport *diff.Diff, operation }) } else { level := WARN - comment := config.i18n("pattern-changed-warn-comment") + comment := config.Localize("pattern-changed-warn-comment") if patternDiff.To == ".*" { level = INFO comment = "" @@ -64,7 +62,7 @@ func RequestParameterPatternAddedOrChangedCheck(diffReport *diff.Diff, operation result = append(result, ApiChange{ Id: "request-parameter-pattern-changed", Level: level, - Text: fmt.Sprintf(config.i18n("request-parameter-pattern-changed"), ColorizedValue(paramLocation), ColorizedValue(paramName), patternDiff.From, patternDiff.To), + Text: config.Localize("request-parameter-pattern-changed", ColorizedValue(paramLocation), ColorizedValue(paramName), patternDiff.From, patternDiff.To), Comment: comment, Operation: operation, OperationId: operationItem.Revision.OperationID, diff --git a/checker/check-request-parameter-removed.go b/checker/check-request-parameter-removed.go index 1aaf3bc0..fbb80259 100644 --- a/checker/check-request-parameter-removed.go +++ b/checker/check-request-parameter-removed.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -25,7 +23,7 @@ func RequestParameterRemovedCheck(diffReport *diff.Diff, operationsSources *diff result = append(result, ApiChange{ Id: "request-parameter-removed", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-parameter-removed"), ColorizedValue(paramLocation), ColorizedValue(paramName)), + Text: config.Localize("request-parameter-removed", ColorizedValue(paramLocation), ColorizedValue(paramName)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameter-required-value-updated.go b/checker/check-request-parameter-required-value-updated.go index 0609c307..f5bb56a5 100644 --- a/checker/check-request-parameter-required-value-updated.go +++ b/checker/check-request-parameter-required-value-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -41,7 +39,7 @@ func RequestParameterRequiredValueUpdatedCheck(diffReport *diff.Diff, operations result = append(result, ApiChange{ Id: id, Level: level, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(paramLocation), ColorizedValue(paramName)), + Text: config.Localize(id, ColorizedValue(paramLocation), ColorizedValue(paramName)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameter-x-extensible-enum-value-removed.go b/checker/check-request-parameter-x-extensible-enum-value-removed.go index 2f4dd970..ccd13cc4 100644 --- a/checker/check-request-parameter-x-extensible-enum-value-removed.go +++ b/checker/check-request-parameter-x-extensible-enum-value-removed.go @@ -85,7 +85,7 @@ func RequestParameterXExtensibleEnumValueRemovedCheck(diffReport *diff.Diff, ope result = append(result, ApiChange{ Id: "request-parameter-x-extensible-enum-value-removed", Level: ERR, - Text: fmt.Sprintf(config.i18n("request-parameter-x-extensible-enum-value-removed"), ColorizedValue(enumVal), ColorizedValue(paramLocation), ColorizedValue(paramName)), + Text: config.Localize("request-parameter-x-extensible-enum-value-removed", ColorizedValue(enumVal), ColorizedValue(paramLocation), ColorizedValue(paramName)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameters-default-value-changed.go b/checker/check-request-parameters-default-value-changed.go index d896d8af..c3a6318a 100644 --- a/checker/check-request-parameters-default-value-changed.go +++ b/checker/check-request-parameters-default-value-changed.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -24,7 +22,7 @@ func RequestParameterDefaultValueChanged(diffReport *diff.Diff, operationsSource result = append(result, ApiChange{ Id: messageId, Level: ERR, - Text: fmt.Sprintf(config.i18n(messageId), a...), + Text: config.Localize(messageId, a...), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameters-max-items-updated.go b/checker/check-request-parameters-max-items-updated.go index 7bcf548f..e58336e9 100644 --- a/checker/check-request-parameters-max-items-updated.go +++ b/checker/check-request-parameters-max-items-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -45,7 +43,7 @@ func RequestParameterMaxItemsUpdatedCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: id, Level: level, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(maxItemsDiff.From), ColorizedValue(maxItemsDiff.To)), + Text: config.Localize(id, ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(maxItemsDiff.From), ColorizedValue(maxItemsDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameters-max-length-set.go b/checker/check-request-parameters-max-length-set.go index 26637c76..0f5a7192 100644 --- a/checker/check-request-parameters-max-length-set.go +++ b/checker/check-request-parameters-max-length-set.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -38,8 +36,8 @@ func RequestParameterMaxLengthSetCheck(diffReport *diff.Diff, operationsSources result = append(result, ApiChange{ Id: "request-parameter-max-length-set", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-parameter-max-length-set"), ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(maxLengthDiff.To)), - Comment: config.i18n("request-parameter-max-length-set-comment"), + Text: config.Localize("request-parameter-max-length-set", ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(maxLengthDiff.To)), + Comment: config.Localize("request-parameter-max-length-set-comment"), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameters-max-length-updated.go b/checker/check-request-parameters-max-length-updated.go index 191ebd73..99734655 100644 --- a/checker/check-request-parameters-max-length-updated.go +++ b/checker/check-request-parameters-max-length-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -45,7 +43,7 @@ func RequestParameterMaxLengthUpdatedCheck(diffReport *diff.Diff, operationsSour result = append(result, ApiChange{ Id: id, Level: level, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(maxLengthDiff.From), ColorizedValue(maxLengthDiff.To)), + Text: config.Localize(id, ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(maxLengthDiff.From), ColorizedValue(maxLengthDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameters-max-set.go b/checker/check-request-parameters-max-set.go index 6dc8929b..7b979ebc 100644 --- a/checker/check-request-parameters-max-set.go +++ b/checker/check-request-parameters-max-set.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -38,8 +36,8 @@ func RequestParameterMaxSetCheck(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "request-parameter-max-set", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-parameter-max-set"), ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(maxDiff.To)), - Comment: config.i18n("request-parameter-max-set-comment"), + Text: config.Localize("request-parameter-max-set", ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(maxDiff.To)), + Comment: config.Localize("request-parameter-max-set-comment"), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameters-max-updated.go b/checker/check-request-parameters-max-updated.go index c61ab10e..9e23b3c7 100644 --- a/checker/check-request-parameters-max-updated.go +++ b/checker/check-request-parameters-max-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -46,7 +44,7 @@ func RequestParameterMaxUpdatedCheck(diffReport *diff.Diff, operationsSources *d result = append(result, ApiChange{ Id: id, Level: level, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(maxDiff.From), ColorizedValue(maxDiff.To)), + Text: config.Localize(id, ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(maxDiff.From), ColorizedValue(maxDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameters-min-items-set.go b/checker/check-request-parameters-min-items-set.go index a8ff7cd6..2ce17ef6 100644 --- a/checker/check-request-parameters-min-items-set.go +++ b/checker/check-request-parameters-min-items-set.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -37,8 +35,8 @@ func RequestParameterMinItemsSetCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: "request-parameter-min-items-set", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-parameter-min-items-set"), ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(minItemsDiff.To)), - Comment: config.i18n("request-parameter-min-items-set-comment"), + Text: config.Localize("request-parameter-min-items-set", ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(minItemsDiff.To)), + Comment: config.Localize("request-parameter-min-items-set-comment"), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameters-min-items-updated.go b/checker/check-request-parameters-min-items-updated.go index 54183e00..db4a5551 100644 --- a/checker/check-request-parameters-min-items-updated.go +++ b/checker/check-request-parameters-min-items-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -45,7 +43,7 @@ func RequestParameterMinItemsUpdatedCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: id, Level: level, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(minItemsDiff.From), ColorizedValue(minItemsDiff.To)), + Text: config.Localize(id, ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(minItemsDiff.From), ColorizedValue(minItemsDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameters-min-length-updated.go b/checker/check-request-parameters-min-length-updated.go index eb2bde49..4b3e8a3c 100644 --- a/checker/check-request-parameters-min-length-updated.go +++ b/checker/check-request-parameters-min-length-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -45,7 +43,7 @@ func RequestParameterMinLengthUpdatedCheck(diffReport *diff.Diff, operationsSour result = append(result, ApiChange{ Id: id, Level: level, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To)), + Text: config.Localize(id, ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameters-min-set.go b/checker/check-request-parameters-min-set.go index ac31025a..02fc4461 100644 --- a/checker/check-request-parameters-min-set.go +++ b/checker/check-request-parameters-min-set.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -38,8 +36,8 @@ func RequestParameterMinSetCheck(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "request-parameter-min-set", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-parameter-min-set"), ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(minDiff.To)), - Comment: config.i18n("request-parameter-min-set-comment"), + Text: config.Localize("request-parameter-min-set", ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(minDiff.To)), + Comment: config.Localize("request-parameter-min-set-comment"), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameters-min-updated.go b/checker/check-request-parameters-min-updated.go index 3c971f6e..c4fb7fe1 100644 --- a/checker/check-request-parameters-min-updated.go +++ b/checker/check-request-parameters-min-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -45,7 +43,7 @@ func RequestParameterMinUpdatedCheck(diffReport *diff.Diff, operationsSources *d result = append(result, ApiChange{ Id: id, Level: level, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(minDiff.From), ColorizedValue(minDiff.To)), + Text: config.Localize(id, ColorizedValue(paramLocation), ColorizedValue(paramName), ColorizedValue(minDiff.From), ColorizedValue(minDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-parameters-type-changed.go b/checker/check-request-parameters-type-changed.go index f4d3faf2..098a3624 100644 --- a/checker/check-request-parameters-type-changed.go +++ b/checker/check-request-parameters-type-changed.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -72,7 +70,7 @@ func RequestParameterTypeChangedCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: "request-parameter-type-changed", Level: ERR, - Text: fmt.Sprintf(config.i18n("request-parameter-type-changed"), ColorizedValue(paramLocation), ColorizedValue(paramName), empty2none(typeDiff.From), empty2none(formatDiff.From), empty2none(typeDiff.To), empty2none(formatDiff.To)), + Text: config.Localize("request-parameter-type-changed", ColorizedValue(paramLocation), ColorizedValue(paramName), empty2none(typeDiff.From), empty2none(formatDiff.From), empty2none(typeDiff.To), empty2none(formatDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-path-parameter-added.go b/checker/check-request-path-parameter-added.go index 168ce501..cd178c68 100644 --- a/checker/check-request-path-parameter-added.go +++ b/checker/check-request-path-parameter-added.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -29,7 +27,7 @@ func NewRequestPathParameterCheck(diffReport *diff.Diff, operationsSources *diff result = append(result, ApiChange{ Id: "new-request-path-parameter", Level: ERR, - Text: fmt.Sprintf(config.i18n("new-request-path-parameter"), ColorizedValue(paramName)), + Text: config.Localize("new-request-path-parameter", ColorizedValue(paramName)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-all-of-updated.go b/checker/check-request-property-all-of-updated.go index f0d3c9b2..a9f8e670 100644 --- a/checker/check-request-property-all-of-updated.go +++ b/checker/check-request-property-all-of-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -35,8 +33,8 @@ func RequestPropertyAllOfUpdated(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "request-body-all-of-added", Level: ERR, - Text: fmt.Sprintf( - config.i18n("request-body-all-of-added"), + Text: config.Localize( + "request-body-all-of-added", ColorizedValue(mediaTypeDiff.SchemaDiff.AllOfDiff.Added.String())), Operation: operation, OperationId: operationItem.Revision.OperationID, @@ -49,8 +47,8 @@ func RequestPropertyAllOfUpdated(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "request-body-all-of-removed", Level: WARN, - Text: fmt.Sprintf( - config.i18n("request-body-all-of-removed"), + Text: config.Localize( + "request-body-all-of-removed", ColorizedValue(mediaTypeDiff.SchemaDiff.AllOfDiff.Deleted.String())), Operation: operation, OperationId: operationItem.Revision.OperationID, @@ -70,8 +68,8 @@ func RequestPropertyAllOfUpdated(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "request-property-all-of-added", Level: ERR, - Text: fmt.Sprintf( - config.i18n("request-property-all-of-added"), + Text: config.Localize( + "request-property-all-of-added", ColorizedValue(propertyDiff.AllOfDiff.Added.String()), ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, @@ -85,8 +83,8 @@ func RequestPropertyAllOfUpdated(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "request-property-all-of-removed", Level: WARN, - Text: fmt.Sprintf( - config.i18n("request-property-all-of-removed"), + Text: config.Localize( + "request-property-all-of-removed", ColorizedValue(propertyDiff.AllOfDiff.Deleted.String()), ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, diff --git a/checker/check-request-property-any-of-updated.go b/checker/check-request-property-any-of-updated.go index ce587ead..8f866758 100644 --- a/checker/check-request-property-any-of-updated.go +++ b/checker/check-request-property-any-of-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -35,8 +33,8 @@ func RequestPropertyAnyOfUpdated(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "request-body-any-of-added", Level: INFO, - Text: fmt.Sprintf( - config.i18n("request-body-any-of-added"), + Text: config.Localize( + "request-body-any-of-added", ColorizedValue(mediaTypeDiff.SchemaDiff.AnyOfDiff.Added.String())), Operation: operation, OperationId: operationItem.Revision.OperationID, @@ -49,8 +47,8 @@ func RequestPropertyAnyOfUpdated(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "request-body-any-of-removed", Level: ERR, - Text: fmt.Sprintf( - config.i18n("request-body-any-of-removed"), + Text: config.Localize( + "request-body-any-of-removed", ColorizedValue(mediaTypeDiff.SchemaDiff.AnyOfDiff.Deleted.String())), Operation: operation, OperationId: operationItem.Revision.OperationID, @@ -70,8 +68,8 @@ func RequestPropertyAnyOfUpdated(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "request-property-any-of-added", Level: INFO, - Text: fmt.Sprintf( - config.i18n("request-property-any-of-added"), + Text: config.Localize( + "request-property-any-of-added", ColorizedValue(propertyDiff.AnyOfDiff.Added.String()), ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, @@ -85,8 +83,8 @@ func RequestPropertyAnyOfUpdated(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "request-property-any-of-removed", Level: ERR, - Text: fmt.Sprintf( - config.i18n("request-property-any-of-removed"), + Text: config.Localize( + "request-property-any-of-removed", ColorizedValue(propertyDiff.AnyOfDiff.Deleted.String()), ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, diff --git a/checker/check-request-property-became-enum.go b/checker/check-request-property-became-enum.go index 0e1426bd..c62bfc86 100644 --- a/checker/check-request-property-became-enum.go +++ b/checker/check-request-property-became-enum.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -42,7 +40,7 @@ func RequestPropertyBecameEnumCheck(diffReport *diff.Diff, operationsSources *di result = append(result, ApiChange{ Id: requestPropertyBecameEnumId, Level: ERR, - Text: fmt.Sprintf(config.i18n(requestPropertyBecameEnumId), ColorizedValue(propertyFullName(propertyPath, propertyName))), + Text: config.Localize(requestPropertyBecameEnumId, ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-became-not-nuallable.go b/checker/check-request-property-became-not-nuallable.go index cb26c9e9..0a4a6909 100644 --- a/checker/check-request-property-became-not-nuallable.go +++ b/checker/check-request-property-became-not-nuallable.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -39,7 +37,7 @@ func RequestPropertyBecameNotNullableCheck(diffReport *diff.Diff, operationsSour result = append(result, ApiChange{ Id: requestBodyBecameNotNullableId, Level: ERR, - Text: config.i18n(requestBodyBecameNotNullableId), + Text: config.Localize(requestBodyBecameNotNullableId), Operation: operation, Path: path, Source: source, @@ -49,7 +47,7 @@ func RequestPropertyBecameNotNullableCheck(diffReport *diff.Diff, operationsSour result = append(result, ApiChange{ Id: requestBodyBecameNullableId, Level: INFO, - Text: config.i18n(requestBodyBecameNullableId), + Text: config.Localize(requestBodyBecameNullableId), Operation: operation, Path: path, Source: source, @@ -69,7 +67,7 @@ func RequestPropertyBecameNotNullableCheck(diffReport *diff.Diff, operationsSour result = append(result, ApiChange{ Id: requestPropertyBecameNotNullableId, Level: ERR, - Text: fmt.Sprintf(config.i18n(requestPropertyBecameNotNullableId), ColorizedValue(propertyFullName(propertyPath, propertyName))), + Text: config.Localize(requestPropertyBecameNotNullableId, ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, Path: path, Source: source, @@ -79,7 +77,7 @@ func RequestPropertyBecameNotNullableCheck(diffReport *diff.Diff, operationsSour result = append(result, ApiChange{ Id: requestPropertyBecameNullableId, Level: INFO, - Text: fmt.Sprintf(config.i18n(requestPropertyBecameNullableId), ColorizedValue(propertyFullName(propertyPath, propertyName))), + Text: config.Localize(requestPropertyBecameNullableId, ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, Path: path, Source: source, diff --git a/checker/check-request-property-default-value-changed.go b/checker/check-request-property-default-value-changed.go index 721210cf..b0d702e0 100644 --- a/checker/check-request-property-default-value-changed.go +++ b/checker/check-request-property-default-value-changed.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -27,7 +25,7 @@ func RequestPropertyDefaultValueChangedCheck(diffReport *diff.Diff, operationsSo result = append(result, ApiChange{ Id: messageId, Level: INFO, - Text: fmt.Sprintf(config.i18n(messageId), a...), + Text: config.Localize(messageId, a...), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-enum-value-updated.go b/checker/check-request-property-enum-value-updated.go index 61a5d795..101ce2e1 100644 --- a/checker/check-request-property-enum-value-updated.go +++ b/checker/check-request-property-enum-value-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -41,7 +39,7 @@ func RequestPropertyEnumValueUpdatedCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: "request-property-enum-value-removed", Level: level, - Text: fmt.Sprintf(config.i18n("request-property-enum-value-removed"), ColorizedValue(enumVal), ColorizedValue(propertyFullName(propertyPath, propertyName))), + Text: config.Localize("request-property-enum-value-removed", ColorizedValue(enumVal), ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -53,7 +51,7 @@ func RequestPropertyEnumValueUpdatedCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: "request-property-enum-value-added", Level: INFO, - Text: fmt.Sprintf(config.i18n("request-property-enum-value-added"), ColorizedValue(enumVal), ColorizedValue(propertyFullName(propertyPath, propertyName))), + Text: config.Localize("request-property-enum-value-added", ColorizedValue(enumVal), ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-max-length-set.go b/checker/check-request-property-max-length-set.go index e10004e0..7e77a952 100644 --- a/checker/check-request-property-max-length-set.go +++ b/checker/check-request-property-max-length-set.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -32,8 +30,8 @@ func RequestPropertyMaxLengthSetCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: "request-body-max-length-set", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-body-max-length-set"), ColorizedValue(maxLengthDiff.To)), - Comment: config.i18n("request-body-max-length-set-comment"), + Text: config.Localize("request-body-max-length-set", ColorizedValue(maxLengthDiff.To)), + Comment: config.Localize("request-body-max-length-set-comment"), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -60,8 +58,8 @@ func RequestPropertyMaxLengthSetCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: "request-property-max-length-set", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-property-max-length-set"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxLengthDiff.To)), - Comment: config.i18n("request-property-max-length-set-comment"), + Text: config.Localize("request-property-max-length-set", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxLengthDiff.To)), + Comment: config.Localize("request-property-max-length-set-comment"), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-max-length-updated.go b/checker/check-request-property-max-length-updated.go index 258f3cbc..a4ef6568 100644 --- a/checker/check-request-property-max-length-updated.go +++ b/checker/check-request-property-max-length-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -33,7 +31,7 @@ func RequestPropertyMaxLengthUpdatedCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: "request-body-max-length-decreased", Level: ERR, - Text: fmt.Sprintf(config.i18n("request-body-max-length-decreased"), ColorizedValue(maxLengthDiff.To)), + Text: config.Localize("request-body-max-length-decreased", ColorizedValue(maxLengthDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -43,7 +41,7 @@ func RequestPropertyMaxLengthUpdatedCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: "request-body-max-length-increased", Level: INFO, - Text: fmt.Sprintf(config.i18n("request-body-max-length-increased"), ColorizedValue(maxLengthDiff.From), ColorizedValue(maxLengthDiff.To)), + Text: config.Localize("request-body-max-length-increased", ColorizedValue(maxLengthDiff.From), ColorizedValue(maxLengthDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -69,7 +67,7 @@ func RequestPropertyMaxLengthUpdatedCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: "request-property-max-length-decreased", Level: ConditionalError(!propertyDiff.Revision.Value.ReadOnly), - Text: fmt.Sprintf(config.i18n("request-property-max-length-decreased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxLengthDiff.To)), + Text: config.Localize("request-property-max-length-decreased", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxLengthDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -79,7 +77,7 @@ func RequestPropertyMaxLengthUpdatedCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: "request-property-max-length-increased", Level: INFO, - Text: fmt.Sprintf(config.i18n("request-property-max-length-increased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxLengthDiff.From), ColorizedValue(maxLengthDiff.To)), + Text: config.Localize("request-property-max-length-increased", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxLengthDiff.From), ColorizedValue(maxLengthDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-max-set.go b/checker/check-request-property-max-set.go index c81a9f27..5b0ee8b3 100644 --- a/checker/check-request-property-max-set.go +++ b/checker/check-request-property-max-set.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -32,8 +30,8 @@ func RequestPropertyMaxSetCheck(diffReport *diff.Diff, operationsSources *diff.O result = append(result, ApiChange{ Id: "request-body-max-set", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-body-max-set"), ColorizedValue(maxDiff.To)), - Comment: config.i18n("request-body-max-set-comment"), + Text: config.Localize("request-body-max-set", ColorizedValue(maxDiff.To)), + Comment: config.Localize("request-body-max-set-comment"), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -60,8 +58,8 @@ func RequestPropertyMaxSetCheck(diffReport *diff.Diff, operationsSources *diff.O result = append(result, ApiChange{ Id: "request-property-max-set", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-property-max-set"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxDiff.To)), - Comment: config.i18n("request-property-max-set-comment"), + Text: config.Localize("request-property-max-set", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxDiff.To)), + Comment: config.Localize("request-property-max-set-comment"), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-max-updated.go b/checker/check-request-property-max-updated.go index 106efe0c..94d2aa95 100644 --- a/checker/check-request-property-max-updated.go +++ b/checker/check-request-property-max-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -33,7 +31,7 @@ func RequestPropertyMaxDecreasedCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: "request-body-max-decreased", Level: ERR, - Text: fmt.Sprintf(config.i18n("request-body-max-decreased"), ColorizedValue(maxDiff.To)), + Text: config.Localize("request-body-max-decreased", ColorizedValue(maxDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -43,7 +41,7 @@ func RequestPropertyMaxDecreasedCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: "request-body-max-increased", Level: INFO, - Text: fmt.Sprintf(config.i18n("request-body-max-increased"), ColorizedValue(maxDiff.From), ColorizedValue(maxDiff.To)), + Text: config.Localize("request-body-max-increased", ColorizedValue(maxDiff.From), ColorizedValue(maxDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -73,7 +71,7 @@ func RequestPropertyMaxDecreasedCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: "request-property-max-decreased", Level: level, - Text: fmt.Sprintf(config.i18n("request-property-max-decreased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxDiff.To)), + Text: config.Localize("request-property-max-decreased", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -83,7 +81,7 @@ func RequestPropertyMaxDecreasedCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: "request-property-max-increased", Level: INFO, - Text: fmt.Sprintf(config.i18n("request-property-max-increased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxDiff.From), ColorizedValue(maxDiff.To)), + Text: config.Localize("request-property-max-increased", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxDiff.From), ColorizedValue(maxDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-min-items-increased.go b/checker/check-request-property-min-items-increased.go index e6a7f6b8..b1121348 100644 --- a/checker/check-request-property-min-items-increased.go +++ b/checker/check-request-property-min-items-increased.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -33,7 +31,7 @@ func RequestPropertyMinItemsIncreasedCheck(diffReport *diff.Diff, operationsSour result = append(result, ApiChange{ Id: "request-body-min-items-increased", Level: ERR, - Text: fmt.Sprintf(config.i18n("request-body-min-items-increased"), ColorizedValue(minItemsDiff.To)), + Text: config.Localize("request-body-min-items-increased", ColorizedValue(minItemsDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -64,7 +62,7 @@ func RequestPropertyMinItemsIncreasedCheck(diffReport *diff.Diff, operationsSour result = append(result, ApiChange{ Id: "request-property-min-items-increased", Level: ERR, - Text: fmt.Sprintf(config.i18n("request-property-min-items-increased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minItemsDiff.To)), + Text: config.Localize("request-property-min-items-increased", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minItemsDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-min-items-set.go b/checker/check-request-property-min-items-set.go index 660b9771..c23f1228 100644 --- a/checker/check-request-property-min-items-set.go +++ b/checker/check-request-property-min-items-set.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -32,8 +30,8 @@ func RequestPropertyMinItemsSetCheck(diffReport *diff.Diff, operationsSources *d result = append(result, ApiChange{ Id: "request-body-min-items-set", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-body-min-items-set"), ColorizedValue(minItemsDiff.To)), - Comment: config.i18n("request-body-min-items-set-comment"), + Text: config.Localize("request-body-min-items-set", ColorizedValue(minItemsDiff.To)), + Comment: config.Localize("request-body-min-items-set-comment"), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -60,8 +58,8 @@ func RequestPropertyMinItemsSetCheck(diffReport *diff.Diff, operationsSources *d result = append(result, ApiChange{ Id: "request-property-min-items-set", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-property-min-items-set"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minItemsDiff.To)), - Comment: config.i18n("request-property-min-items-set-comment"), + Text: config.Localize("request-property-min-items-set", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minItemsDiff.To)), + Comment: config.Localize("request-property-min-items-set-comment"), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-min-length-updated.go b/checker/check-request-property-min-length-updated.go index c51cb3c5..eccca9ca 100644 --- a/checker/check-request-property-min-length-updated.go +++ b/checker/check-request-property-min-length-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -33,7 +31,7 @@ func RequestPropertyMinLengthUpdatedCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: "request-body-min-length-increased", Level: ERR, - Text: fmt.Sprintf(config.i18n("request-body-min-length-increased"), ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To)), + Text: config.Localize("request-body-min-length-increased", ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -43,7 +41,7 @@ func RequestPropertyMinLengthUpdatedCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: "request-body-min-length-decreased", Level: INFO, - Text: fmt.Sprintf(config.i18n("request-body-min-length-decreased"), ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To)), + Text: config.Localize("request-body-min-length-decreased", ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -69,7 +67,7 @@ func RequestPropertyMinLengthUpdatedCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: "request-property-min-length-decreased", Level: INFO, - Text: fmt.Sprintf(config.i18n("request-property-min-length-decreased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To)), + Text: config.Localize("request-property-min-length-decreased", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -79,7 +77,7 @@ func RequestPropertyMinLengthUpdatedCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: "request-property-min-length-increased", Level: ERR, - Text: fmt.Sprintf(config.i18n("request-property-min-length-increased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To)), + Text: config.Localize("request-property-min-length-increased", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-min-set.go b/checker/check-request-property-min-set.go index e591e827..67919ab2 100644 --- a/checker/check-request-property-min-set.go +++ b/checker/check-request-property-min-set.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -32,8 +30,8 @@ func RequestPropertyMinSetCheck(diffReport *diff.Diff, operationsSources *diff.O result = append(result, ApiChange{ Id: "request-body-min-set", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-body-min-set"), ColorizedValue(minDiff.To)), - Comment: config.i18n("request-body-min-set-comment"), + Text: config.Localize("request-body-min-set", ColorizedValue(minDiff.To)), + Comment: config.Localize("request-body-min-set-comment"), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -60,8 +58,8 @@ func RequestPropertyMinSetCheck(diffReport *diff.Diff, operationsSources *diff.O result = append(result, ApiChange{ Id: "request-property-min-set", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-property-min-set"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minDiff.To)), - Comment: config.i18n("request-property-min-set-comment"), + Text: config.Localize("request-property-min-set", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minDiff.To)), + Comment: config.Localize("request-property-min-set-comment"), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-min-updated.go b/checker/check-request-property-min-updated.go index 87242a77..aeb772df 100644 --- a/checker/check-request-property-min-updated.go +++ b/checker/check-request-property-min-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -33,7 +31,7 @@ func RequestPropertyMinIncreasedCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: "request-body-min-increased", Level: ERR, - Text: fmt.Sprintf(config.i18n("request-body-min-increased"), ColorizedValue(minDiff.To)), + Text: config.Localize("request-body-min-increased", ColorizedValue(minDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -43,7 +41,7 @@ func RequestPropertyMinIncreasedCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: "request-body-min-decreased", Level: INFO, - Text: fmt.Sprintf(config.i18n("request-body-min-decreased"), ColorizedValue(minDiff.From), ColorizedValue(minDiff.To)), + Text: config.Localize("request-body-min-decreased", ColorizedValue(minDiff.From), ColorizedValue(minDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -68,7 +66,7 @@ func RequestPropertyMinIncreasedCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: "request-property-min-increased", Level: ConditionalError(!propertyDiff.Revision.Value.ReadOnly), - Text: fmt.Sprintf(config.i18n("request-property-min-increased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minDiff.To)), + Text: config.Localize("request-property-min-increased", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -78,7 +76,7 @@ func RequestPropertyMinIncreasedCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: "request-property-min-decreased", Level: INFO, - Text: fmt.Sprintf(config.i18n("request-property-min-decreased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minDiff.From), ColorizedValue(minDiff.To)), + Text: config.Localize("request-property-min-decreased", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minDiff.From), ColorizedValue(minDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-one-of-updated.go b/checker/check-request-property-one-of-updated.go index 17fd3ac3..4b7b9f93 100644 --- a/checker/check-request-property-one-of-updated.go +++ b/checker/check-request-property-one-of-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -35,8 +33,8 @@ func RequestPropertyOneOfUpdated(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "request-body-one-of-added", Level: INFO, - Text: fmt.Sprintf( - config.i18n("request-body-one-of-added"), + Text: config.Localize( + "request-body-one-of-added", ColorizedValue(mediaTypeDiff.SchemaDiff.OneOfDiff.Added.String())), Operation: operation, OperationId: operationItem.Revision.OperationID, @@ -49,8 +47,8 @@ func RequestPropertyOneOfUpdated(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "request-body-one-of-removed", Level: ERR, - Text: fmt.Sprintf( - config.i18n("request-body-one-of-removed"), + Text: config.Localize( + "request-body-one-of-removed", ColorizedValue(mediaTypeDiff.SchemaDiff.OneOfDiff.Deleted.String())), Operation: operation, OperationId: operationItem.Revision.OperationID, @@ -70,8 +68,8 @@ func RequestPropertyOneOfUpdated(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "request-property-one-of-added", Level: INFO, - Text: fmt.Sprintf( - config.i18n("request-property-one-of-added"), + Text: config.Localize( + "request-property-one-of-added", ColorizedValue(propertyDiff.OneOfDiff.Added.String()), ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, @@ -85,8 +83,8 @@ func RequestPropertyOneOfUpdated(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "request-property-one-of-removed", Level: ERR, - Text: fmt.Sprintf( - config.i18n("request-property-one-of-removed"), + Text: config.Localize( + "request-property-one-of-removed", ColorizedValue(propertyDiff.OneOfDiff.Deleted.String()), ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, diff --git a/checker/check-request-property-pattern-added-or-changed.go b/checker/check-request-property-pattern-added-or-changed.go index a6b4127a..012e1220 100644 --- a/checker/check-request-property-pattern-added-or-changed.go +++ b/checker/check-request-property-pattern-added-or-changed.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -37,7 +35,7 @@ func RequestPropertyPatternUpdatedCheck(diffReport *diff.Diff, operationsSources result = append(result, ApiChange{ Id: "request-property-pattern-removed", Level: INFO, - Text: fmt.Sprintf(config.i18n("request-property-pattern-removed"), patternDiff.From, ColorizedValue(propertyFullName(propertyPath, propertyName))), + Text: config.Localize("request-property-pattern-removed", patternDiff.From, ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -47,8 +45,8 @@ func RequestPropertyPatternUpdatedCheck(diffReport *diff.Diff, operationsSources result = append(result, ApiChange{ Id: "request-property-pattern-added", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-property-pattern-added"), patternDiff.To, ColorizedValue(propertyFullName(propertyPath, propertyName))), - Comment: config.i18n("pattern-changed-warn-comment"), + Text: config.Localize("request-property-pattern-added", patternDiff.To, ColorizedValue(propertyFullName(propertyPath, propertyName))), + Comment: config.Localize("pattern-changed-warn-comment"), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -56,7 +54,7 @@ func RequestPropertyPatternUpdatedCheck(diffReport *diff.Diff, operationsSources }) } else { level := WARN - comment := config.i18n("pattern-changed-warn-comment") + comment := config.Localize("pattern-changed-warn-comment") if patternDiff.To == ".*" { level = INFO comment = "" @@ -64,7 +62,7 @@ func RequestPropertyPatternUpdatedCheck(diffReport *diff.Diff, operationsSources result = append(result, ApiChange{ Id: "request-property-pattern-changed", Level: level, - Text: fmt.Sprintf(config.i18n("request-property-pattern-changed"), ColorizedValue(propertyFullName(propertyPath, propertyName)), patternDiff.From, patternDiff.To), + Text: config.Localize("request-property-pattern-changed", ColorizedValue(propertyFullName(propertyPath, propertyName)), patternDiff.From, patternDiff.To), Comment: comment, Operation: operation, OperationId: operationItem.Revision.OperationID, diff --git a/checker/check-request-property-required-updated.go b/checker/check-request-property-required-updated.go index 4072e442..aadd09d4 100644 --- a/checker/check-request-property-required-updated.go +++ b/checker/check-request-property-required-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -45,7 +43,7 @@ func RequestPropertyRequiredUpdatedCheck(diffReport *diff.Diff, operationsSource result = append(result, ApiChange{ Id: "request-property-became-required", Level: ERR, - Text: fmt.Sprintf(config.i18n("request-property-became-required"), ColorizedValue(changedRequiredPropertyName)), + Text: config.Localize("request-property-became-required", ColorizedValue(changedRequiredPropertyName)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -67,7 +65,7 @@ func RequestPropertyRequiredUpdatedCheck(diffReport *diff.Diff, operationsSource result = append(result, ApiChange{ Id: "request-property-became-optional", Level: INFO, - Text: fmt.Sprintf(config.i18n("request-property-became-optional"), ColorizedValue(changedRequiredPropertyName)), + Text: config.Localize("request-property-became-optional", ColorizedValue(changedRequiredPropertyName)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -98,7 +96,7 @@ func RequestPropertyRequiredUpdatedCheck(diffReport *diff.Diff, operationsSource result = append(result, ApiChange{ Id: "request-property-became-required", Level: ERR, - Text: fmt.Sprintf(config.i18n("request-property-became-required"), ColorizedValue(propertyFullName(propertyPath, propertyFullName(propertyName, changedRequiredPropertyName)))), + Text: config.Localize("request-property-became-required", ColorizedValue(propertyFullName(propertyPath, propertyFullName(propertyName, changedRequiredPropertyName)))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -120,7 +118,7 @@ func RequestPropertyRequiredUpdatedCheck(diffReport *diff.Diff, operationsSource result = append(result, ApiChange{ Id: "request-property-became-optional", Level: INFO, - Text: fmt.Sprintf(config.i18n("request-property-became-optional"), ColorizedValue(propertyFullName(propertyPath, propertyFullName(propertyName, changedRequiredPropertyName)))), + Text: config.Localize("request-property-became-optional", ColorizedValue(propertyFullName(propertyPath, propertyFullName(propertyName, changedRequiredPropertyName)))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-type-changed.go b/checker/check-request-property-type-changed.go index 839bc61e..79a9b48c 100644 --- a/checker/check-request-property-type-changed.go +++ b/checker/check-request-property-type-changed.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -36,7 +34,7 @@ func RequestPropertyTypeChangedCheck(diffReport *diff.Diff, operationsSources *d result = append(result, ApiChange{ Id: "request-body-type-changed", Level: ConditionalError(breakingTypeFormatChangedInRequestProperty(typeDiff, formatDiff, mediaType, schemaDiff)), - Text: fmt.Sprintf(config.i18n("request-body-type-changed"), empty2none(typeDiff.From), empty2none(formatDiff.From), empty2none(typeDiff.To), empty2none(formatDiff.To)), + Text: config.Localize("request-body-type-changed", empty2none(typeDiff.From), empty2none(formatDiff.From), empty2none(typeDiff.To), empty2none(formatDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -64,7 +62,7 @@ func RequestPropertyTypeChangedCheck(diffReport *diff.Diff, operationsSources *d result = append(result, ApiChange{ Id: "request-property-type-changed", Level: ConditionalError(breakingTypeFormatChangedInRequestProperty(typeDiff, formatDiff, mediaType, schemaDiff)), - Text: fmt.Sprintf(config.i18n("request-property-type-changed"), ColorizedValue(propertyFullName(propertyPath, propertyName)), empty2none(typeDiff.From), empty2none(formatDiff.From), empty2none(typeDiff.To), empty2none(formatDiff.To)), + Text: config.Localize("request-property-type-changed", ColorizedValue(propertyFullName(propertyPath, propertyName)), empty2none(typeDiff.From), empty2none(formatDiff.From), empty2none(typeDiff.To), empty2none(formatDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-updated.go b/checker/check-request-property-updated.go index 35c5a694..cb50390a 100644 --- a/checker/check-request-property-updated.go +++ b/checker/check-request-property-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/getkin/kin-openapi/openapi3" "github.com/tufin/oasdiff/diff" "golang.org/x/exp/slices" @@ -33,7 +31,7 @@ func RequestPropertyUpdatedCheck(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "request-property-removed", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-property-removed"), ColorizedValue(propertyFullName(propertyPath, propertyName))), + Text: config.Localize("request-property-removed", ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -52,7 +50,7 @@ func RequestPropertyUpdatedCheck(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "new-required-request-property", Level: ERR, - Text: fmt.Sprintf(config.i18n("new-required-request-property"), ColorizedValue(propertyFullName(propertyPath, propertyName))), + Text: config.Localize("new-required-request-property", ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -62,7 +60,7 @@ func RequestPropertyUpdatedCheck(diffReport *diff.Diff, operationsSources *diff. result = append(result, ApiChange{ Id: "new-optional-request-property", Level: INFO, - Text: fmt.Sprintf(config.i18n("new-optional-request-property"), ColorizedValue(propertyFullName(propertyPath, propertyName))), + Text: config.Localize("new-optional-request-property", ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-write-only-read-only.go b/checker/check-request-property-write-only-read-only.go index 1ecceda0..93f50de6 100644 --- a/checker/check-request-property-write-only-read-only.go +++ b/checker/check-request-property-write-only-read-only.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" "golang.org/x/exp/slices" ) @@ -61,7 +59,7 @@ func RequestPropertyWriteOnlyReadOnlyCheck(diffReport *diff.Diff, operationsSour result = append(result, ApiChange{ Id: id, Level: INFO, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyName))), + Text: config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -77,7 +75,7 @@ func RequestPropertyWriteOnlyReadOnlyCheck(diffReport *diff.Diff, operationsSour result = append(result, ApiChange{ Id: id, Level: INFO, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyName))), + Text: config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -104,7 +102,7 @@ func RequestPropertyWriteOnlyReadOnlyCheck(diffReport *diff.Diff, operationsSour result = append(result, ApiChange{ Id: id, Level: INFO, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyName))), + Text: config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -120,7 +118,7 @@ func RequestPropertyWriteOnlyReadOnlyCheck(diffReport *diff.Diff, operationsSour result = append(result, ApiChange{ Id: id, Level: INFO, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyName))), + Text: config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-request-property-x-extensible-enum-value-removed.go b/checker/check-request-property-x-extensible-enum-value-removed.go index 1e05886c..30cfff1c 100644 --- a/checker/check-request-property-x-extensible-enum-value-removed.go +++ b/checker/check-request-property-x-extensible-enum-value-removed.go @@ -88,7 +88,7 @@ func RequestPropertyXExtensibleEnumValueRemovedCheck(diffReport *diff.Diff, oper result = append(result, ApiChange{ Id: "request-property-x-extensible-enum-value-removed", Level: ERR, - Text: fmt.Sprintf(config.i18n("request-property-x-extensible-enum-value-removed"), enumVal, ColorizedValue(propertyFullName(propertyPath, propertyName))), + Text: config.Localize("request-property-x-extensible-enum-value-removed", enumVal, ColorizedValue(propertyFullName(propertyPath, propertyName))), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-discriminator-updated.go b/checker/check-response-discriminator-updated.go index 6a3650e9..60c1dfcf 100644 --- a/checker/check-response-discriminator-updated.go +++ b/checker/check-response-discriminator-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -27,7 +25,7 @@ func ResponseDiscriminatorUpdatedCheck(diffReport *diff.Diff, operationsSources result = append(result, ApiChange{ Id: messageId, Level: INFO, - Text: fmt.Sprintf(config.i18n(messageId), a...), + Text: config.Localize(messageId, a...), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-header-became-optional.go b/checker/check-response-header-became-optional.go index c4965329..9baf1d16 100644 --- a/checker/check-response-header-became-optional.go +++ b/checker/check-response-header-became-optional.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -40,7 +38,7 @@ func ResponseHeaderBecameOptional(diffReport *diff.Diff, operationsSources *diff result = append(result, ApiChange{ Id: "response-header-became-optional", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-header-became-optional"), ColorizedValue(headerName), ColorizedValue(responseStatus)), + Text: config.Localize("response-header-became-optional", ColorizedValue(headerName), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-header-removed.go b/checker/check-response-header-removed.go index 0cd58e06..669f72d1 100644 --- a/checker/check-response-header-removed.go +++ b/checker/check-response-header-removed.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -37,7 +35,7 @@ func ResponseHeaderRemoved(diffReport *diff.Diff, operationsSources *diff.Operat result = append(result, ApiChange{ Id: "required-response-header-removed", Level: ERR, - Text: fmt.Sprintf(config.i18n("required-response-header-removed"), ColorizedValue(headerName), ColorizedValue(responseStatus)), + Text: config.Localize("required-response-header-removed", ColorizedValue(headerName), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -47,7 +45,7 @@ func ResponseHeaderRemoved(diffReport *diff.Diff, operationsSources *diff.Operat result = append(result, ApiChange{ Id: "optional-response-header-removed", Level: WARN, - Text: fmt.Sprintf(config.i18n("optional-response-header-removed"), ColorizedValue(headerName), ColorizedValue(responseStatus)), + Text: config.Localize("optional-response-header-removed", ColorizedValue(headerName), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-mediatype-enum-value-removed.go b/checker/check-response-mediatype-enum-value-removed.go index 85b440cb..7c570e1f 100644 --- a/checker/check-response-mediatype-enum-value-removed.go +++ b/checker/check-response-mediatype-enum-value-removed.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -47,7 +45,7 @@ func ResponseMediaTypeEnumValueRemovedCheck(diffReport *diff.Diff, operationsSou result = append(result, ApiChange{ Id: responseMediatypeEnumValueRemovedId, Level: config.getLogLevel(responseMediatypeEnumValueRemovedId, ERR), - Text: fmt.Sprintf(config.i18n(responseMediatypeEnumValueRemovedId), mediaType, ColorizedValue(enumVal)), + Text: config.Localize(responseMediatypeEnumValueRemovedId, mediaType, ColorizedValue(enumVal)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-mediatype-updated.go b/checker/check-response-mediatype-updated.go index 7b9b9e5d..90367ca2 100644 --- a/checker/check-response-mediatype-updated.go +++ b/checker/check-response-mediatype-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -39,7 +37,7 @@ func ResponseMediaTypeUpdated(diffReport *diff.Diff, operationsSources *diff.Ope result = append(result, ApiChange{ Id: ResponseMediaTypeUpdatedId, Level: ERR, - Text: fmt.Sprintf(config.i18n(ResponseMediaTypeUpdatedId), ColorizedValue(mediaType), ColorizedValue(responseStatus)), + Text: config.Localize(ResponseMediaTypeUpdatedId, ColorizedValue(mediaType), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -50,7 +48,7 @@ func ResponseMediaTypeUpdated(diffReport *diff.Diff, operationsSources *diff.Ope result = append(result, ApiChange{ Id: ResponseMediaTypeAddedId, Level: INFO, - Text: fmt.Sprintf(config.i18n(ResponseMediaTypeAddedId), ColorizedValue(mediaType), ColorizedValue(responseStatus)), + Text: config.Localize(ResponseMediaTypeAddedId, ColorizedValue(mediaType), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-optional-property-updated.go b/checker/check-response-optional-property-updated.go index 46c9260f..9c1de2e3 100644 --- a/checker/check-response-optional-property-updated.go +++ b/checker/check-response-optional-property-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/getkin/kin-openapi/openapi3" "github.com/tufin/oasdiff/diff" "golang.org/x/exp/slices" @@ -48,7 +46,7 @@ func ResponseOptionalPropertyUpdatedCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: id, Level: level, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), + Text: config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -69,7 +67,7 @@ func ResponseOptionalPropertyUpdatedCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: id, Level: INFO, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), + Text: config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-optional-property-write-only-read-only.go b/checker/check-response-optional-property-write-only-read-only.go index 0ef6d8f4..64a5a7ad 100644 --- a/checker/check-response-optional-property-write-only-read-only.go +++ b/checker/check-response-optional-property-write-only-read-only.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" "golang.org/x/exp/slices" ) @@ -67,7 +65,7 @@ func ResponseOptionalPropertyWriteOnlyReadOnlyCheck(diffReport *diff.Diff, opera result = append(result, ApiChange{ Id: id, Level: INFO, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), + Text: config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -100,7 +98,7 @@ func ResponseOptionalPropertyWriteOnlyReadOnlyCheck(diffReport *diff.Diff, opera result = append(result, ApiChange{ Id: id, Level: INFO, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), + Text: config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-pattern-added-or-changed.go b/checker/check-response-pattern-added-or-changed.go index 2087fbfe..ea8f7686 100644 --- a/checker/check-response-pattern-added-or-changed.go +++ b/checker/check-response-pattern-added-or-changed.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -49,14 +47,14 @@ func ResponsePatternAddedOrChangedCheck(diffReport *diff.Diff, operationsSources } id := ResponsePropertyPatternChangedId - text := fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(patternDiff.From), ColorizedValue(patternDiff.To), ColorizedValue(responseStatus)) + text := config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(patternDiff.From), ColorizedValue(patternDiff.To), ColorizedValue(responseStatus)) if patternDiff.To == "" || patternDiff.To == nil { id = ResponsePropertyPatternRemovedId - text = fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(patternDiff.From), ColorizedValue(responseStatus)) + text = config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(patternDiff.From), ColorizedValue(responseStatus)) } else if patternDiff.From == "" || patternDiff.From == nil { id = ResponsePropertyPatternAddedId - text = fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(patternDiff.To), ColorizedValue(responseStatus)) + text = config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(patternDiff.To), ColorizedValue(responseStatus)) } result = append(result, ApiChange{ diff --git a/checker/check-response-property-all-of-updated.go b/checker/check-response-property-all-of-updated.go index 0b6b1fd9..488c5d4e 100644 --- a/checker/check-response-property-all-of-updated.go +++ b/checker/check-response-property-all-of-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -38,8 +36,8 @@ func ResponsePropertyAllOfUpdated(diffReport *diff.Diff, operationsSources *diff result = append(result, ApiChange{ Id: "response-body-all-of-added", Level: INFO, - Text: fmt.Sprintf( - config.i18n("response-body-all-of-added"), + Text: config.Localize( + "response-body-all-of-added", ColorizedValue(mediaTypeDiff.SchemaDiff.AllOfDiff.Added.String()), responseStatus), Operation: operation, @@ -53,8 +51,8 @@ func ResponsePropertyAllOfUpdated(diffReport *diff.Diff, operationsSources *diff result = append(result, ApiChange{ Id: "response-body-all-of-removed", Level: INFO, - Text: fmt.Sprintf( - config.i18n("response-body-all-of-removed"), + Text: config.Localize( + "response-body-all-of-removed", ColorizedValue(mediaTypeDiff.SchemaDiff.AllOfDiff.Deleted.String()), responseStatus), Operation: operation, @@ -75,8 +73,8 @@ func ResponsePropertyAllOfUpdated(diffReport *diff.Diff, operationsSources *diff result = append(result, ApiChange{ Id: "response-property-all-of-added", Level: INFO, - Text: fmt.Sprintf( - config.i18n("response-property-all-of-added"), + Text: config.Localize( + "response-property-all-of-added", ColorizedValue(propertyDiff.AllOfDiff.Added.String()), ColorizedValue(propertyFullName(propertyPath, propertyName)), responseStatus), @@ -91,8 +89,8 @@ func ResponsePropertyAllOfUpdated(diffReport *diff.Diff, operationsSources *diff result = append(result, ApiChange{ Id: "response-property-all-of-removed", Level: INFO, - Text: fmt.Sprintf( - config.i18n("response-property-all-of-removed"), + Text: config.Localize( + "response-property-all-of-removed", ColorizedValue(propertyDiff.AllOfDiff.Deleted.String()), ColorizedValue(propertyFullName(propertyPath, propertyName)), responseStatus), diff --git a/checker/check-response-property-any-of-updated.go b/checker/check-response-property-any-of-updated.go index 1bc08367..1eafca15 100644 --- a/checker/check-response-property-any-of-updated.go +++ b/checker/check-response-property-any-of-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -38,8 +36,8 @@ func ResponsePropertyAnyOfUpdated(diffReport *diff.Diff, operationsSources *diff result = append(result, ApiChange{ Id: "response-body-any-of-added", Level: INFO, - Text: fmt.Sprintf( - config.i18n("response-body-any-of-added"), + Text: config.Localize( + "response-body-any-of-added", ColorizedValue(mediaTypeDiff.SchemaDiff.AnyOfDiff.Added.String()), responseStatus), Operation: operation, @@ -53,8 +51,8 @@ func ResponsePropertyAnyOfUpdated(diffReport *diff.Diff, operationsSources *diff result = append(result, ApiChange{ Id: "response-body-any-of-removed", Level: INFO, - Text: fmt.Sprintf( - config.i18n("response-body-any-of-removed"), + Text: config.Localize( + "response-body-any-of-removed", ColorizedValue(mediaTypeDiff.SchemaDiff.AnyOfDiff.Deleted.String()), responseStatus), Operation: operation, @@ -75,8 +73,8 @@ func ResponsePropertyAnyOfUpdated(diffReport *diff.Diff, operationsSources *diff result = append(result, ApiChange{ Id: "response-property-any-of-added", Level: INFO, - Text: fmt.Sprintf( - config.i18n("response-property-any-of-added"), + Text: config.Localize( + "response-property-any-of-added", ColorizedValue(propertyDiff.AnyOfDiff.Added.String()), ColorizedValue(propertyFullName(propertyPath, propertyName)), responseStatus), @@ -91,8 +89,8 @@ func ResponsePropertyAnyOfUpdated(diffReport *diff.Diff, operationsSources *diff result = append(result, ApiChange{ Id: "response-property-any-of-removed", Level: INFO, - Text: fmt.Sprintf( - config.i18n("response-property-any-of-removed"), + Text: config.Localize( + "response-property-any-of-removed", ColorizedValue(propertyDiff.AnyOfDiff.Deleted.String()), ColorizedValue(propertyFullName(propertyPath, propertyName)), responseStatus), diff --git a/checker/check-response-property-became-nuallable.go b/checker/check-response-property-became-nuallable.go index 65924a0c..0c8fbdc0 100644 --- a/checker/check-response-property-became-nuallable.go +++ b/checker/check-response-property-became-nuallable.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -41,7 +39,7 @@ func ResponsePropertyBecameNullableCheck(diffReport *diff.Diff, operationsSource result = append(result, ApiChange{ Id: responseBodyBecameNullableId, Level: ERR, - Text: config.i18n(responseBodyBecameNullableId), + Text: config.Localize(responseBodyBecameNullableId), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -63,7 +61,7 @@ func ResponsePropertyBecameNullableCheck(diffReport *diff.Diff, operationsSource result = append(result, ApiChange{ Id: responsePropertyBecameNullableId, Level: ERR, - Text: fmt.Sprintf(config.i18n(responsePropertyBecameNullableId), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), + Text: config.Localize(responsePropertyBecameNullableId, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-property-became-optional.go b/checker/check-response-property-became-optional.go index 0902be9b..e4dc8760 100644 --- a/checker/check-response-property-became-optional.go +++ b/checker/check-response-property-became-optional.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -55,7 +53,7 @@ func ResponsePropertyBecameOptionalCheck(diffReport *diff.Diff, operationsSource result = append(result, ApiChange{ Id: id, Level: level, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(changedRequiredPropertyName), ColorizedValue(responseStatus)), + Text: config.Localize(id, ColorizedValue(changedRequiredPropertyName), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -89,7 +87,7 @@ func ResponsePropertyBecameOptionalCheck(diffReport *diff.Diff, operationsSource result = append(result, ApiChange{ Id: id, Level: level, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyFullName(propertyName, changedRequiredPropertyName))), ColorizedValue(responseStatus)), + Text: config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyFullName(propertyName, changedRequiredPropertyName))), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-property-became-required.go b/checker/check-response-property-became-required.go index 4b7b04d3..04033435 100644 --- a/checker/check-response-property-became-required.go +++ b/checker/check-response-property-became-required.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -53,7 +51,7 @@ func ResponsePropertyBecameRequiredCheck(diffReport *diff.Diff, operationsSource result = append(result, ApiChange{ Id: id, Level: INFO, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(changedRequiredPropertyName), ColorizedValue(responseStatus)), + Text: config.Localize(id, ColorizedValue(changedRequiredPropertyName), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -84,7 +82,7 @@ func ResponsePropertyBecameRequiredCheck(diffReport *diff.Diff, operationsSource result = append(result, ApiChange{ Id: id, Level: INFO, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyFullName(propertyName, changedRequiredPropertyName))), ColorizedValue(responseStatus)), + Text: config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyFullName(propertyName, changedRequiredPropertyName))), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-property-default-value-changed.go b/checker/check-response-property-default-value-changed.go index 34e6def8..1de38603 100644 --- a/checker/check-response-property-default-value-changed.go +++ b/checker/check-response-property-default-value-changed.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -25,7 +23,7 @@ func ResponsePropertyDefaultValueChangedCheck(diffReport *diff.Diff, operationsS result = append(result, ApiChange{ Id: messageId, Level: INFO, - Text: fmt.Sprintf(config.i18n(messageId), a...), + Text: config.Localize(messageId, a...), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-property-enum-value-added.go b/checker/check-response-property-enum-value-added.go index ba9ccde6..f5081501 100644 --- a/checker/check-response-property-enum-value-added.go +++ b/checker/check-response-property-enum-value-added.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -43,7 +41,7 @@ func ResponsePropertyEnumValueAddedCheck(diffReport *diff.Diff, operationsSource id := ResponsePropertyEnumValueAddedCheckId level := WARN - comment := config.i18n("response-property-enum-value-added-comment") + comment := config.Localize("response-property-enum-value-added-comment") if propertyDiff.Revision.Value.WriteOnly { // Document write-only enum update @@ -56,7 +54,7 @@ func ResponsePropertyEnumValueAddedCheck(diffReport *diff.Diff, operationsSource result = append(result, ApiChange{ Id: id, Level: level, - Text: fmt.Sprintf(config.i18n(id), enumVal, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), + Text: config.Localize(id, enumVal, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), Comment: comment, Operation: operation, OperationId: operationItem.Revision.OperationID, diff --git a/checker/check-response-property-enum-value-removed.go b/checker/check-response-property-enum-value-removed.go index 7d2edce4..ac0ed35a 100644 --- a/checker/check-response-property-enum-value-removed.go +++ b/checker/check-response-property-enum-value-removed.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -42,7 +40,7 @@ func ResponseParameterEnumValueRemovedCheck(diffReport *diff.Diff, operationsSou result = append(result, ApiChange{ Id: responsePropertyEnumValueRemovedId, Level: config.getLogLevel(responsePropertyEnumValueRemovedId, INFO), - Text: fmt.Sprintf(config.i18n(responsePropertyEnumValueRemovedId), enumVal, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), + Text: config.Localize(responsePropertyEnumValueRemovedId, enumVal, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-property-max-increased.go b/checker/check-response-property-max-increased.go index fbc3290b..fcdd8afb 100644 --- a/checker/check-response-property-max-increased.go +++ b/checker/check-response-property-max-increased.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -36,7 +34,7 @@ func ResponsePropertyMaxIncreasedCheck(diffReport *diff.Diff, operationsSources result = append(result, ApiChange{ Id: "response-body-max-increased", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-body-max-increased"), ColorizedValue(maxDiff.From), ColorizedValue(maxDiff.To)), + Text: config.Localize("response-body-max-increased", ColorizedValue(maxDiff.From), ColorizedValue(maxDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -68,7 +66,7 @@ func ResponsePropertyMaxIncreasedCheck(diffReport *diff.Diff, operationsSources result = append(result, ApiChange{ Id: "response-property-max-increased", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-property-max-increased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxDiff.From), ColorizedValue(maxDiff.To), ColorizedValue(responseStatus)), + Text: config.Localize("response-property-max-increased", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxDiff.From), ColorizedValue(maxDiff.To), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-property-max-length-increased.go b/checker/check-response-property-max-length-increased.go index 2c2dbe9f..69e4bbb3 100644 --- a/checker/check-response-property-max-length-increased.go +++ b/checker/check-response-property-max-length-increased.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -36,7 +34,7 @@ func ResponsePropertyMaxLengthIncreasedCheck(diffReport *diff.Diff, operationsSo result = append(result, ApiChange{ Id: "response-body-max-length-increased", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-body-max-length-increased"), ColorizedValue(maxLengthDiff.From), ColorizedValue(maxLengthDiff.To)), + Text: config.Localize("response-body-max-length-increased", ColorizedValue(maxLengthDiff.From), ColorizedValue(maxLengthDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -68,7 +66,7 @@ func ResponsePropertyMaxLengthIncreasedCheck(diffReport *diff.Diff, operationsSo result = append(result, ApiChange{ Id: "response-property-max-length-increased", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-property-max-length-increased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxLengthDiff.From), ColorizedValue(maxLengthDiff.To), ColorizedValue(responseStatus)), + Text: config.Localize("response-property-max-length-increased", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxLengthDiff.From), ColorizedValue(maxLengthDiff.To), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-property-max-length-unset.go b/checker/check-response-property-max-length-unset.go index 75ed4358..8b61217f 100644 --- a/checker/check-response-property-max-length-unset.go +++ b/checker/check-response-property-max-length-unset.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -35,7 +33,7 @@ func ResponsePropertyMaxLengthUnsetCheck(diffReport *diff.Diff, operationsSource result = append(result, ApiChange{ Id: "response-body-max-length-unset", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-body-max-length-unset"), ColorizedValue(maxLengthDiff.From)), + Text: config.Localize("response-body-max-length-unset", ColorizedValue(maxLengthDiff.From)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -62,7 +60,7 @@ func ResponsePropertyMaxLengthUnsetCheck(diffReport *diff.Diff, operationsSource result = append(result, ApiChange{ Id: "response-property-max-length-unset", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-property-max-length-unset"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxLengthDiff.From), ColorizedValue(responseStatus)), + Text: config.Localize("response-property-max-length-unset", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(maxLengthDiff.From), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-property-min-decreased.go b/checker/check-response-property-min-decreased.go index db0d3c58..457e6ec6 100644 --- a/checker/check-response-property-min-decreased.go +++ b/checker/check-response-property-min-decreased.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -36,7 +34,7 @@ func ResponsePropertyMinDecreasedCheck(diffReport *diff.Diff, operationsSources result = append(result, ApiChange{ Id: "response-body-min-decreased", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-body-min-decreased"), ColorizedValue(minDiff.From), ColorizedValue(minDiff.To)), + Text: config.Localize("response-body-min-decreased", ColorizedValue(minDiff.From), ColorizedValue(minDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -68,7 +66,7 @@ func ResponsePropertyMinDecreasedCheck(diffReport *diff.Diff, operationsSources result = append(result, ApiChange{ Id: "response-property-min-decreased", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-property-min-decreased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minDiff.From), ColorizedValue(minDiff.To), ColorizedValue(responseStatus)), + Text: config.Localize("response-property-min-decreased", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minDiff.From), ColorizedValue(minDiff.To), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-property-min-items-decreased.go b/checker/check-response-property-min-items-decreased.go index bc834e86..8ecd3234 100644 --- a/checker/check-response-property-min-items-decreased.go +++ b/checker/check-response-property-min-items-decreased.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -36,7 +34,7 @@ func ResponsePropertyMinItemsDecreasedCheck(diffReport *diff.Diff, operationsSou result = append(result, ApiChange{ Id: "response-body-min-items-decreased", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-body-min-items-decreased"), ColorizedValue(minItemsDiff.From), ColorizedValue(minItemsDiff.To)), + Text: config.Localize("response-body-min-items-decreased", ColorizedValue(minItemsDiff.From), ColorizedValue(minItemsDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -68,7 +66,7 @@ func ResponsePropertyMinItemsDecreasedCheck(diffReport *diff.Diff, operationsSou result = append(result, ApiChange{ Id: "response-property-min-items-decreased", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-property-min-items-decreased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minItemsDiff.From), ColorizedValue(minItemsDiff.To), ColorizedValue(responseStatus)), + Text: config.Localize("response-property-min-items-decreased", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minItemsDiff.From), ColorizedValue(minItemsDiff.To), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-property-min-items-unset.go b/checker/check-response-property-min-items-unset.go index 2b2d7fd2..2fca9aca 100644 --- a/checker/check-response-property-min-items-unset.go +++ b/checker/check-response-property-min-items-unset.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -35,7 +33,7 @@ func ResponsePropertyMinItemsUnsetCheck(diffReport *diff.Diff, operationsSources result = append(result, ApiChange{ Id: "response-body-min-items-unset", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-body-min-items-unset"), ColorizedValue(minItemsDiff.From)), + Text: config.Localize("response-body-min-items-unset", ColorizedValue(minItemsDiff.From)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -62,7 +60,7 @@ func ResponsePropertyMinItemsUnsetCheck(diffReport *diff.Diff, operationsSources result = append(result, ApiChange{ Id: "response-property-min-items-unset", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-property-min-items-unset"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minItemsDiff.From), ColorizedValue(responseStatus)), + Text: config.Localize("response-property-min-items-unset", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minItemsDiff.From), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-property-min-length-decreased.go b/checker/check-response-property-min-length-decreased.go index bf62cc42..6c2309a0 100644 --- a/checker/check-response-property-min-length-decreased.go +++ b/checker/check-response-property-min-length-decreased.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -36,7 +34,7 @@ func ResponsePropertyMinLengthDecreasedCheck(diffReport *diff.Diff, operationsSo result = append(result, ApiChange{ Id: "response-body-min-length-decreased", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-body-min-length-decreased"), ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To)), + Text: config.Localize("response-body-min-length-decreased", ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -68,7 +66,7 @@ func ResponsePropertyMinLengthDecreasedCheck(diffReport *diff.Diff, operationsSo result = append(result, ApiChange{ Id: "response-property-min-length-decreased", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-property-min-length-decreased"), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To), ColorizedValue(responseStatus)), + Text: config.Localize("response-property-min-length-decreased", ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(minLengthDiff.From), ColorizedValue(minLengthDiff.To), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-property-one-of-updated.go b/checker/check-response-property-one-of-updated.go index 71b6c2b6..034a1951 100644 --- a/checker/check-response-property-one-of-updated.go +++ b/checker/check-response-property-one-of-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" ) @@ -38,8 +36,8 @@ func ResponsePropertyOneOfUpdated(diffReport *diff.Diff, operationsSources *diff result = append(result, ApiChange{ Id: "response-body-one-of-added", Level: INFO, - Text: fmt.Sprintf( - config.i18n("response-body-one-of-added"), + Text: config.Localize( + "response-body-one-of-added", ColorizedValue(mediaTypeDiff.SchemaDiff.OneOfDiff.Added.String()), responseStatus), Operation: operation, @@ -53,8 +51,8 @@ func ResponsePropertyOneOfUpdated(diffReport *diff.Diff, operationsSources *diff result = append(result, ApiChange{ Id: "response-body-one-of-removed", Level: INFO, - Text: fmt.Sprintf( - config.i18n("response-body-one-of-removed"), + Text: config.Localize( + "response-body-one-of-removed", ColorizedValue(mediaTypeDiff.SchemaDiff.OneOfDiff.Deleted.String()), responseStatus), Operation: operation, @@ -75,8 +73,8 @@ func ResponsePropertyOneOfUpdated(diffReport *diff.Diff, operationsSources *diff result = append(result, ApiChange{ Id: "response-property-one-of-added", Level: INFO, - Text: fmt.Sprintf( - config.i18n("response-property-one-of-added"), + Text: config.Localize( + "response-property-one-of-added", ColorizedValue(propertyDiff.OneOfDiff.Added.String()), ColorizedValue(propertyFullName(propertyPath, propertyName)), responseStatus), @@ -91,8 +89,8 @@ func ResponsePropertyOneOfUpdated(diffReport *diff.Diff, operationsSources *diff result = append(result, ApiChange{ Id: "response-property-one-of-removed", Level: INFO, - Text: fmt.Sprintf( - config.i18n("response-property-one-of-removed"), + Text: config.Localize( + "response-property-one-of-removed", ColorizedValue(propertyDiff.OneOfDiff.Deleted.String()), ColorizedValue(propertyFullName(propertyPath, propertyName)), responseStatus), diff --git a/checker/check-response-property-type-changed.go b/checker/check-response-property-type-changed.go index 87c6558d..bb23ad2b 100644 --- a/checker/check-response-property-type-changed.go +++ b/checker/check-response-property-type-changed.go @@ -1,7 +1,6 @@ package checker import ( - "fmt" "strings" "github.com/tufin/oasdiff/diff" @@ -39,7 +38,7 @@ func ResponsePropertyTypeChangedCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: "response-body-type-changed", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-body-type-changed"), empty2none(typeDiff.From), empty2none(formatDiff.From), empty2none(typeDiff.To), empty2none(formatDiff.To), ColorizedValue(responseStatus)), + Text: config.Localize("response-body-type-changed", empty2none(typeDiff.From), empty2none(formatDiff.From), empty2none(typeDiff.To), empty2none(formatDiff.To), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -64,7 +63,7 @@ func ResponsePropertyTypeChangedCheck(diffReport *diff.Diff, operationsSources * result = append(result, ApiChange{ Id: "response-property-type-changed", Level: ERR, - Text: fmt.Sprintf(config.i18n("response-property-type-changed"), empty2none(typeDiff.From), empty2none(formatDiff.From), empty2none(typeDiff.To), empty2none(formatDiff.To), ColorizedValue(responseStatus)), + Text: config.Localize("response-property-type-changed", empty2none(typeDiff.From), empty2none(formatDiff.From), empty2none(typeDiff.To), empty2none(formatDiff.To), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-required-property-updated.go b/checker/check-response-required-property-updated.go index 564f492a..f10dfa12 100644 --- a/checker/check-response-required-property-updated.go +++ b/checker/check-response-required-property-updated.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/getkin/kin-openapi/openapi3" "github.com/tufin/oasdiff/diff" "golang.org/x/exp/slices" @@ -55,7 +53,7 @@ func ResponseRequiredPropertyUpdatedCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: id, Level: level, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), + Text: config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -76,7 +74,7 @@ func ResponseRequiredPropertyUpdatedCheck(diffReport *diff.Diff, operationsSourc result = append(result, ApiChange{ Id: id, Level: INFO, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), + Text: config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-required-property-write-only-read-only.go b/checker/check-response-required-property-write-only-read-only.go index 4e30b37f..4efe2279 100644 --- a/checker/check-response-required-property-write-only-read-only.go +++ b/checker/check-response-required-property-write-only-read-only.go @@ -1,8 +1,6 @@ package checker import ( - "fmt" - "github.com/tufin/oasdiff/diff" "golang.org/x/exp/slices" ) @@ -60,7 +58,7 @@ func ResponseRequiredPropertyWriteOnlyReadOnlyCheck(diffReport *diff.Diff, opera id := ResponseRequiredPropertyBecameNonWriteOnlyCheckId level := WARN - comment := config.i18n("response-required-property-became-not-write-only-comment") + comment := config.Localize("response-required-property-became-not-write-only-comment") if writeOnlyDiff.To == true { id = ResponseRequiredPropertyBecameWriteOnlyCheckId @@ -71,7 +69,7 @@ func ResponseRequiredPropertyWriteOnlyReadOnlyCheck(diffReport *diff.Diff, opera result = append(result, ApiChange{ Id: id, Level: level, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), + Text: config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), Comment: comment, Operation: operation, OperationId: operationItem.Revision.OperationID, @@ -107,7 +105,7 @@ func ResponseRequiredPropertyWriteOnlyReadOnlyCheck(diffReport *diff.Diff, opera result = append(result, ApiChange{ Id: id, Level: level, - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), + Text: config.Localize(id, ColorizedValue(propertyFullName(propertyPath, propertyName)), ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-response-status-updated.go b/checker/check-response-status-updated.go index 559dba65..d92e2e58 100644 --- a/checker/check-response-status-updated.go +++ b/checker/check-response-status-updated.go @@ -1,7 +1,6 @@ package checker import ( - "fmt" "strconv" "strings" @@ -51,7 +50,7 @@ func ResponseStatusUpdated(diffReport *diff.Diff, operationsSources *diff.Operat result = append(result, ApiChange{ Id: id, Level: config.getLogLevel(id, defaultLevel), - Text: fmt.Sprintf(config.i18n(id), ColorizedValue(responseStatus)), + Text: config.Localize(id, ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, @@ -73,7 +72,7 @@ func ResponseStatusUpdated(diffReport *diff.Diff, operationsSources *diff.Operat result = append(result, ApiChange{ Id: addedId, Level: config.getLogLevel(addedId, defaultLevel), - Text: fmt.Sprintf(config.i18n(addedId), ColorizedValue(responseStatus)), + Text: config.Localize(addedId, ColorizedValue(responseStatus)), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/check-unchekable-allof-warn.go b/checker/check-unchekable-allof-warn.go index bb56ee0d..bd362adc 100644 --- a/checker/check-unchekable-allof-warn.go +++ b/checker/check-unchekable-allof-warn.go @@ -34,8 +34,8 @@ func UncheckedRequestAllOfWarnCheck(diffReport *diff.Diff, operationsSources *di result = append(result, ApiChange{ Id: "request-allOf-modified", Level: WARN, - Text: fmt.Sprintf(config.i18n("request-allOf-modified"), ColorizedValue(propertyFullName(propertyPath, propertyName))), - Comment: config.i18n("request-allOf-modified-comment"), + Text: config.Localize("request-allOf-modified", ColorizedValue(propertyFullName(propertyPath, propertyName))), + Comment: config.Localize("request-allOf-modified-comment"), Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/checker_deprecation_test.go b/checker/checker_deprecation_test.go index 2a0e1ea2..1895789c 100644 --- a/checker/checker_deprecation_test.go +++ b/checker/checker_deprecation_test.go @@ -10,7 +10,6 @@ import ( "github.com/getkin/kin-openapi/openapi3" "github.com/stretchr/testify/require" "github.com/tufin/oasdiff/checker" - "github.com/tufin/oasdiff/checker/localizations" "github.com/tufin/oasdiff/diff" "github.com/tufin/oasdiff/load" ) @@ -28,7 +27,7 @@ func singleCheckConfig(c checker.BackwardCompatibilityCheck) checker.Config { Checks: []checker.BackwardCompatibilityCheck{c}, MinSunsetBetaDays: 31, MinSunsetStableDays: 180, - Localizer: *localizations.New("en", "en"), + Localize: checker.NewLocalizer("en", "en"), } } diff --git a/checker/component_change.go b/checker/component_change.go index 0ddcb00b..c4c5a38f 100644 --- a/checker/component_change.go +++ b/checker/component_change.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/TwiN/go-color" - "github.com/tufin/oasdiff/checker/localizations" ) // ComponentChange represnts a change in the Components Section: https://swagger.io/docs/specification/components/ @@ -48,11 +47,11 @@ func (ComponentChange) GetPath() string { return "" } -func (c ComponentChange) LocalizedError(l localizations.Localizer) string { - return fmt.Sprintf("%s, %s components %s [%s]. %s", c.Level, l.Get("messages.in"), c.Text, c.Id, c.Comment) +func (c ComponentChange) LocalizedError(l Localizer) string { + return fmt.Sprintf("%s, %s components %s [%s]. %s", c.Level, l("in"), c.Text, c.Id, c.Comment) } -func (c ComponentChange) PrettyErrorText(l localizations.Localizer) string { +func (c ComponentChange) PrettyErrorText(l Localizer) string { if IsPipedOutput() { return c.LocalizedError(l) } @@ -61,7 +60,7 @@ func (c ComponentChange) PrettyErrorText(l localizations.Localizer) string { if c.Comment != "" { comment = fmt.Sprintf("\n\t\t%s", c.Comment) } - return fmt.Sprintf("%s\t[%s] \t\n\t%s components\n\t\t%s%s", c.Level.PrettyString(), color.InYellow(c.Id), l.Get("messages.in"), c.Text, comment) + return fmt.Sprintf("%s\t[%s] \t\n\t%s components\n\t\t%s%s", c.Level.PrettyString(), color.InYellow(c.Id), l("in"), c.Text, comment) } func (c ComponentChange) Error() string { diff --git a/checker/config.go b/checker/config.go index fdcaf549..d142b9ec 100644 --- a/checker/config.go +++ b/checker/config.go @@ -1,19 +1,31 @@ package checker -import "github.com/tufin/oasdiff/checker/localizations" +import ( + "fmt" + + "github.com/tufin/oasdiff/checker/localizations" +) + +type Localizer func(key string, args ...interface{}) string + +func NewLocalizer(locale string, fallbackLocale string) Localizer { + locales := localizations.New(locale, fallbackLocale) + + return func(key string, args ...interface{}) string { + pattern := locales.Get("messages." + key) + + return fmt.Sprintf(pattern, args...) + } +} type Config struct { Checks []BackwardCompatibilityCheck MinSunsetBetaDays int MinSunsetStableDays int - Localizer localizations.Localizer + Localize Localizer LogLevelOverrides map[string]Level } -func (c *Config) i18n(messageID string) string { - return c.Localizer.Get("messages." + messageID) -} - func (c *Config) getLogLevel(checkerId string, defaultLevel Level) Level { if level, ok := c.LogLevelOverrides[checkerId]; ok { return level diff --git a/checker/default_checks.go b/checker/default_checks.go index 02859906..985d302e 100644 --- a/checker/default_checks.go +++ b/checker/default_checks.go @@ -1,7 +1,6 @@ package checker import ( - "github.com/tufin/oasdiff/checker/localizations" "github.com/tufin/oasdiff/utils" ) @@ -34,7 +33,7 @@ func getBackwardCompatibilityCheckConfig(checks []BackwardCompatibilityCheck, le LogLevelOverrides: levelOverrides, MinSunsetBetaDays: minSunsetBetaDays, MinSunsetStableDays: minSunsetStableDays, - Localizer: *localizations.New("en", "en"), + Localize: NewLocalizer("en", "en"), } } diff --git a/checker/security_change.go b/checker/security_change.go index 26e093b2..02b5aa54 100644 --- a/checker/security_change.go +++ b/checker/security_change.go @@ -4,7 +4,6 @@ import ( "fmt" "github.com/TwiN/go-color" - "github.com/tufin/oasdiff/checker/localizations" ) // SecurityChange represnts a change in the Security Section (not to be confised with components/securitySchemes) @@ -48,11 +47,11 @@ func (SecurityChange) GetPath() string { return "" } -func (c SecurityChange) LocalizedError(l localizations.Localizer) string { - return fmt.Sprintf("%s, %s security %s [%s]. %s", c.Level, l.Get("messages.in"), c.Text, c.Id, c.Comment) +func (c SecurityChange) LocalizedError(l Localizer) string { + return fmt.Sprintf("%s, %s security %s [%s]. %s", c.Level, l("in"), c.Text, c.Id, c.Comment) } -func (c SecurityChange) PrettyErrorText(l localizations.Localizer) string { +func (c SecurityChange) PrettyErrorText(l Localizer) string { if IsPipedOutput() { return c.LocalizedError(l) } @@ -61,7 +60,7 @@ func (c SecurityChange) PrettyErrorText(l localizations.Localizer) string { if c.Comment != "" { comment = fmt.Sprintf("\n\t\t%s", c.Comment) } - return fmt.Sprintf("%s\t[%s] \t\n\t%s security\n\t\t%s%s", c.Level.PrettyString(), color.InYellow(c.Id), l.Get("messages.in"), c.Text, comment) + return fmt.Sprintf("%s\t[%s] \t\n\t%s security\n\t\t%s%s", c.Level.PrettyString(), color.InYellow(c.Id), l("in"), c.Text, comment) } func (c SecurityChange) Error() string { diff --git a/diff/example_test.go b/diff/example_test.go index 5a2c5504..8069b6d9 100644 --- a/diff/example_test.go +++ b/diff/example_test.go @@ -7,7 +7,6 @@ import ( "github.com/getkin/kin-openapi/openapi3" "github.com/tufin/oasdiff/checker" - "github.com/tufin/oasdiff/checker/localizations" "github.com/tufin/oasdiff/diff" "github.com/tufin/oasdiff/load" "gopkg.in/yaml.v3" @@ -90,7 +89,7 @@ func ExampleGetPathsDiff() { } c := checker.GetDefaultChecks() - c.Localizer = *localizations.New("en", "en") + c.Localize = checker.NewLocalizer("en", "en") errs := checker.CheckBackwardCompatibility(c, diffRes, operationsSources) // process configuration file for ignoring errors @@ -110,9 +109,9 @@ func ExampleGetPathsDiff() { // pretty print breaking changes errors if len(errs) > 0 { count := errs.GetLevelCount() - fmt.Printf(c.Localizer.Get("messages.total-errors"), len(errs), count[checker.ERR], "error", count[checker.WARN], "warning") + fmt.Print(c.Localize("total-errors", len(errs), count[checker.ERR], "error", count[checker.WARN], "warning")) for _, bcerr := range errs { - fmt.Printf("%s\n\n", strings.TrimRight(bcerr.PrettyErrorText(c.Localizer), " ")) + fmt.Printf("%s\n\n", strings.TrimRight(bcerr.PrettyErrorText(c.Localize), " ")) } } diff --git a/internal/breaking_changes.go b/internal/breaking_changes.go index ba3b04f1..b94922af 100644 --- a/internal/breaking_changes.go +++ b/internal/breaking_changes.go @@ -1,7 +1,6 @@ package internal import ( - "fmt" "io" "github.com/spf13/cobra" @@ -72,8 +71,8 @@ func runBreakingChanges(flags *ChangelogFlags, stdout io.Writer) (bool, *ReturnE func getBreakingChangesTitle(config checker.Config, errs checker.Changes) string { count := errs.GetLevelCount() - return fmt.Sprintf( - config.Localizer.Get("messages.total-errors"), + return config.Localize( + "total-errors", len(errs), count[checker.ERR], checker.ERR.PrettyString(), diff --git a/internal/changelog.go b/internal/changelog.go index 73bc6ed4..ed4a8974 100644 --- a/internal/changelog.go +++ b/internal/changelog.go @@ -7,7 +7,6 @@ import ( "github.com/getkin/kin-openapi/openapi3" "github.com/spf13/cobra" "github.com/tufin/oasdiff/checker" - "github.com/tufin/oasdiff/checker/localizations" "github.com/tufin/oasdiff/diff" ) @@ -79,7 +78,7 @@ func getChangelog(flags *ChangelogFlags, stdout io.Writer, level checker.Level, } bcConfig := checker.GetAllChecks(flags.includeChecks, flags.deprecationDaysBeta, flags.deprecationDaysStable) - bcConfig.Localizer = *localizations.New(flags.lang, LangDefault) + bcConfig.Localize = checker.NewLocalizer(flags.lang, LangDefault) errs, returnErr := filterIgnored( checker.CheckBackwardCompatibilityUntilLevel(bcConfig, diffReport, operationsSources, level), @@ -128,8 +127,8 @@ func filterIgnored(errs checker.Changes, warnIgnoreFile string, errIgnoreFile st func getChangelogTitle(config checker.Config, errs checker.Changes) string { count := errs.GetLevelCount() - return fmt.Sprintf( - config.Localizer.Get("messages.total-changes"), + return config.Localize( + "total-changes", len(errs), count[checker.ERR], checker.ERR.PrettyString(), @@ -158,7 +157,7 @@ func outputChangelog(config checker.Config, format string, stdout io.Writer, err } for _, bcerr := range errs { - fmt.Fprintf(stdout, "%s\n\n", bcerr.PrettyErrorText(config.Localizer)) + fmt.Fprintf(stdout, "%s\n\n", bcerr.PrettyErrorText(config.Localize)) } default: return getErrUnsupportedBreakingChangesFormat(format)