diff --git a/src/modeler/AutoRest.Swagger/Model/ServiceDefinition.cs b/src/modeler/AutoRest.Swagger/Model/ServiceDefinition.cs index df5f0c4c64..4559b1a782 100644 --- a/src/modeler/AutoRest.Swagger/Model/ServiceDefinition.cs +++ b/src/modeler/AutoRest.Swagger/Model/ServiceDefinition.cs @@ -94,6 +94,7 @@ public ServiceDefinition() /// /// Key is the object serviceTypeName and the value is swagger definition. + /// [Rule(typeof(BooleanPropertyNotRecommended))] [Rule(typeof(ResourceModelValidation))] [Rule(typeof(TrackedResourceValidation))] diff --git a/src/modeler/AutoRest.Swagger/Validation/BooleanPropertyNotRecommended.cs b/src/modeler/AutoRest.Swagger/Validation/BooleanPropertyNotRecommended.cs index 8be6e94195..10f1f32ae9 100644 --- a/src/modeler/AutoRest.Swagger/Validation/BooleanPropertyNotRecommended.cs +++ b/src/modeler/AutoRest.Swagger/Validation/BooleanPropertyNotRecommended.cs @@ -31,22 +31,20 @@ public class BooleanPropertyNotRecommended : TypedRule /// Operation Definition to validate - /// true if there are propeties of type boolean, false otherwise. + /// true if there are no propeties of type boolean, false otherwise. public override bool IsValid(Dictionary definitions, RuleContext context, out object[] formatParameters) { formatParameters = null; List booleanProperties = new List(); - foreach (string key in definitions.Keys) + foreach (KeyValuePair definition in definitions) { - Schema definitionSchema = definitions.GetValueOrNull(key); - if (definitionSchema.Properties != null) + if (definition.Value?.Properties != null) { - foreach (var property in definitionSchema.Properties) + foreach (KeyValuePair property in definition.Value.Properties) { if (property.Value.Type.ToString().ToLower().Equals("boolean")) { - booleanProperties.Add(key + "/" + property.Key); - + booleanProperties.Add(definition.Key + "/" + property.Key); } } }