Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/modeler/AutoRest.Swagger/Model/ServiceDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public ServiceDefinition()

/// <summary>
/// Key is the object serviceTypeName and the value is swagger definition.
/// <summary>
[Rule(typeof(BooleanPropertyNotRecommended))]
[Rule(typeof(ResourceModelValidation))]
[Rule(typeof(TrackedResourceValidation))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,20 @@ public class BooleanPropertyNotRecommended : TypedRule<Dictionary<string, Schema
/// Validates whether properties of type boolean exist.
/// </summary>
/// <param name="definitions">Operation Definition to validate</param>
/// <returns>true if there are propeties of type boolean, false otherwise.</returns>
/// <returns>true if there are no propeties of type boolean, false otherwise.</returns>
public override bool IsValid(Dictionary<string, Schema> definitions, RuleContext context, out object[] formatParameters)
{
formatParameters = null;
List<string> booleanProperties = new List<string>();
foreach (string key in definitions.Keys)
foreach (KeyValuePair<string, Schema> 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<string, Schema> property in definition.Value.Properties)
{
if (property.Value.Type.ToString().ToLower().Equals("boolean"))
{
booleanProperties.Add(key + "/" + property.Key);

booleanProperties.Add(definition.Key + "/" + property.Key);
}
}
}
Expand Down