From 2fc0d40f5d9bdab343b1bbe096a85fafc60dc157 Mon Sep 17 00:00:00 2001 From: Jan Melcher Date: Thu, 12 Sep 2024 17:47:25 +0200 Subject: [PATCH] fix: do not make "Field is missing" suppressable on type level It suppressed all missing fields, not just the one, which does not make sense. --- src/model/compatibility-check/check-object-type.ts | 8 ++++---- src/model/validation/suppress/message-codes.ts | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/model/compatibility-check/check-object-type.ts b/src/model/compatibility-check/check-object-type.ts index a256f1f7..04f43697 100644 --- a/src/model/compatibility-check/check-object-type.ts +++ b/src/model/compatibility-check/check-object-type.ts @@ -48,14 +48,14 @@ export function checkObjectType( ); } + // cannot easily make this suppressable - if we would accept a @suppress on the type, + // that would supress all missing fields, not just this one context.addMessage( - ValidationMessage.suppressableCompatibilityIssue( - 'MISSING_FIELD', + ValidationMessage.nonSuppressableCompatibilityIssue( `Field "${baselineType.name}.${ baselineField.name }" is missing${getRequiredBySuffix(baselineField)}.`, - typeToCheck.astNode, - { location: typeToCheck.nameASTNode, quickFixes }, + typeToCheck.nameASTNode ?? typeToCheck.astNode, ), ); continue; diff --git a/src/model/validation/suppress/message-codes.ts b/src/model/validation/suppress/message-codes.ts index c5f97303..a8e80dfa 100644 --- a/src/model/validation/suppress/message-codes.ts +++ b/src/model/validation/suppress/message-codes.ts @@ -47,7 +47,6 @@ export const COMPATIBILITY_ISSUE_CODES = { DEFAULT_VALUE: 'Missing, superfluous or diverging @defaultValue', MISSING_ENUM_VALUE: 'An enum declaration is missing a value', FIELD_TYPE: 'A field has the wrong type', - MISSING_FIELD: 'An object type declaration is missing a field', KEY_FIELD: 'Missing or superfluous @key', REFERENCE: 'Missing, superfluous or diverging @reference', RELATION: 'Missing, superfluous or diverging @relation',