private static int Main(string[] args) { Settings settings = Settings.GetInstance(args); if (settings.ShowHelp) { Console.WriteLine(HelpGenerator.Generate(Resources.HelpTextTemplate, settings)); return(0); } try { settings.Validate(); } catch (Exception ex) { Console.WriteLine(ex.Message); return(1); } SwaggerModeler modeler = new SwaggerModeler(); string swaggerPrev = File.ReadAllText(settings.OldSpec); string swaggerNew = File.ReadAllText(settings.NewSpec); var messages = modeler.Compare(swaggerPrev, swaggerNew, settings); foreach (var msg in messages) { Console.WriteLine(settings.JsonValidationMessages ? msg.GetValidationMessagesAsJson() : msg.ToString()); } return(0); }
/// <summary> /// Helper method -- load two Swagger documents and invoke the comparison logic. /// </summary> /// <param name="input">The name of the swagger document file. The file name must be the same in both the 'modified' and 'original' folder.</param> /// <returns>A list of messages from the comparison logic.</returns> private IEnumerable <ComparisonMessage> CompareSwagger(string input) { var modeler = new SwaggerModeler(); var baseDir = Directory.GetParent(typeof(SwaggerModelerCompareTests).GetTypeInfo().Assembly.Location.ToString()).ToString(); return(modeler.Compare( File.ReadAllText(Path.Combine(baseDir, "Resource", "Swagger", "old", input)), File.ReadAllText(Path.Combine(baseDir, "Resource", "Swagger", "new", input)) )); }
/// <summary> /// Helper method -- load two Swagger documents and invoke the comparison logic. /// </summary> /// <param name="input">The name of the swagger document file. The file name must be the same in both the 'modified' and 'original' folder.</param> /// <returns>A list of messages from the comparison logic.</returns> private static IEnumerable <ComparisonMessage> CompareSwagger(string input) { var modeler = new SwaggerModeler(); var baseDir = Directory.GetParent(typeof(SwaggerModelerCompareTests).GetTypeInfo().Assembly.Location.ToString()).ToString(); var oldFileName = Path.Combine(baseDir, "Resource", "Swagger", "old", input); var newFileName = Path.Combine(baseDir, "Resource", "Swagger", "new", input); var result = modeler.Compare( Path.Combine("old", input), File.ReadAllText(oldFileName), Path.Combine("new", input), File.ReadAllText(newFileName) ); ValidateMessages(result); return(result); }
/// <summary> /// Helper method -- load two Swagger documents and invoke the comparison logic. /// </summary> /// <param name="input">The name of the swagger document file. The file name must be the same in both the 'modified' and 'original' folder.</param> /// <returns>A list of messages from the comparison logic.</returns> private IEnumerable <ComparisonMessage> CompareSwagger(string input) { var settings = new Settings { Namespace = "Test", Input = Path.Combine("Swagger", "Comparison", "Modified", input), Previous = Path.Combine("Swagger", "Comparison", "Original", input) }; var modeler = new SwaggerModeler(settings); IEnumerable <ComparisonMessage> messages = modeler.Compare(); // remove debug-level messages messages = messages.Where(each => each.Severity > LogEntrySeverity.Debug); return(messages); }
/// <summary> /// Helper method -- load two Swagger documents and invoke the comparison logic. /// </summary> /// <param name="input">The name of the swagger document file. The file name must be the same in both the 'modified' and 'original' folder.</param> /// <returns>A list of messages from the comparison logic.</returns> private IEnumerable <ComparisonMessage> CompareSwagger(string input) { using (NewContext) { var settings = new Settings { Namespace = "Test", Input = Path.Combine(Core.Utilities.Extensions.CodeBaseDirectory, "Resource", "Swagger", "Comparison", "Modified", input), Previous = Path.Combine(Core.Utilities.Extensions.CodeBaseDirectory, "Resource", "Swagger", "Comparison", "Original", input) }; var modeler = new SwaggerModeler(); var messages = modeler.Compare().OfType <ComparisonMessage>(); // remove debug-level messages messages = messages.Where(each => each.Severity > Category.Debug); return(messages); } }
/// <summary> /// Helper method -- load two Swagger documents and invoke the comparison logic. /// </summary> /// <param name="input">The name of the swagger document file. The file name must be the same in both the 'modified' and 'original' folder.</param> /// <returns>A list of messages from the comparison logic.</returns> private IEnumerable<ComparisonMessage> CompareSwagger(string input) { using (NewContext) { var settings = new Settings { Namespace = "Test", Input = Path.Combine("Swagger", "Comparison", "Modified", input), Previous = Path.Combine("Swagger", "Comparison", "Original", input) }; var modeler = new SwaggerModeler(); IEnumerable<ComparisonMessage> messages = modeler.Compare(); // remove debug-level messages messages = messages.Where(each => each.Severity > LogEntrySeverity.Debug); return messages; } }
private static int Main(string[] args) { var settings = Settings.GetInstance(args); if (settings.ShowHelp) { Console.WriteLine(HelpGenerator.Generate(Resources.HelpTextTemplate, settings)); return(0); } try { settings.Validate(); } catch (Exception ex) { Console.WriteLine(ex.Message); return(1); } var modeler = new SwaggerModeler(); var swaggerPrev = File.ReadAllText(settings.OldSpec); var swaggerNew = File.ReadAllText(settings.NewSpec); var messages = modeler.Compare( settings.OldSpec, swaggerPrev, settings.NewSpec, swaggerNew, settings ); Console.WriteLine("["); Console.WriteLine(string.Join(",\n", messages.Select(v => v.GetValidationMessagesAsJson()))); Console.WriteLine("]"); return(0); }