diff --git a/checker/check-added-required-request-body.go b/checker/check-added-required-request-body.go index 198e48d2..7f44fe2c 100644 --- a/checker/check-added-required-request-body.go +++ b/checker/check-added-required-request-body.go @@ -7,9 +7,10 @@ import ( const ( AddedRequiredRequestBodyId = "added-required-request-body" + AddedOptionalRequestBodyId = "added-optional-request-body" ) -func AddedRequiredRequestBodyCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSourcesMap, config *Config) Changes { +func AddedRequestBodyCheck(diffReport *diff.Diff, operationsSources *diff.OperationsSourcesMap, config *Config) Changes { result := make(Changes, 0) if diffReport.PathsDiff == nil { return result @@ -22,12 +23,19 @@ func AddedRequiredRequestBodyCheck(diffReport *diff.Diff, operationsSources *dif if operationItem.RequestBodyDiff == nil { continue } - if operationItem.RequestBodyDiff.Added && - operationItem.Revision.RequestBody.Value.Required { + if operationItem.RequestBodyDiff.Added { + id := AddedOptionalRequestBodyId + logLevel := INFO + + if operationItem.Revision.RequestBody.Value.Required { + id = AddedRequiredRequestBodyId + logLevel = ERR + } + source := (*operationsSources)[operationItem.Revision] result = append(result, ApiChange{ - Id: AddedRequiredRequestBodyId, - Level: ERR, + Id: id, + Level: logLevel, Operation: operation, OperationId: operationItem.Revision.OperationID, Path: path, diff --git a/checker/localizations/localizations.go b/checker/localizations/localizations.go index 1caeda39..24406919 100644 --- a/checker/localizations/localizations.go +++ b/checker/localizations/localizations.go @@ -1,6 +1,6 @@ // Code generated by go-localize; DO NOT EDIT. // This file was generated by robots at -// 2024-01-28 10:36:11.0749058 +0200 IST m=+0.014169201 +// 2024-04-24 18:43:43.939071 +0300 IDT m=+0.005875554 package localizations @@ -12,6 +12,7 @@ import ( ) var localizations = map[string]string{ + "en.messages.added-optional-request-body": "added optional request body", "en.messages.added-required-request-body": "added required request body", "en.messages.added-required-request-body-description": "required request body added", "en.messages.api-deprecated-sunset-parse": "api sunset date %s can't be parsed for deprecated API: %v", @@ -527,6 +528,7 @@ var localizations = map[string]string{ "en.messages.unparseable-parameter-to-x-extensible-enum-description": "unparseable x-extensible-enum in revised request parameter", "en.messages.unparseable-property-from-x-extensible-enum-description": "unparseable x-extensible-enum in original request property", "en.messages.unparseable-property-to-x-extensible-enum-description": "unparseable x-extensible-enum in revised request property", + "ru.messages.added-optional-request-body": "добавлено необязательное тело запроса", "ru.messages.added-required-request-body": "добавлено обязательное тело запроса", "ru.messages.api-deprecated-sunset-parse": "API deprecated без валидно парсящейся %s даты sunset: %v", "ru.messages.api-global-security-added": "схема безопасности %s была добавлена к API", diff --git a/checker/localizations_src/en/messages.yaml b/checker/localizations_src/en/messages.yaml index cf754d28..31f4daa8 100644 --- a/checker/localizations_src/en/messages.yaml +++ b/checker/localizations_src/en/messages.yaml @@ -1,6 +1,7 @@ at: at in: in added-required-request-body: added required request body +added-optional-request-body: added optional request body request-parameter-removed: deleted the %s request parameter %s total-errors: "%d breaking changes: %d %s, %d %s\\n" total-changes: "%d changes: %d %s, %d %s, %d %s\\n" diff --git a/checker/localizations_src/ru/messages.yaml b/checker/localizations_src/ru/messages.yaml index be82c5ec..5da76ac2 100644 --- a/checker/localizations_src/ru/messages.yaml +++ b/checker/localizations_src/ru/messages.yaml @@ -1,6 +1,7 @@ at: в in: в added-required-request-body: добавлено обязательное тело запроса +added-optional-request-body: добавлено необязательное тело запроса request-parameter-removed: удалён %s параметр запроса %s total-errors: "%s критические изменения: %s %s, %s %s\\n" total-changes: "%s изменений: %s %s, %s %s, %s %s\\n" diff --git a/checker/rules.go b/checker/rules.go index 5fdef989..c9b767f0 100644 --- a/checker/rules.go +++ b/checker/rules.go @@ -58,7 +58,8 @@ func GetAllRules() []BackwardCompatibilityRule { newBackwardCompatibilityRule(APISunsetDeletedId, ERR, true, APISunsetChangedCheck), newBackwardCompatibilityRule(APISunsetDateChangedTooSmallId, ERR, true, APISunsetChangedCheck), // AddedRequiredRequestBodyCheck - newBackwardCompatibilityRule(AddedRequiredRequestBodyId, ERR, true, AddedRequiredRequestBodyCheck), + newBackwardCompatibilityRule(AddedRequiredRequestBodyId, ERR, true, AddedRequestBodyCheck), + newBackwardCompatibilityRule(AddedOptionalRequestBodyId, INFO, true, AddedRequestBodyCheck), // NewRequestNonPathDefaultParameterCheck newBackwardCompatibilityRule(NewRequiredRequestDefaultParameterToExistingPathId, ERR, true, NewRequestNonPathDefaultParameterCheck), newBackwardCompatibilityRule(NewOptionalRequestDefaultParameterToExistingPathId, INFO, true, NewRequestNonPathDefaultParameterCheck),