Skip to content

Commit

Permalink
Fixing minor validation errors
Browse files Browse the repository at this point in the history
- Fixing description rule to allow references to define a description
- Fixing AutoRest logging output to avoid throwing NRE when an error is logged without an exception
- Changing the message that gets output for validation errors to make it more useful
  • Loading branch information
tbombach committed Jul 12, 2016
1 parent 2a491e8 commit e7bf312
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/AutoRest.Core/AutoRest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static void Generate(Settings settings)

if (messages.Any(entry => entry.Severity >= settings.ValidationLevel))
{
throw ErrorManager.CreateError(Resources.CodeGenerationError);
throw ErrorManager.CreateError(null, Resources.ErrorGeneratingClientModel, "Errors found during Swagger validation");
}
}
catch (Exception exception)
Expand Down
2 changes: 1 addition & 1 deletion src/core/AutoRest.Core/Logging/ErrorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public static CodeGenerationException CreateError(Exception exception, string me
}

var errors =
Logger.Entries.Where(e => e.Severity == LogEntrySeverity.Error).Select(e => e.Exception).ToList();
Logger.Entries.Where(e => e.Severity == LogEntrySeverity.Error).Select(e => e.Exception).Where(e => e != null).ToList();
Logger.Entries.Add(new LogEntry(LogEntrySeverity.Fatal, FormatMessageString(message, args))
{
Exception = exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class DescriptionRequired : TypedRule<SwaggerObject>
/// <param name="entity"></param>
/// <returns></returns>
public override bool IsValid(SwaggerObject entity)
=> entity == null || entity.Description != null || string.IsNullOrEmpty(entity.Reference);
=> entity == null || entity.Description != null || !string.IsNullOrEmpty(entity.Reference);

public override ValidationExceptionName Exception => ValidationExceptionName.DescriptionRequired;
}
Expand Down

0 comments on commit e7bf312

Please sign in to comment.