From fdbee8ffda661bec742bac157aac6dc4e0eb4384 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 19 Jan 2022 07:11:00 +0300 Subject: [PATCH 01/67] Update input parameter description --- src/Microsoft.OpenApi.Hidi/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 533878a0d..812b7d58b 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -23,7 +23,7 @@ static async Task Main(string[] args) var transformCommand = new Command("transform") { - new Option("--input", "Input OpenAPI description file path or URL", typeof(string) ), + new Option("--input", "Input OpenAPI description, JSON or CSDL file path or URL", typeof(string) ), new Option("--output","Output OpenAPI description file", typeof(FileInfo), arity: ArgumentArity.ZeroOrOne), new Option("--version", "OpenAPI specification version", typeof(OpenApiSpecVersion)), new Option("--format", "File format",typeof(OpenApiFormat) ), From 7f88a35b4db1cf4d75a3cfc7f93c3eec99293d06 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 19 Jan 2022 07:12:54 +0300 Subject: [PATCH 02/67] Add OData conversion libraries --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index b13c9dc18..ea9ee08d1 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -10,6 +10,8 @@ + + From e0f0ed66f9299abfee8e1f7269b4af4c517ff7b4 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 19 Jan 2022 07:13:06 +0300 Subject: [PATCH 03/67] Add necessary usings --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 486666568..5e02e8fc4 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -7,8 +7,12 @@ using System.Net; using System.Net.Http; using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; +using Microsoft.OData.Edm.Csdl; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.OData; using Microsoft.OpenApi.Readers; using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Validations; From c2ae2dd0ab7b3f858ec9b8e11413027b61937f00 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 19 Jan 2022 07:13:58 +0300 Subject: [PATCH 04/67] Add method for CSDL to OpenAPI conversion --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 43 ++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 5e02e8fc4..e4b7c90cc 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -106,6 +106,49 @@ public static void ProcessOpenApiDocument( textWriter.Flush(); } + /// + /// Converts CSDL to OpenAPI + /// + /// The CSDL stream. + /// An OpenAPI document. + public static OpenApiDocument ConvertCsdlToOpenApi(Stream csdl) + { + using var reader = new StreamReader(csdl); + var csdlText = reader.ReadToEndAsync().GetAwaiter().GetResult(); + var edmModel = CsdlReader.Parse(XElement.Parse(csdlText).CreateReader()); + + var settings = new OpenApiConvertSettings() + { + EnableKeyAsSegment = true, + EnableOperationId = true, + PrefixEntityTypeNameBeforeKey = true, + TagDepth = 2, + EnablePagination = true, + EnableDiscriminatorValue = false, + EnableDerivedTypesReferencesForRequestBody = false, + EnableDerivedTypesReferencesForResponses = false, + ShowRootPath = true, + ShowLinks = true + }; + OpenApiDocument document = edmModel.ConvertToOpenApi(settings); + + document = FixReferences(document); + + return document; + } + + public static OpenApiDocument FixReferences(OpenApiDocument document) + { + // This method is only needed because the output of ConvertToOpenApi isn't quite a valid OpenApiDocument instance. + // So we write it out, and read it back in again to fix it up. + + var sb = new StringBuilder(); + document.SerializeAsV3(new OpenApiYamlWriter(new StringWriter(sb))); + var doc = new OpenApiStringReader().Read(sb.ToString(), out _); + + return doc; + } + private static Stream GetStream(string input) { Stream stream; From 07169a4dac80ed7f6bc0f78a7089bcba38d552c2 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 20 Jan 2022 18:45:57 +0300 Subject: [PATCH 05/67] Check input file for .xml extension --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index e4b7c90cc..bb66f4158 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -46,6 +46,13 @@ public static void ProcessOpenApiDocument( } var stream = GetStream(input); + OpenApiDocument document; + + if (input.Contains("xml")) + { + document = ConvertCsdlToOpenApi(stream); + } + var result = new OpenApiStreamReader(new OpenApiReaderSettings { ReferenceResolution = resolveExternal ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, @@ -53,9 +60,8 @@ public static void ProcessOpenApiDocument( } ).ReadAsync(stream).GetAwaiter().GetResult(); - OpenApiDocument document; document = result.OpenApiDocument; - + // Check if filter options are provided, then execute if (!string.IsNullOrEmpty(filterByOperationIds) && !string.IsNullOrEmpty(filterByTags)) { From 581023c6d991ee12ffffe93f31cb9a16e623eeca Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 25 Jan 2022 09:57:38 +0300 Subject: [PATCH 06/67] Clean up code --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 23 ++++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 17920ea6d..3fbcde7fa 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -9,7 +9,6 @@ using System.Net.Http; using System.Text; using System.Text.Json; -using System.Threading.Tasks; using System.Xml.Linq; using Microsoft.OData.Edm.Csdl; using Microsoft.OpenApi.Extensions; @@ -49,21 +48,27 @@ public static void ProcessOpenApiDocument( } var stream = GetStream(input); + + ReadResult result = null; + OpenApiDocument document; - if (input.Contains("xml")) + if (input.Contains(".xml")) { document = ConvertCsdlToOpenApi(stream); } - - var result = new OpenApiStreamReader(new OpenApiReaderSettings + else { - ReferenceResolution = resolveExternal ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, - RuleSet = ValidationRuleSet.GetDefaultRuleSet() - } - ).ReadAsync(stream).GetAwaiter().GetResult(); + result = new OpenApiStreamReader(new OpenApiReaderSettings + { + ReferenceResolution = resolveExternal ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, + RuleSet = ValidationRuleSet.GetDefaultRuleSet() + } + ).ReadAsync(stream).GetAwaiter().GetResult(); - document = result.OpenApiDocument; + document = result.OpenApiDocument; + } + Func predicate; // Check if filter options are provided, then execute From 7606916c19f1b1a9ca52d6e9b9834fcf53186c7a Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 25 Jan 2022 16:25:05 +0300 Subject: [PATCH 07/67] Refactor code --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 30 ++++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 3fbcde7fa..25faa1b28 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -67,6 +67,20 @@ public static void ProcessOpenApiDocument( ).ReadAsync(stream).GetAwaiter().GetResult(); document = result.OpenApiDocument; + + var context = result.OpenApiDiagnostic; + + if (context.Errors.Count > 0) + { + var errorReport = new StringBuilder(); + + foreach (var error in context.Errors) + { + errorReport.AppendLine(error.ToString()); + } + + throw new ArgumentException(string.Join(Environment.NewLine, context.Errors.Select(e => e.Message).ToArray())); + } } Func predicate; @@ -94,21 +108,7 @@ public static void ProcessOpenApiDocument( predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source:document); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } - - var context = result.OpenApiDiagnostic; - - if (context.Errors.Count > 0) - { - var errorReport = new StringBuilder(); - - foreach (var error in context.Errors) - { - errorReport.AppendLine(error.ToString()); - } - - throw new ArgumentException(string.Join(Environment.NewLine, context.Errors.Select(e => e.Message).ToArray())); - } - + using var outputStream = output?.Create(); var textWriter = outputStream != null ? new StreamWriter(outputStream) : Console.Out; From cb8ef3a530dd1516f2fd15e3c6ca4251dd3b8fe2 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 26 Jan 2022 10:37:03 +0300 Subject: [PATCH 08/67] Add check for .csdl files --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 25faa1b28..782f16e88 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -53,7 +53,7 @@ public static void ProcessOpenApiDocument( OpenApiDocument document; - if (input.Contains(".xml")) + if (input.Contains(".xml") || input.Contains(".csdl")) { document = ConvertCsdlToOpenApi(stream); } From 73339e10f04af0794ccf3f6728acc1e0aa09e1f0 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 26 Jan 2022 10:37:54 +0300 Subject: [PATCH 09/67] Add a sample csdl file for testing and copy to output directory --- .../Microsoft.OpenApi.Tests.csproj | 3 +++ .../UtilityFiles/Todo.xml | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 test/Microsoft.OpenApi.Tests/UtilityFiles/Todo.xml diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 56bdd0983..3e8295902 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -43,5 +43,8 @@ Always + + Always + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/UtilityFiles/Todo.xml b/test/Microsoft.OpenApi.Tests/UtilityFiles/Todo.xml new file mode 100644 index 000000000..b3b07debf --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/UtilityFiles/Todo.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + From 7ec682b656eda14f99a56d499f78e981ce9a218a Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 26 Jan 2022 10:38:17 +0300 Subject: [PATCH 10/67] Add csdl conversion tests --- .../Services/OpenApiCSDLConversionTests.cs | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 test/Microsoft.OpenApi.Tests/Services/OpenApiCSDLConversionTests.cs diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiCSDLConversionTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiCSDLConversionTests.cs new file mode 100644 index 000000000..969fe325c --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiCSDLConversionTests.cs @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System; +using System.IO; +using Microsoft.OpenApi.Hidi; +using Microsoft.OpenApi.Services; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Services +{ + public class OpenApiCSDLConversionTests + { + [Fact] + public void ReturnConvertedCSDLFile() + { + // Arrange + var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\Todo.xml"); + var fileInput = new FileInfo(filePath); + var csdlStream = fileInput.OpenRead(); + + // Act + var openApiDoc = OpenApiService.ConvertCsdlToOpenApi(csdlStream); + var expectedPathCount = 5; + + // Assert + Assert.NotNull(openApiDoc); + Assert.NotEmpty(openApiDoc.Paths); + Assert.Equal(openApiDoc.Paths.Count, expectedPathCount); + } + + [Theory] + [InlineData("Todos.Todo.UpdateTodo",null, 1)] + [InlineData("Todos.Todo.ListTodo",null, 1)] + [InlineData(null, "Todos.Todo", 4)] + public void ReturnFilteredOpenApiDocumentBasedOnOperationIdsAndInputCsdlDocument(string operationIds, string tags, int expectedPathCount) + { + // Arrange + var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\Todo.xml"); + var fileInput = new FileInfo(filePath); + var csdlStream = fileInput.OpenRead(); + + // Act + var openApiDoc = OpenApiService.ConvertCsdlToOpenApi(csdlStream); + var predicate = OpenApiFilterService.CreatePredicate(operationIds, tags); + var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(openApiDoc, predicate); + + // Assert + Assert.NotNull(subsetOpenApiDocument); + Assert.NotEmpty(subsetOpenApiDocument.Paths); + Assert.Equal(expectedPathCount, subsetOpenApiDocument.Paths.Count); + } + } +} From b13c3adbc6b4907cbc79313b1d7d3d329ce6c9fd Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 26 Jan 2022 10:51:27 +0300 Subject: [PATCH 11/67] Add xml documentation --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 782f16e88..8dcb0d22d 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -162,6 +162,11 @@ public static OpenApiDocument ConvertCsdlToOpenApi(Stream csdl) return document; } + /// + /// Fixes the references in the resulting OpenApiDocument. + /// + /// The converted OpenApiDocument. + /// A valid OpenApiDocument instance. public static OpenApiDocument FixReferences(OpenApiDocument document) { // This method is only needed because the output of ConvertToOpenApi isn't quite a valid OpenApiDocument instance. From 66c06b6d4c4061629eb06751a4b5b184e9d7e9b9 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 27 Jan 2022 19:14:09 +0300 Subject: [PATCH 12/67] Add --csdl input param for converting csdl files --- src/Microsoft.OpenApi.Hidi/Program.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index e5865d464..77781a33f 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -19,6 +19,9 @@ static async Task Main(string[] args) var descriptionOption = new Option("--openapi", "Input OpenAPI description file path or URL", typeof(string)); descriptionOption.AddAlias("-d"); + var csdlOption = new Option("--csdl", "Input CSDL file path or URL", typeof(string)); + csdlOption.AddAlias("-cs"); + var outputOption = new Option("--output", "The output directory path for the generated file.", typeof(FileInfo), () => "./output", arity: ArgumentArity.ZeroOrOne); outputOption.AddAlias("-o"); @@ -52,6 +55,7 @@ static async Task Main(string[] args) var transformCommand = new Command("transform") { descriptionOption, + csdlOption, outputOption, versionOption, formatOption, @@ -61,7 +65,7 @@ static async Task Main(string[] args) filterByTagsOption, filterByCollectionOption }; - transformCommand.Handler = CommandHandler.Create( + transformCommand.Handler = CommandHandler.Create( OpenApiService.ProcessOpenApiDocument); rootCommand.Add(transformCommand); From 1b40298b5db0fb91e266a95afaf7e37d6cc21fbe Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 27 Jan 2022 19:14:29 +0300 Subject: [PATCH 13/67] Refactor code --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 39 +++++++++++--------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 22f02cf57..653be79e4 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -25,6 +25,7 @@ public static class OpenApiService { public static void ProcessOpenApiDocument( string openapi, + string csdl, FileInfo output, OpenApiSpecVersion? version, OpenApiFormat? format, @@ -34,9 +35,9 @@ public static void ProcessOpenApiDocument( bool inline, bool resolveexternal) { - if (string.IsNullOrEmpty(openapi)) + if (string.IsNullOrEmpty(openapi) && string.IsNullOrEmpty(csdl)) { - throw new ArgumentNullException(nameof(openapi)); + throw new ArgumentNullException("Please input a file path"); } if(output == null) { @@ -47,21 +48,25 @@ public static void ProcessOpenApiDocument( throw new IOException("The file you're writing to already exists. Please input a new output path."); } - var stream = GetStream(input); - - ReadResult result = null; - + Stream stream; OpenApiDocument document; + OpenApiFormat openApiFormat; - if (input.Contains(".xml") || input.Contains(".csdl")) + if (!string.IsNullOrEmpty(csdl)) { - document = ConvertCsdlToOpenApi(stream); + // Default to yaml during csdl to OpenApi conversion + openApiFormat = format ?? GetOpenApiFormat(csdl); + + stream = GetStream(csdl); + document = ConvertCsdlToOpenApi(stream); } else { - result = new OpenApiStreamReader(new OpenApiReaderSettings + stream = GetStream(openapi); + + var result = new OpenApiStreamReader(new OpenApiReaderSettings { - ReferenceResolution = resolveExternal ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, + ReferenceResolution = resolveexternal ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, RuleSet = ValidationRuleSet.GetDefaultRuleSet() } ).ReadAsync(stream).GetAwaiter().GetResult(); @@ -81,8 +86,11 @@ public static void ProcessOpenApiDocument( throw new ArgumentException(string.Join(Environment.NewLine, context.Errors.Select(e => e.Message).ToArray())); } + + openApiFormat = format ?? GetOpenApiFormat(openapi); + version ??= result.OpenApiDiagnostic.SpecificationVersion; } - + Func predicate; // Check if filter options are provided, then execute @@ -100,7 +108,6 @@ public static void ProcessOpenApiDocument( predicate = OpenApiFilterService.CreatePredicate(tags: filterbytags); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } - if (!string.IsNullOrEmpty(filterbycollection)) { var fileStream = GetStream(filterbycollection); @@ -118,15 +125,13 @@ public static void ProcessOpenApiDocument( ReferenceInline = inline ? ReferenceInlineSetting.InlineLocalReferences : ReferenceInlineSetting.DoNotInlineReferences }; - var openApiFormat = format ?? GetOpenApiFormat(openapi); - var openApiVersion = version ?? result.OpenApiDiagnostic.SpecificationVersion; IOpenApiWriter writer = openApiFormat switch { OpenApiFormat.Json => new OpenApiJsonWriter(textWriter, settings), OpenApiFormat.Yaml => new OpenApiYamlWriter(textWriter, settings), _ => throw new ArgumentException("Unknown format"), }; - document.Serialize(writer, openApiVersion); + document.Serialize(writer, (OpenApiSpecVersion)version); textWriter.Flush(); } @@ -139,7 +144,7 @@ public static void ProcessOpenApiDocument( public static OpenApiDocument ConvertCsdlToOpenApi(Stream csdl) { using var reader = new StreamReader(csdl); - var csdlText = reader.ReadToEndAsync().GetAwaiter().GetResult(); + var csdlText = reader.ReadToEndAsync().GetAwaiter().GetResult(); var edmModel = CsdlReader.Parse(XElement.Parse(csdlText).CreateReader()); var settings = new OpenApiConvertSettings() @@ -179,7 +184,7 @@ public static OpenApiDocument FixReferences(OpenApiDocument document) return doc; } - private static Stream GetStream(string input) + private static Stream GetStream(string openapi) { Stream stream; if (openapi.StartsWith("http")) From ef7640ffc351fca80ddde7a77421412fec590ae7 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 27 Jan 2022 19:17:02 +0300 Subject: [PATCH 14/67] Rename test file --- .../{OpenApiCSDLConversionTests.cs => OpenApiServiceTests.cs} | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename test/Microsoft.OpenApi.Tests/Services/{OpenApiCSDLConversionTests.cs => OpenApiServiceTests.cs} (90%) diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiCSDLConversionTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiServiceTests.cs similarity index 90% rename from test/Microsoft.OpenApi.Tests/Services/OpenApiCSDLConversionTests.cs rename to test/Microsoft.OpenApi.Tests/Services/OpenApiServiceTests.cs index 969fe325c..1b94a3557 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiCSDLConversionTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiServiceTests.cs @@ -9,7 +9,7 @@ namespace Microsoft.OpenApi.Tests.Services { - public class OpenApiCSDLConversionTests + public class OpenApiServiceTests { [Fact] public void ReturnConvertedCSDLFile() @@ -33,7 +33,7 @@ public void ReturnConvertedCSDLFile() [InlineData("Todos.Todo.UpdateTodo",null, 1)] [InlineData("Todos.Todo.ListTodo",null, 1)] [InlineData(null, "Todos.Todo", 4)] - public void ReturnFilteredOpenApiDocumentBasedOnOperationIdsAndInputCsdlDocument(string operationIds, string tags, int expectedPathCount) + public void ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocument(string operationIds, string tags, int expectedPathCount) { // Arrange var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\Todo.xml"); From 51e85a7a24c446659faf4221130f7eb403b6c898 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 27 Jan 2022 19:26:46 +0300 Subject: [PATCH 15/67] Refactor param to be more implicit --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 653be79e4..3013da5e9 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -184,10 +184,10 @@ public static OpenApiDocument FixReferences(OpenApiDocument document) return doc; } - private static Stream GetStream(string openapi) + private static Stream GetStream(string input) { Stream stream; - if (openapi.StartsWith("http")) + if (input.StartsWith("http")) { var httpClient = new HttpClient(new HttpClientHandler() { @@ -196,11 +196,11 @@ private static Stream GetStream(string openapi) { DefaultRequestVersion = HttpVersion.Version20 }; - stream = httpClient.GetStreamAsync(openapi).Result; + stream = httpClient.GetStreamAsync(input).Result; } else { - var fileInput = new FileInfo(openapi); + var fileInput = new FileInfo(input); stream = fileInput.OpenRead(); } From 5550f01d766013209f1ac8a68468a5ad3c9be224 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 3 Feb 2022 17:04:34 +0300 Subject: [PATCH 16/67] Clean up code --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 10 +++++----- src/Microsoft.OpenApi.Hidi/Program.cs | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 19a4f28c5..5b0e5d15b 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -83,21 +83,21 @@ string filterbycollection Stream stream; OpenApiDocument document; OpenApiFormat openApiFormat; + var stopwatch = new Stopwatch(); if (!string.IsNullOrEmpty(csdl)) { // Default to yaml during csdl to OpenApi conversion - openApiFormat = format ?? GetOpenApiFormat(csdl); + openApiFormat = format ?? GetOpenApiFormat(csdl, logger); - stream = GetStream(csdl); + stream = await GetStream(csdl, logger); document = ConvertCsdlToOpenApi(stream); } else { - stream = GetStream(openapi, logger); + stream = await GetStream(openapi, logger); // Parsing OpenAPI file - var stopwatch = new Stopwatch(); stopwatch.Start(); logger.LogTrace("Parsing OpenApi file"); var result = new OpenApiStreamReader(new OpenApiReaderSettings @@ -126,7 +126,7 @@ string filterbycollection logger.LogTrace("{timestamp}ms: Parsed OpenApi successfully. {count} paths found.", stopwatch.ElapsedMilliseconds, document.Paths.Count); } - openApiFormat = format ?? GetOpenApiFormat(openapi); + openApiFormat = format ?? GetOpenApiFormat(openapi, logger); version ??= result.OpenApiDiagnostic.SpecificationVersion; } diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index df8d26fa1..95e6f63f2 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -19,7 +19,7 @@ static async Task Main(string[] args) var descriptionOption = new Option("--openapi", "Input OpenAPI description file path or URL"); descriptionOption.AddAlias("-d"); - var csdlOption = new Option("--csdl", "Input CSDL file path or URL", typeof(string)); + var csdlOption = new Option("--csdl", "Input CSDL file path or URL"); csdlOption.AddAlias("-cs"); var outputOption = new Option("--output", () => new FileInfo("./output"), "The output directory path for the generated file.") { Arity = ArgumentArity.ZeroOrOne }; @@ -72,8 +72,8 @@ static async Task Main(string[] args) resolveExternalOption, }; - transformCommand.SetHandler ( - OpenApiService.ProcessOpenApiDocument, descriptionOption, outputOption, versionOption, formatOption, logLevelOption, inlineOption, resolveExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); + transformCommand.SetHandler ( + OpenApiService.ProcessOpenApiDocument, descriptionOption, csdlOption, outputOption, versionOption, formatOption, logLevelOption, inlineOption, resolveExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); rootCommand.Add(transformCommand); rootCommand.Add(validateCommand); From b8d0d2b42fc69b3e615c1166ea04eaf5191db0ab Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 4 Feb 2022 10:25:41 +0300 Subject: [PATCH 17/67] Default to V3 of OpenApi during document serialization --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 5b0e5d15b..f10a6f8ac 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -87,8 +87,9 @@ string filterbycollection if (!string.IsNullOrEmpty(csdl)) { - // Default to yaml during csdl to OpenApi conversion + // Default to yaml and OpenApiVersion 3 during csdl to OpenApi conversion openApiFormat = format ?? GetOpenApiFormat(csdl, logger); + version ??= OpenApiSpecVersion.OpenApi3_0; stream = await GetStream(csdl, logger); document = ConvertCsdlToOpenApi(stream); From 385e5af9872c70cab4dfb056b97572dc8c9b0fc6 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 4 Feb 2022 10:26:00 +0300 Subject: [PATCH 18/67] Clean up --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index f10a6f8ac..964329aaf 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -356,10 +356,10 @@ internal static async void ValidateOpenApiDocument(string openapi, LogLevel logl Console.WriteLine(statsVisitor.GetStatisticsReport()); } - private static OpenApiFormat GetOpenApiFormat(string openapi, ILogger logger) + private static OpenApiFormat GetOpenApiFormat(string input, ILogger logger) { logger.LogTrace("Getting the OpenApi format"); - return !openapi.StartsWith("http") && Path.GetExtension(openapi) == ".json" ? OpenApiFormat.Json : OpenApiFormat.Yaml; + return !input.StartsWith("http") && Path.GetExtension(input) == ".json" ? OpenApiFormat.Json : OpenApiFormat.Yaml; } private static ILogger ConfigureLoggerInstance(LogLevel loglevel) From 53c4e2c225de1b0d4fc3cb59e3025784ba147ea7 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 7 Feb 2022 10:00:35 +0300 Subject: [PATCH 19/67] Update package version --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 3e2b209b4..4b3054786 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -17,7 +17,7 @@ - + From 8683e372ac7ff8402f2b776ed6d13e4491e59423 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 8 Feb 2022 14:50:08 +0300 Subject: [PATCH 20/67] Catch any OpenApiExceptions thrown during parsing and continue processing of schema components --- .../V3/OpenApiV3VersionService.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs index 2663b6a3b..3d4091b95 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -88,7 +88,14 @@ public OpenApiReference ConvertToOpenApiReference( if (reference.StartsWith("#")) { // "$ref": "#/components/schemas/Pet" - return ParseLocalReference(segments[1]); + try + { + return ParseLocalReference(segments[1]); + } + catch (OpenApiException) + { + return null; + } } // Where fragments point into a non-OpenAPI document, the id will be the complete fragment identifier string id = segments[1]; From 36a11bb662d1f9ad4a2bfa66d40f98662551c817 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 8 Feb 2022 15:00:21 +0300 Subject: [PATCH 21/67] Add package icon and description --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index bd22e6361..70a39df3a 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -5,6 +5,7 @@ netcoreapp3.1 9.0 true + http://go.microsoft.com/fwlink/?LinkID=288890 https://github.com/Microsoft/OpenAPI.NET MIT true @@ -15,6 +16,7 @@ hidi ./../../artifacts 0.5.0-preview4 + OpenAPI.NET CLI tool for slicing OpenAPI documents © Microsoft Corporation. All rights reserved. OpenAPI .NET https://github.com/Microsoft/OpenAPI.NET From 409247226c431db497ac86f7039810ee00785918 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Feb 2022 03:38:44 +0000 Subject: [PATCH 22/67] Bump Verify from 15.2.1 to 16.1.1 Bumps [Verify](https://github.com/VerifyTests/Verify) from 15.2.1 to 16.1.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/commits/16.1.1) --- updated-dependencies: - dependency-name: Verify dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 695d4ef23..244afbd39 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -20,7 +20,7 @@ - + From 18abdedd1703a938bdd36226f129f97f30b50c95 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Feb 2022 03:54:11 +0000 Subject: [PATCH 23/67] Bump System.Text.Json from 6.0.1 to 6.0.2 Bumps [System.Text.Json](https://github.com/dotnet/runtime) from 6.0.1 to 6.0.2. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v6.0.1...v6.0.2) --- updated-dependencies: - dependency-name: System.Text.Json dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 7279e56db..328e374b5 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -38,7 +38,7 @@ - + From 54bdbbea15a982ede1617d60784370202d5c99ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 10 Feb 2022 04:05:52 +0000 Subject: [PATCH 24/67] Bump Verify.Xunit from 14.14.1 to 16.1.1 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 14.14.1 to 16.1.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/14.14.1...16.1.1) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 244afbd39..8bedf8388 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -21,7 +21,7 @@ - + all From 9f128dc28159df0f50d9065b911b6ffdcb3d0b45 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sat, 12 Feb 2022 15:58:50 -0500 Subject: [PATCH 25/67] Fixed ValidateDocument method in hidi --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 70a39df3a..a4cb0aa1c 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net5.0 9.0 true http://go.microsoft.com/fwlink/?LinkID=288890 diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 964329aaf..d7a4f4298 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -251,13 +251,13 @@ private static async Task GetStream(string input, ILogger logger) { try { - using var httpClientHandler = new HttpClientHandler() + var httpClientHandler = new HttpClientHandler() { SslProtocols = System.Security.Authentication.SslProtocols.Tls12, }; using var httpClient = new HttpClient(httpClientHandler) { - DefaultRequestVersion = HttpVersion.Version20 + DefaultRequestVersion = HttpVersion.Version20 }; stream = await httpClient.GetStreamAsync(input); } @@ -323,7 +323,7 @@ public static Dictionary> ParseJsonCollectionFile(Stream st return requestUrls; } - internal static async void ValidateOpenApiDocument(string openapi, LogLevel loglevel) + internal static async Task ValidateOpenApiDocument(string openapi, LogLevel loglevel) { if (string.IsNullOrEmpty(openapi)) { From b27416226b94ea3a44c589e4ec81234ae43cfa91 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sat, 12 Feb 2022 17:25:36 -0500 Subject: [PATCH 26/67] Fixed validate for Path Parameters so it does not fail for components --- .../Validations/Rules/OpenApiParameterRules.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs index 7f1a8ec04..d38bd7f9e 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiParameterRules.cs @@ -103,7 +103,8 @@ public static class OpenApiParameterRules new ValidationRule( (context, parameter) => { - if (parameter.In == ParameterLocation.Path && !context.PathString.Contains("{" + parameter.Name + "}")) + if (parameter.In == ParameterLocation.Path && + !(context.PathString.Contains("{" + parameter.Name + "}") || context.PathString.Contains("#/components"))) { context.Enter("in"); context.CreateError( From 5984798377db70f3a0407818747a0f5f0529a30a Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 15 Feb 2022 18:15:25 +0300 Subject: [PATCH 27/67] Initialize a diagnostics object in the constructor and use it to append the exceptions caught --- .../V2/OpenApiV2VersionService.cs | 21 ++++++++++++++++++- .../V3/OpenApiV3VersionService.cs | 14 ++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs index 5baa580af..fbd4dbb85 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs @@ -20,6 +20,17 @@ namespace Microsoft.OpenApi.Readers.V2 /// internal class OpenApiV2VersionService : IOpenApiVersionService { + public OpenApiDiagnostic Diagnostic { get; } + + /// + /// Create Parsing Context + /// + /// Provide instance for diagnotic object for collecting and accessing information about the parsing. + public OpenApiV2VersionService(OpenApiDiagnostic diagnostic) + { + Diagnostic = diagnostic; + } + private IDictionary> _loaders = new Dictionary> { [typeof(IOpenApiAny)] = OpenApiV2Deserializer.LoadAny, @@ -154,7 +165,15 @@ public OpenApiReference ConvertToOpenApiReference(string reference, ReferenceTyp if (reference.StartsWith("#")) { // "$ref": "#/definitions/Pet" - return ParseLocalReference(segments[1]); + try + { + return ParseLocalReference(segments[1]); + } + catch (OpenApiException ex) + { + Diagnostic.Errors.Add(new OpenApiError(ex)); + return null; + } } // $ref: externalSource.yaml#/Pet diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs index 3d4091b95..bdaedf560 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs @@ -19,6 +19,17 @@ namespace Microsoft.OpenApi.Readers.V3 /// internal class OpenApiV3VersionService : IOpenApiVersionService { + public OpenApiDiagnostic Diagnostic { get; } + + /// + /// Create Parsing Context + /// + /// Provide instance for diagnotic object for collecting and accessing information about the parsing. + public OpenApiV3VersionService(OpenApiDiagnostic diagnostic) + { + Diagnostic = diagnostic; + } + private IDictionary> _loaders = new Dictionary> { [typeof(IOpenApiAny)] = OpenApiV3Deserializer.LoadAny, @@ -92,8 +103,9 @@ public OpenApiReference ConvertToOpenApiReference( { return ParseLocalReference(segments[1]); } - catch (OpenApiException) + catch (OpenApiException ex) { + Diagnostic.Errors.Add(new OpenApiError(ex)); return null; } } From a7b1e1e37175a7702ee3d772b72c6398f25ceea7 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 15 Feb 2022 18:16:36 +0300 Subject: [PATCH 28/67] Pass the Diagnostic object to the class instances --- .../ParsingContext.cs | 8 ++++---- .../ConvertToOpenApiReferenceV2Tests.cs | 16 +++++++++++----- .../ConvertToOpenApiReferenceV3Tests.cs | 18 +++++++++++++----- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/ParsingContext.cs b/src/Microsoft.OpenApi.Readers/ParsingContext.cs index b7cfb6acb..6c4dece2f 100644 --- a/src/Microsoft.OpenApi.Readers/ParsingContext.cs +++ b/src/Microsoft.OpenApi.Readers/ParsingContext.cs @@ -60,13 +60,13 @@ internal OpenApiDocument Parse(YamlDocument yamlDocument) switch (inputVersion) { case string version when version == "2.0": - VersionService = new OpenApiV2VersionService(); + VersionService = new OpenApiV2VersionService(Diagnostic); doc = VersionService.LoadDocument(RootNode); this.Diagnostic.SpecificationVersion = OpenApiSpecVersion.OpenApi2_0; break; case string version when version.StartsWith("3.0"): - VersionService = new OpenApiV3VersionService(); + VersionService = new OpenApiV3VersionService(Diagnostic); doc = VersionService.LoadDocument(RootNode); this.Diagnostic.SpecificationVersion = OpenApiSpecVersion.OpenApi3_0; break; @@ -93,12 +93,12 @@ internal T ParseFragment(YamlDocument yamlDocument, OpenApiSpecVersion versio switch (version) { case OpenApiSpecVersion.OpenApi2_0: - VersionService = new OpenApiV2VersionService(); + VersionService = new OpenApiV2VersionService(Diagnostic); element = this.VersionService.LoadElement(node); break; case OpenApiSpecVersion.OpenApi3_0: - this.VersionService = new OpenApiV3VersionService(); + this.VersionService = new OpenApiV3VersionService(Diagnostic); element = this.VersionService.LoadElement(node); break; } diff --git a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs index e374dc205..ff6641f88 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs @@ -10,12 +10,18 @@ namespace Microsoft.OpenApi.Readers.Tests { public class ConvertToOpenApiReferenceV2Tests { + public OpenApiDiagnostic Diagnostic{get;} + + public ConvertToOpenApiReferenceV2Tests() + { + Diagnostic = new OpenApiDiagnostic(); + } [Fact] public void ParseExternalReference() { // Arrange - var versionService = new OpenApiV2VersionService(); + var versionService = new OpenApiV2VersionService(Diagnostic); var externalResource = "externalSchema.json"; var id = "externalPathSegment1/externalPathSegment2/externalPathSegment3"; var input = $"{externalResource}#/{id}"; @@ -33,7 +39,7 @@ public void ParseExternalReference() public void ParseLocalParameterReference() { // Arrange - var versionService = new OpenApiV2VersionService(); + var versionService = new OpenApiV2VersionService(Diagnostic); var referenceType = ReferenceType.Parameter; var id = "parameterId"; var input = $"#/parameters/{id}"; @@ -51,7 +57,7 @@ public void ParseLocalParameterReference() public void ParseLocalSchemaReference() { // Arrange - var versionService = new OpenApiV2VersionService(); + var versionService = new OpenApiV2VersionService(Diagnostic); var referenceType = ReferenceType.Schema; var id = "parameterId"; var input = $"#/definitions/{id}"; @@ -69,7 +75,7 @@ public void ParseLocalSchemaReference() public void ParseTagReference() { // Arrange - var versionService = new OpenApiV2VersionService(); + var versionService = new OpenApiV2VersionService(Diagnostic); var referenceType = ReferenceType.Tag; var id = "tagId"; var input = $"{id}"; @@ -87,7 +93,7 @@ public void ParseTagReference() public void ParseSecuritySchemeReference() { // Arrange - var versionService = new OpenApiV2VersionService(); + var versionService = new OpenApiV2VersionService(Diagnostic); var referenceType = ReferenceType.SecurityScheme; var id = "securitySchemeId"; var input = $"{id}"; diff --git a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs index 04debfd7d..c4e88998e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs @@ -10,12 +10,20 @@ namespace Microsoft.OpenApi.Readers.Tests { public class ConvertToOpenApiReferenceV3Tests { + public OpenApiDiagnostic Diagnostic { get; } + + public ConvertToOpenApiReferenceV3Tests() + { + Diagnostic = new OpenApiDiagnostic(); + } + + [Fact] public void ParseExternalReference() { // Arrange - var versionService = new OpenApiV3VersionService(); + var versionService = new OpenApiV3VersionService(Diagnostic); var externalResource = "externalSchema.json"; var id = "/externalPathSegment1/externalPathSegment2/externalPathSegment3"; var input = $"{externalResource}#{id}"; @@ -33,7 +41,7 @@ public void ParseExternalReference() public void ParseLocalParameterReference() { // Arrange - var versionService = new OpenApiV3VersionService(); + var versionService = new OpenApiV3VersionService(Diagnostic); var referenceType = ReferenceType.Parameter; var id = "parameterId"; var input = $"#/components/parameters/{id}"; @@ -51,7 +59,7 @@ public void ParseLocalParameterReference() public void ParseLocalSchemaReference() { // Arrange - var versionService = new OpenApiV3VersionService(); + var versionService = new OpenApiV3VersionService(Diagnostic); var referenceType = ReferenceType.Schema; var id = "schemaId"; var input = $"#/components/schemas/{id}"; @@ -69,7 +77,7 @@ public void ParseLocalSchemaReference() public void ParseTagReference() { // Arrange - var versionService = new OpenApiV3VersionService(); + var versionService = new OpenApiV3VersionService(Diagnostic); var referenceType = ReferenceType.Tag; var id = "tagId"; var input = $"{id}"; @@ -87,7 +95,7 @@ public void ParseTagReference() public void ParseSecuritySchemeReference() { // Arrange - var versionService = new OpenApiV3VersionService(); + var versionService = new OpenApiV3VersionService(Diagnostic); var referenceType = ReferenceType.SecurityScheme; var id = "securitySchemeId"; var input = $"{id}"; From 00eca6f7b057073791e9d234574093865a1a442d Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 15 Feb 2022 18:28:47 +0300 Subject: [PATCH 29/67] Upgrade packages --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- .../Microsoft.OpenApi.Tests.csproj | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 70a39df3a..1a4131864 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -36,7 +36,7 @@ - + diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj index 7ed607fd3..63debd17e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -243,7 +243,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 8bedf8388..ff22b0d00 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,20 +15,20 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + From ceb3ff4b2ac9d1cbdcde70a27c4a5e0a384bb7aa Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 16 Feb 2022 12:31:03 +0300 Subject: [PATCH 30/67] Update TFMs in project and workflow files --- .github/workflows/ci-cd.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- .../Microsoft.OpenApi.Readers.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- .../Microsoft.OpenApi.SmokeTests.csproj | 4 ++-- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 610134cd0..34647ed31 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -16,7 +16,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0.x + dotnet-version: 6.0.x - name: Data gatherer id: data_gatherer diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 347ff8bca..833635651 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -19,7 +19,7 @@ jobs: - name: Setup .NET uses: actions/setup-dotnet@v1 with: - dotnet-version: 5.0.x + dotnet-version: 6.0.x - name: Initialize CodeQL id: init_codeql diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 70a39df3a..95e61a394 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp3.1 + net6.0 9.0 true http://go.microsoft.com/fwlink/?LinkID=288890 diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index ac11100c2..542a7afd0 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + net6.0 true http://go.microsoft.com/fwlink/?LinkID=288890 https://github.com/Microsoft/OpenAPI.NET diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 328e374b5..8dceb231f 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -1,6 +1,6 @@  - netstandard2.0 + net6.0 9.0 true http://go.microsoft.com/fwlink/?LinkID=288890 diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj index 7ed607fd3..516f5122f 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -1,6 +1,6 @@  - net48;net50 + net6.0 false Microsoft diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 44d85ee21..290277c69 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -1,11 +1,11 @@  - net48 + net60 - TRACE;DEBUG;NET48 + TRACE;DEBUG;NET60 diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 8bedf8388..704734275 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -1,6 +1,6 @@  - net50 + net6.0 false Microsoft From b97760734e3b09f0aaf85569b1743261a65c6ca0 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 16 Feb 2022 13:01:51 +0300 Subject: [PATCH 31/67] Update public api text file --- test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index f700fee15..55ddcde47 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -1,7 +1,7 @@ [assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/Microsoft/OpenAPI.NET")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Microsoft.OpenApi.Readers.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100957cb48387b2a5f54f5ce39255f18f26d32a39990db27cf48737afc6bc62759ba996b8a2bfb675d4e39f3d06ecb55a178b1b4031dcb2a767e29977d88cce864a0d16bfc1b3bebb0edf9fe285f10fffc0a85f93d664fa05af07faa3aad2e545182dbf787e3fd32b56aca95df1a3c4e75dec164a3f1a4c653d971b01ffc39eb3c4")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Microsoft.OpenApi.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100957cb48387b2a5f54f5ce39255f18f26d32a39990db27cf48737afc6bc62759ba996b8a2bfb675d4e39f3d06ecb55a178b1b4031dcb2a767e29977d88cce864a0d16bfc1b3bebb0edf9fe285f10fffc0a85f93d664fa05af07faa3aad2e545182dbf787e3fd32b56aca95df1a3c4e75dec164a3f1a4c653d971b01ffc39eb3c4")] -[assembly: System.Runtime.Versioning.TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName="")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName="")] namespace Microsoft.OpenApi.Any { public enum AnyType From 8e9e8cb1254a4e550e45e1c1155dc346dd3cb82d Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 16 Feb 2022 13:05:00 +0300 Subject: [PATCH 32/67] Migrate WPF project to .NET6 and delete obsolete App.config --- src/Microsoft.OpenApi.Workbench/App.config | 6 - .../Microsoft.OpenApi.Workbench.csproj | 141 +++--------------- 2 files changed, 20 insertions(+), 127 deletions(-) delete mode 100644 src/Microsoft.OpenApi.Workbench/App.config diff --git a/src/Microsoft.OpenApi.Workbench/App.config b/src/Microsoft.OpenApi.Workbench/App.config deleted file mode 100644 index 4bfa00561..000000000 --- a/src/Microsoft.OpenApi.Workbench/App.config +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index 47a9d6ffe..5921cd4c2 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -1,136 +1,35 @@ - - - + - Debug - AnyCPU - {6A5E91E5-0441-46EE-AEB9-8334981B7F08} + net6.0-windows WinExe - Microsoft.OpenApi.Workbench - Microsoft.OpenApi.Workbench - v4.8 - 512 - {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - 4 - true - - - - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + true + true - - - - - - - - - - 4.0 - - - - + + + all + + - - MSBuild:Compile - Designer - - - - MSBuild:Compile - Designer - - - App.xaml - Code - - - - MainWindow.xaml - Code - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - - - Code - - - True - True - Resources.resx - - - True - Settings.settings - True - - - ResXFileCodeGenerator - Resources.Designer.cs - - - SettingsSingleFileGenerator - Settings.Designer.cs - + - + + - + + - - {79933258-0126-4382-8755-d50820ecc483} - Microsoft.OpenApi.Readers - - - {a8e50143-69b2-472a-9d45-3f9a05d13202} - Microsoft.OpenApi.Core - + + + + + - \ No newline at end of file From 25b7357d84efa790081b89226959404310c68855 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 16 Feb 2022 21:14:06 +0300 Subject: [PATCH 33/67] Remove package and its reference --- src/Microsoft.OpenApi.Workbench/App.xaml | 8 -------- .../Microsoft.OpenApi.Workbench.csproj | 1 - 2 files changed, 9 deletions(-) diff --git a/src/Microsoft.OpenApi.Workbench/App.xaml b/src/Microsoft.OpenApi.Workbench/App.xaml index 40e1d5bad..d4fbb4a0c 100644 --- a/src/Microsoft.OpenApi.Workbench/App.xaml +++ b/src/Microsoft.OpenApi.Workbench/App.xaml @@ -3,12 +3,4 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:Microsoft.OpenApi.Workbench" StartupUri="MainWindow.xaml"> - - - - - - - - diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index 5921cd4c2..d56e31ec5 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -7,7 +7,6 @@ true - all From 7b2821e8668b19c8dc34593b505cf1b2597f49e7 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 16 Feb 2022 22:36:47 +0300 Subject: [PATCH 34/67] Add enums to cater for multiple scheme and bearer formats --- .../Models/AuthenticationScheme.cs | 30 +++++++++++++++++++ src/Microsoft.OpenApi/Models/BearerFormat.cs | 19 ++++++++++++ .../Models/OpenApiSecurityScheme.cs | 6 ++-- 3 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 src/Microsoft.OpenApi/Models/AuthenticationScheme.cs create mode 100644 src/Microsoft.OpenApi/Models/BearerFormat.cs diff --git a/src/Microsoft.OpenApi/Models/AuthenticationScheme.cs b/src/Microsoft.OpenApi/Models/AuthenticationScheme.cs new file mode 100644 index 000000000..712dd9665 --- /dev/null +++ b/src/Microsoft.OpenApi/Models/AuthenticationScheme.cs @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using Microsoft.OpenApi.Attributes; + +namespace Microsoft.OpenApi.Models +{ + /// + /// The type of HTTP authentication schemes + /// + public enum AuthenticationScheme + { + /// + /// Use basic HTTP authentication schemes + /// + [Display("basic")] Basic, + + /// + /// Use bearer Authentication scheme + /// + [Display("bearer")] Bearer, + + /// + /// Use OpenIdConnectUrl + /// + [Display("openIdConnectUrl")] OpenIdConnectUrl + + + } +} diff --git a/src/Microsoft.OpenApi/Models/BearerFormat.cs b/src/Microsoft.OpenApi/Models/BearerFormat.cs new file mode 100644 index 000000000..e3ec7dbf0 --- /dev/null +++ b/src/Microsoft.OpenApi/Models/BearerFormat.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using Microsoft.OpenApi.Attributes; + +namespace Microsoft.OpenApi.Models +{ + /// + /// The type of Bearer authentication scheme + /// + public enum BearerFormat + { + /// + /// Use JWT bearer format + /// + [Display("jwt")] JWT, + + } +} diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs index 7694c5fd4..7d0a98bf7 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -39,14 +39,14 @@ public class OpenApiSecurityScheme : IOpenApiSerializable, IOpenApiReferenceable /// REQUIRED. The name of the HTTP Authorization scheme to be used /// in the Authorization header as defined in RFC7235. /// - public string Scheme { get; set; } + public AuthenticationScheme Scheme { get; set; } /// /// A hint to the client to identify how the bearer token is formatted. /// Bearer tokens are usually generated by an authorization server, /// so this information is primarily for documentation purposes. /// - public string BearerFormat { get; set; } + public BearerFormat BearerFormat { get; set; } /// /// REQUIRED. An object containing configuration information for the flow types supported. From 8af1c193a98abf07ca765258e0146fe8943156d0 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 16 Feb 2022 22:38:04 +0300 Subject: [PATCH 35/67] Get the display name from the enum --- .../V3/OpenApiSecuritySchemeDeserializer.cs | 4 ++-- src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiSecuritySchemeDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiSecuritySchemeDeserializer.cs index 0e7b1c39c..32742291b 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiSecuritySchemeDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiSecuritySchemeDeserializer.cs @@ -44,13 +44,13 @@ internal static partial class OpenApiV3Deserializer { "scheme", (o, n) => { - o.Scheme = n.GetScalarValue(); + o.Scheme = n.GetScalarValue().GetEnumFromDisplayName(); } }, { "bearerFormat", (o, n) => { - o.BearerFormat = n.GetScalarValue(); + o.BearerFormat = n.GetScalarValue().GetEnumFromDisplayName(); } }, { diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs index 7d0a98bf7..3542be3a5 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs @@ -118,8 +118,8 @@ public void SerializeAsV3WithoutReference(IOpenApiWriter writer) // These properties apply to http type only. // scheme // bearerFormat - writer.WriteProperty(OpenApiConstants.Scheme, Scheme); - writer.WriteProperty(OpenApiConstants.BearerFormat, BearerFormat); + writer.WriteProperty(OpenApiConstants.Scheme, Scheme.GetDisplayName()); + writer.WriteProperty(OpenApiConstants.BearerFormat, BearerFormat.GetDisplayName()); break; case SecuritySchemeType.OAuth2: // This property apply to oauth2 type only. From fc6f4617b20bbf074eb877ed834d4d8808924b7b Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 16 Feb 2022 22:38:19 +0300 Subject: [PATCH 36/67] Refactor code --- .../V2/OpenApiSecuritySchemeDeserializer.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs | 4 ++-- .../V3Tests/OpenApiSecuritySchemeTests.cs | 6 +++--- .../Models/OpenApiComponentsTests.cs | 4 ++-- .../Models/OpenApiSecuritySchemeTests.cs | 10 +++++----- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiSecuritySchemeDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiSecuritySchemeDeserializer.cs index 7e0c6c1dc..fc7b761a4 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiSecuritySchemeDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiSecuritySchemeDeserializer.cs @@ -30,7 +30,7 @@ internal static partial class OpenApiV2Deserializer { case "basic": o.Type = SecuritySchemeType.Http; - o.Scheme = "basic"; + o.Scheme = AuthenticationScheme.Basic; break; case "apiKey": diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs index 3542be3a5..32550dff5 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; @@ -163,7 +163,7 @@ public void SerializeAsV2(IOpenApiWriter writer) /// public void SerializeAsV2WithoutReference(IOpenApiWriter writer) { - if (Type == SecuritySchemeType.Http && Scheme != OpenApiConstants.Basic) + if (Type == SecuritySchemeType.Http && Scheme != AuthenticationScheme.Basic) { // Bail because V2 does not support non-basic HTTP scheme writer.WriteStartObject(); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs index 57c156cc0..6aca51559 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs @@ -40,7 +40,7 @@ public void ParseHttpSecuritySchemeShouldSucceed() new OpenApiSecurityScheme { Type = SecuritySchemeType.Http, - Scheme = "basic" + Scheme = AuthenticationScheme.Basic }); } } @@ -95,8 +95,8 @@ public void ParseBearerSecuritySchemeShouldSucceed() new OpenApiSecurityScheme { Type = SecuritySchemeType.Http, - Scheme = "bearer", - BearerFormat = "JWT" + Scheme = AuthenticationScheme.Bearer, + BearerFormat = BearerFormat.JWT }); } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs index 002143b15..84364a12c 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs @@ -57,7 +57,7 @@ public class OpenApiComponentsTests { Description = "description1", Type = SecuritySchemeType.OpenIdConnect, - Scheme = "openIdConnectUrl", + Scheme = AuthenticationScheme.OpenIdConnectUrl, OpenIdConnectUrl = new Uri("https://example.com/openIdConnect") } } @@ -129,7 +129,7 @@ public class OpenApiComponentsTests { Description = "description1", Type = SecuritySchemeType.OpenIdConnect, - Scheme = "openIdConnectUrl", + Scheme = AuthenticationScheme.OpenIdConnectUrl, OpenIdConnectUrl = new Uri("https://example.com/openIdConnect"), Reference = new OpenApiReference { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs index b7871f51f..6c035f1a0 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs @@ -32,15 +32,15 @@ public class OpenApiSecuritySchemeTests { Description = "description1", Type = SecuritySchemeType.Http, - Scheme = "basic", + Scheme = AuthenticationScheme.Basic, }; public static OpenApiSecurityScheme HttpBearerSecurityScheme = new OpenApiSecurityScheme { Description = "description1", Type = SecuritySchemeType.Http, - Scheme = "bearer", - BearerFormat = "JWT", + Scheme = AuthenticationScheme.Bearer, + BearerFormat = BearerFormat.JWT, }; public static OpenApiSecurityScheme OAuth2SingleFlowSecurityScheme = new OpenApiSecurityScheme @@ -103,7 +103,7 @@ public class OpenApiSecuritySchemeTests { Description = "description1", Type = SecuritySchemeType.OpenIdConnect, - Scheme = "openIdConnectUrl", + Scheme = AuthenticationScheme.OpenIdConnectUrl, OpenIdConnectUrl = new Uri("https://example.com/openIdConnect") }; @@ -111,7 +111,7 @@ public class OpenApiSecuritySchemeTests { Description = "description1", Type = SecuritySchemeType.OpenIdConnect, - Scheme = "openIdConnectUrl", + Scheme = AuthenticationScheme.OpenIdConnectUrl, OpenIdConnectUrl = new Uri("https://example.com/openIdConnect"), Reference = new OpenApiReference { From 5dc4d8a2fe13cf39e67f31523a0dacd3ac46766b Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 16 Feb 2022 23:46:08 +0300 Subject: [PATCH 37/67] Fix test --- .../V2Tests/OpenApiSecuritySchemeTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs index 1a4a2a3d7..16afc3c08 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs @@ -38,7 +38,7 @@ public void ParseHttpSecuritySchemeShouldSucceed() new OpenApiSecurityScheme { Type = SecuritySchemeType.Http, - Scheme = "basic" + Scheme = AuthenticationScheme.Basic }); } } From 80498c984dd316871a53ba1aef38caa6e8c4e70b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 16 Feb 2022 21:09:54 +0000 Subject: [PATCH 38/67] Bump Microsoft.NET.Test.Sdk from 17.0.0 to 17.1.0 Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.0.0 to 17.1.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v17.0.0...v17.1.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- .../Microsoft.OpenApi.SmokeTests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj index 7ed607fd3..929f1bc75 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -242,7 +242,7 @@ - + diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 44d85ee21..c295543d3 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -9,7 +9,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 8bedf8388..6eb06b896 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -16,7 +16,7 @@ - + From 972098762d02b8a49707719e472eec8682669241 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 21 Feb 2022 11:24:56 +0300 Subject: [PATCH 39/67] Add Jwt and Bearer constants and revert previous changes --- .../V2/OpenApiSecuritySchemeDeserializer.cs | 2 +- .../V3/OpenApiSecuritySchemeDeserializer.cs | 4 +-- .../Models/AuthenticationScheme.cs | 30 ------------------- src/Microsoft.OpenApi/Models/BearerFormat.cs | 19 ------------ .../Models/OpenApiConstants.cs | 10 +++++++ .../Models/OpenApiSecurityScheme.cs | 10 +++---- .../V2Tests/OpenApiSecuritySchemeTests.cs | 2 +- .../V3Tests/OpenApiSecuritySchemeTests.cs | 6 ++-- .../Models/OpenApiComponentsTests.cs | 4 +-- .../Models/OpenApiSecuritySchemeTests.cs | 11 +++---- 10 files changed, 30 insertions(+), 68 deletions(-) delete mode 100644 src/Microsoft.OpenApi/Models/AuthenticationScheme.cs delete mode 100644 src/Microsoft.OpenApi/Models/BearerFormat.cs diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiSecuritySchemeDeserializer.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiSecuritySchemeDeserializer.cs index fc7b761a4..b2aab773c 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiSecuritySchemeDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiSecuritySchemeDeserializer.cs @@ -30,7 +30,7 @@ internal static partial class OpenApiV2Deserializer { case "basic": o.Type = SecuritySchemeType.Http; - o.Scheme = AuthenticationScheme.Basic; + o.Scheme = OpenApiConstants.Basic; break; case "apiKey": diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiSecuritySchemeDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiSecuritySchemeDeserializer.cs index 32742291b..0e7b1c39c 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiSecuritySchemeDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiSecuritySchemeDeserializer.cs @@ -44,13 +44,13 @@ internal static partial class OpenApiV3Deserializer { "scheme", (o, n) => { - o.Scheme = n.GetScalarValue().GetEnumFromDisplayName(); + o.Scheme = n.GetScalarValue(); } }, { "bearerFormat", (o, n) => { - o.BearerFormat = n.GetScalarValue().GetEnumFromDisplayName(); + o.BearerFormat = n.GetScalarValue(); } }, { diff --git a/src/Microsoft.OpenApi/Models/AuthenticationScheme.cs b/src/Microsoft.OpenApi/Models/AuthenticationScheme.cs deleted file mode 100644 index 712dd9665..000000000 --- a/src/Microsoft.OpenApi/Models/AuthenticationScheme.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. - -using Microsoft.OpenApi.Attributes; - -namespace Microsoft.OpenApi.Models -{ - /// - /// The type of HTTP authentication schemes - /// - public enum AuthenticationScheme - { - /// - /// Use basic HTTP authentication schemes - /// - [Display("basic")] Basic, - - /// - /// Use bearer Authentication scheme - /// - [Display("bearer")] Bearer, - - /// - /// Use OpenIdConnectUrl - /// - [Display("openIdConnectUrl")] OpenIdConnectUrl - - - } -} diff --git a/src/Microsoft.OpenApi/Models/BearerFormat.cs b/src/Microsoft.OpenApi/Models/BearerFormat.cs deleted file mode 100644 index e3ec7dbf0..000000000 --- a/src/Microsoft.OpenApi/Models/BearerFormat.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. - -using Microsoft.OpenApi.Attributes; - -namespace Microsoft.OpenApi.Models -{ - /// - /// The type of Bearer authentication scheme - /// - public enum BearerFormat - { - /// - /// Use JWT bearer format - /// - [Display("jwt")] JWT, - - } -} diff --git a/src/Microsoft.OpenApi/Models/OpenApiConstants.cs b/src/Microsoft.OpenApi/Models/OpenApiConstants.cs index 3a29a88b1..553844764 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiConstants.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiConstants.cs @@ -617,6 +617,16 @@ public static class OpenApiConstants /// public const string Basic = "basic"; + /// + /// Field: Bearer + /// + public const string Bearer = "bearer"; + + /// + /// Field: JWT + /// + public const string Jwt = "JWT"; + /// /// Field: Consumes /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs index 32550dff5..7694c5fd4 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs @@ -39,14 +39,14 @@ public class OpenApiSecurityScheme : IOpenApiSerializable, IOpenApiReferenceable /// REQUIRED. The name of the HTTP Authorization scheme to be used /// in the Authorization header as defined in RFC7235. /// - public AuthenticationScheme Scheme { get; set; } + public string Scheme { get; set; } /// /// A hint to the client to identify how the bearer token is formatted. /// Bearer tokens are usually generated by an authorization server, /// so this information is primarily for documentation purposes. /// - public BearerFormat BearerFormat { get; set; } + public string BearerFormat { get; set; } /// /// REQUIRED. An object containing configuration information for the flow types supported. @@ -118,8 +118,8 @@ public void SerializeAsV3WithoutReference(IOpenApiWriter writer) // These properties apply to http type only. // scheme // bearerFormat - writer.WriteProperty(OpenApiConstants.Scheme, Scheme.GetDisplayName()); - writer.WriteProperty(OpenApiConstants.BearerFormat, BearerFormat.GetDisplayName()); + writer.WriteProperty(OpenApiConstants.Scheme, Scheme); + writer.WriteProperty(OpenApiConstants.BearerFormat, BearerFormat); break; case SecuritySchemeType.OAuth2: // This property apply to oauth2 type only. @@ -163,7 +163,7 @@ public void SerializeAsV2(IOpenApiWriter writer) /// public void SerializeAsV2WithoutReference(IOpenApiWriter writer) { - if (Type == SecuritySchemeType.Http && Scheme != AuthenticationScheme.Basic) + if (Type == SecuritySchemeType.Http && Scheme != OpenApiConstants.Basic) { // Bail because V2 does not support non-basic HTTP scheme writer.WriteStartObject(); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs index 16afc3c08..22f7d1633 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs @@ -38,7 +38,7 @@ public void ParseHttpSecuritySchemeShouldSucceed() new OpenApiSecurityScheme { Type = SecuritySchemeType.Http, - Scheme = AuthenticationScheme.Basic + Scheme = OpenApiConstants.Basic }); } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs index 6aca51559..9d7a27d72 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs @@ -40,7 +40,7 @@ public void ParseHttpSecuritySchemeShouldSucceed() new OpenApiSecurityScheme { Type = SecuritySchemeType.Http, - Scheme = AuthenticationScheme.Basic + Scheme = OpenApiConstants.Basic }); } } @@ -95,8 +95,8 @@ public void ParseBearerSecuritySchemeShouldSucceed() new OpenApiSecurityScheme { Type = SecuritySchemeType.Http, - Scheme = AuthenticationScheme.Bearer, - BearerFormat = BearerFormat.JWT + Scheme = OpenApiConstants.Bearer, + BearerFormat = OpenApiConstants.Jwt }); } } diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs index 84364a12c..e3a6ebf1e 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs @@ -57,7 +57,7 @@ public class OpenApiComponentsTests { Description = "description1", Type = SecuritySchemeType.OpenIdConnect, - Scheme = AuthenticationScheme.OpenIdConnectUrl, + Scheme = OpenApiConstants.OpenIdConnectUrl, OpenIdConnectUrl = new Uri("https://example.com/openIdConnect") } } @@ -129,7 +129,7 @@ public class OpenApiComponentsTests { Description = "description1", Type = SecuritySchemeType.OpenIdConnect, - Scheme = AuthenticationScheme.OpenIdConnectUrl, + Scheme = OpenApiConstants.OpenIdConnectUrl, OpenIdConnectUrl = new Uri("https://example.com/openIdConnect"), Reference = new OpenApiReference { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs index 6c035f1a0..4e30dc80f 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs @@ -32,15 +32,16 @@ public class OpenApiSecuritySchemeTests { Description = "description1", Type = SecuritySchemeType.Http, - Scheme = AuthenticationScheme.Basic, + Scheme = OpenApiConstants.Basic + }; public static OpenApiSecurityScheme HttpBearerSecurityScheme = new OpenApiSecurityScheme { Description = "description1", Type = SecuritySchemeType.Http, - Scheme = AuthenticationScheme.Bearer, - BearerFormat = BearerFormat.JWT, + Scheme = OpenApiConstants.Bearer, + BearerFormat = OpenApiConstants.Jwt }; public static OpenApiSecurityScheme OAuth2SingleFlowSecurityScheme = new OpenApiSecurityScheme @@ -103,7 +104,7 @@ public class OpenApiSecuritySchemeTests { Description = "description1", Type = SecuritySchemeType.OpenIdConnect, - Scheme = AuthenticationScheme.OpenIdConnectUrl, + Scheme = OpenApiConstants.OpenIdConnectUrl, OpenIdConnectUrl = new Uri("https://example.com/openIdConnect") }; @@ -111,7 +112,7 @@ public class OpenApiSecuritySchemeTests { Description = "description1", Type = SecuritySchemeType.OpenIdConnect, - Scheme = AuthenticationScheme.OpenIdConnectUrl, + Scheme = OpenApiConstants.OpenIdConnectUrl, OpenIdConnectUrl = new Uri("https://example.com/openIdConnect"), Reference = new OpenApiReference { From 2b2bc251d17c1ac9624494d6a3373e5e306fdbba Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 22 Feb 2022 19:11:10 +0300 Subject: [PATCH 40/67] Remove the OpenIdConnectUrl constant and replace it with the Bearer scheme in the tests --- src/Microsoft.OpenApi/Models/OpenApiConstants.cs | 5 ----- .../Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs | 4 ++-- .../Models/OpenApiSecuritySchemeTests.cs | 4 ++-- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiConstants.cs b/src/Microsoft.OpenApi/Models/OpenApiConstants.cs index 553844764..88c44ef9a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiConstants.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiConstants.cs @@ -535,11 +535,6 @@ public static class OpenApiConstants /// public const string Flows = "flows"; - /// - /// Field: OpenIdConnectUrl - /// - public const string OpenIdConnectUrl = "openIdConnectUrl"; - /// /// Field: DefaultName /// diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs index e3a6ebf1e..7ba6d132c 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs @@ -57,7 +57,7 @@ public class OpenApiComponentsTests { Description = "description1", Type = SecuritySchemeType.OpenIdConnect, - Scheme = OpenApiConstants.OpenIdConnectUrl, + Scheme = OpenApiConstants.Bearer, OpenIdConnectUrl = new Uri("https://example.com/openIdConnect") } } @@ -129,7 +129,7 @@ public class OpenApiComponentsTests { Description = "description1", Type = SecuritySchemeType.OpenIdConnect, - Scheme = OpenApiConstants.OpenIdConnectUrl, + Scheme = OpenApiConstants.Bearer, OpenIdConnectUrl = new Uri("https://example.com/openIdConnect"), Reference = new OpenApiReference { diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs index 4e30dc80f..1294f0f48 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs @@ -104,7 +104,7 @@ public class OpenApiSecuritySchemeTests { Description = "description1", Type = SecuritySchemeType.OpenIdConnect, - Scheme = OpenApiConstants.OpenIdConnectUrl, + Scheme = OpenApiConstants.Bearer, OpenIdConnectUrl = new Uri("https://example.com/openIdConnect") }; @@ -112,7 +112,7 @@ public class OpenApiSecuritySchemeTests { Description = "description1", Type = SecuritySchemeType.OpenIdConnect, - Scheme = OpenApiConstants.OpenIdConnectUrl, + Scheme = OpenApiConstants.Bearer, OpenIdConnectUrl = new Uri("https://example.com/openIdConnect"), Reference = new OpenApiReference { From 4fdfd7040311898eaffb1c17a5b2771964a63301 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 22 Feb 2022 20:58:00 +0300 Subject: [PATCH 41/67] Clean up solution file --- Microsoft.OpenApi.sln | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/Microsoft.OpenApi.sln b/Microsoft.OpenApi.sln index dc489bff8..e8e902e86 100644 --- a/Microsoft.OpenApi.sln +++ b/Microsoft.OpenApi.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29613.14 +# Visual Studio Version 17 +VisualStudioVersion = 17.1.32210.238 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi", "src\Microsoft.OpenApi\Microsoft.OpenApi.csproj", "{A8E50143-69B2-472A-9D45-3F9A05D13202}" EndProject @@ -12,7 +12,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution readme.md = readme.md EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.OpenApi.Workbench", "src\Microsoft.OpenApi.Workbench\Microsoft.OpenApi.Workbench.csproj", "{6A5E91E5-0441-46EE-AEB9-8334981B7F08}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Workbench", "src\Microsoft.OpenApi.Workbench\Microsoft.OpenApi.Workbench.csproj", "{6A5E91E5-0441-46EE-AEB9-8334981B7F08}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Readers", "src\Microsoft.OpenApi.Readers\Microsoft.OpenApi.Readers.csproj", "{79933258-0126-4382-8755-D50820ECC483}" EndProject @@ -38,10 +38,6 @@ Global {A8E50143-69B2-472A-9D45-3F9A05D13202}.Debug|Any CPU.Build.0 = Debug|Any CPU {A8E50143-69B2-472A-9D45-3F9A05D13202}.Release|Any CPU.ActiveCfg = Release|Any CPU {A8E50143-69B2-472A-9D45-3F9A05D13202}.Release|Any CPU.Build.0 = Release|Any CPU - {6A5E91E5-0441-46EE-AEB9-8334981B7F08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {6A5E91E5-0441-46EE-AEB9-8334981B7F08}.Debug|Any CPU.Build.0 = Debug|Any CPU - {6A5E91E5-0441-46EE-AEB9-8334981B7F08}.Release|Any CPU.ActiveCfg = Release|Any CPU - {6A5E91E5-0441-46EE-AEB9-8334981B7F08}.Release|Any CPU.Build.0 = Release|Any CPU {79933258-0126-4382-8755-D50820ECC483}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {79933258-0126-4382-8755-D50820ECC483}.Debug|Any CPU.Build.0 = Debug|Any CPU {79933258-0126-4382-8755-D50820ECC483}.Release|Any CPU.ActiveCfg = Release|Any CPU From 0f1350d724eb5de7383d5db55e7c57b27f2d6376 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 22 Feb 2022 21:20:05 +0300 Subject: [PATCH 42/67] Revert --- src/Microsoft.OpenApi/Models/OpenApiConstants.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Microsoft.OpenApi/Models/OpenApiConstants.cs b/src/Microsoft.OpenApi/Models/OpenApiConstants.cs index 88c44ef9a..553844764 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiConstants.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiConstants.cs @@ -535,6 +535,11 @@ public static class OpenApiConstants /// public const string Flows = "flows"; + /// + /// Field: OpenIdConnectUrl + /// + public const string OpenIdConnectUrl = "openIdConnectUrl"; + /// /// Field: DefaultName /// From 9ef0a8ebe1c74a8a58b6c9d4f24ce299c3656c3c Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 22 Feb 2022 23:04:12 +0300 Subject: [PATCH 43/67] Update target framework monikers --- .../Microsoft.OpenApi.Readers.csproj | 4 ++-- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 542a7afd0..93a9c5918 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -1,6 +1,6 @@ - + - net6.0 + netstandard2.0;net462 true http://go.microsoft.com/fwlink/?LinkID=288890 https://github.com/Microsoft/OpenAPI.NET diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 8dceb231f..d49f20f9b 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -1,6 +1,6 @@  - net6.0 + netstandard2.0;net462 9.0 true http://go.microsoft.com/fwlink/?LinkID=288890 From b440e32e7cca1bf52d9be29c5de1d2cb36c7971e Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 22 Feb 2022 23:04:54 +0300 Subject: [PATCH 44/67] Revert change to the public API interface --- test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 55ddcde47..f700fee15 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -1,7 +1,7 @@ [assembly: System.Reflection.AssemblyMetadata("RepositoryUrl", "https://github.com/Microsoft/OpenAPI.NET")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Microsoft.OpenApi.Readers.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100957cb48387b2a5f54f5ce39255f18f26d32a39990db27cf48737afc6bc62759ba996b8a2bfb675d4e39f3d06ecb55a178b1b4031dcb2a767e29977d88cce864a0d16bfc1b3bebb0edf9fe285f10fffc0a85f93d664fa05af07faa3aad2e545182dbf787e3fd32b56aca95df1a3c4e75dec164a3f1a4c653d971b01ffc39eb3c4")] [assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"Microsoft.OpenApi.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100957cb48387b2a5f54f5ce39255f18f26d32a39990db27cf48737afc6bc62759ba996b8a2bfb675d4e39f3d06ecb55a178b1b4031dcb2a767e29977d88cce864a0d16bfc1b3bebb0edf9fe285f10fffc0a85f93d664fa05af07faa3aad2e545182dbf787e3fd32b56aca95df1a3c4e75dec164a3f1a4c653d971b01ffc39eb3c4")] -[assembly: System.Runtime.Versioning.TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName="")] +[assembly: System.Runtime.Versioning.TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName="")] namespace Microsoft.OpenApi.Any { public enum AnyType From b1e745ce9b41c95294a6552e5d64222f898ca065 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 22 Feb 2022 23:27:55 +0300 Subject: [PATCH 45/67] Address review feedback --- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- .../Microsoft.OpenApi.SmokeTests.csproj | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index d49f20f9b..5b32e1d4b 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -1,7 +1,7 @@  netstandard2.0;net462 - 9.0 + Latest true http://go.microsoft.com/fwlink/?LinkID=288890 https://github.com/Microsoft/OpenAPI.NET diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 290277c69..89031c835 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -1,11 +1,10 @@  - net60 + net6.0 - TRACE;DEBUG;NET60 From b98a4cb2e2a7f293d3ef53eee1af54c5763d0b0b Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Tue, 22 Feb 2022 22:45:21 -0500 Subject: [PATCH 46/67] removed support for net462 --- Microsoft.OpenApi.sln | 4 ++++ .../Microsoft.OpenApi.Readers.csproj | 4 ++-- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Microsoft.OpenApi.sln b/Microsoft.OpenApi.sln index e8e902e86..cca18f1e5 100644 --- a/Microsoft.OpenApi.sln +++ b/Microsoft.OpenApi.sln @@ -38,6 +38,10 @@ Global {A8E50143-69B2-472A-9D45-3F9A05D13202}.Debug|Any CPU.Build.0 = Debug|Any CPU {A8E50143-69B2-472A-9D45-3F9A05D13202}.Release|Any CPU.ActiveCfg = Release|Any CPU {A8E50143-69B2-472A-9D45-3F9A05D13202}.Release|Any CPU.Build.0 = Release|Any CPU + {6A5E91E5-0441-46EE-AEB9-8334981B7F08}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6A5E91E5-0441-46EE-AEB9-8334981B7F08}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6A5E91E5-0441-46EE-AEB9-8334981B7F08}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6A5E91E5-0441-46EE-AEB9-8334981B7F08}.Release|Any CPU.Build.0 = Release|Any CPU {79933258-0126-4382-8755-D50820ECC483}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {79933258-0126-4382-8755-D50820ECC483}.Debug|Any CPU.Build.0 = Debug|Any CPU {79933258-0126-4382-8755-D50820ECC483}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 93a9c5918..1b4542073 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -1,6 +1,6 @@ - netstandard2.0;net462 + netstandard2.0 true http://go.microsoft.com/fwlink/?LinkID=288890 https://github.com/Microsoft/OpenAPI.NET @@ -36,7 +36,7 @@ - + diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 5b32e1d4b..a1d9cab65 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -1,6 +1,6 @@  - netstandard2.0;net462 + netstandard2.0 Latest true http://go.microsoft.com/fwlink/?LinkID=288890 From 1eeb31ace4425c2860a343df053b0a71b50010fc Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 24 Feb 2022 15:58:37 +0300 Subject: [PATCH 47/67] Update ci-build.yml for Azure Pipelines - Adds powershell script to fetch the version number from .csproj - Adds a publish task for publishing hidi as a self-contained .exe application to the artifact staging directory - Publish the generated artifact to the specified location --- .azure-pipelines/ci-build.yml | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index b6944af2f..3fd8eb0b7 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -19,6 +19,13 @@ pool: steps: - task: NuGetCommand@2 displayName: 'NuGet restore' + +- task: UseDotNet@2 + displayName: 'Use .NET Core sdk' + inputs: + packageType: 'sdk' + version: '6.0.x' + includePreviewVersions: true - task: MSBuild@1 displayName: 'Build solution **/*.sln' @@ -127,7 +134,31 @@ steps: ] SessionTimeout: 20 +- task: PowerShell@2 + displayName: "Get Hidi's version-number from .csproj" + inputs: + targetType: 'inline' + script: | + $xml = [Xml] (Get-Content .\src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj) + $version = $xml.Project.PropertyGroup.Version + echo $version + echo "##vso[task.setvariable variable=version]$version" + +# publish hidi as an .exe +- task: DotNetCoreCLI@2 + inputs: + command: 'publish' + arguments: -c Release --runtime win-x64 /p:PublishSingleFile=true --self-contained --output $(Build.ArtifactStagingDirectory) --no-dependencies + projects: 'src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj' + publishWebProjects: False + zipAfterPublish: false + - task: PublishBuildArtifacts@1 displayName: 'Publish Artifact: Nugets' inputs: - ArtifactName: Nugets \ No newline at end of file + ArtifactName: Nugets + +- task: PublishBuildArtifacts@1 + displayName: 'Publish Artifact: Hidi' + inputs: + ArtifactName: Microsoft.OpenApi.Hidi-v$(version) From da6a4d16bdc368b7e6400ece0f153391b91acbf7 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Sun, 27 Feb 2022 15:27:13 +0300 Subject: [PATCH 48/67] Update ci-build.yml for Azure Pipelines --- .azure-pipelines/ci-build.yml | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 3fd8eb0b7..5b1039d03 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -17,9 +17,6 @@ pool: - vstest steps: -- task: NuGetCommand@2 - displayName: 'NuGet restore' - - task: UseDotNet@2 displayName: 'Use .NET Core sdk' inputs: @@ -27,6 +24,9 @@ steps: version: '6.0.x' includePreviewVersions: true +- task: NuGetCommand@2 + displayName: 'NuGet restore' + - task: MSBuild@1 displayName: 'Build solution **/*.sln' inputs: @@ -92,21 +92,21 @@ steps: inputs: solution: src/Microsoft.OpenApi/Microsoft.OpenApi.csproj configuration: Release - msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory) /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg' + msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory)/Nugets /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg' - task: MSBuild@1 displayName: 'Pack OpenAPI Readers' inputs: solution: src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj configuration: Release - msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory) /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg' + msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory)/Nugets /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg' - task: MSBuild@1 displayName: 'Pack OpenApi Hidi' inputs: solution: src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj configuration: Release - msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory) /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg' + msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory)/Nugets /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg' - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 displayName: 'ESRP CodeSigning Nuget Packages' @@ -148,7 +148,7 @@ steps: - task: DotNetCoreCLI@2 inputs: command: 'publish' - arguments: -c Release --runtime win-x64 /p:PublishSingleFile=true --self-contained --output $(Build.ArtifactStagingDirectory) --no-dependencies + arguments: -c Release --runtime win-x64 /p:PublishSingleFile=true --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(version) --no-dependencies projects: 'src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj' publishWebProjects: False zipAfterPublish: false @@ -157,8 +157,10 @@ steps: displayName: 'Publish Artifact: Nugets' inputs: ArtifactName: Nugets + PathtoPublish: '$(Build.ArtifactStagingDirectory)/Nugets' - task: PublishBuildArtifacts@1 displayName: 'Publish Artifact: Hidi' inputs: ArtifactName: Microsoft.OpenApi.Hidi-v$(version) + PathtoPublish: '$(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(version)' From fecd0fe70d9fd6cf4228aaa534c915b722a1925b Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 28 Feb 2022 11:21:44 -0500 Subject: [PATCH 49/67] - upgrades odata conversion lib reference in hidi --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 6 +++--- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index ecd6f19f5..2c745fd70 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -15,13 +15,13 @@ Microsoft.OpenApi.Hidi hidi ./../../artifacts - 0.5.0-preview4 + 0.6.0-preview1 OpenAPI.NET CLI tool for slicing OpenAPI documents © Microsoft Corporation. All rights reserved. OpenAPI .NET https://github.com/Microsoft/OpenAPI.NET -- Publish symbols. +- Upgrades Microsoft.OpenApi.OData to 1.0.10-preview1 Microsoft.OpenApi.Hidi Microsoft.OpenApi.Hidi @@ -37,7 +37,7 @@ - + diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index d7a4f4298..730b8f894 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -206,8 +206,12 @@ public static OpenApiDocument ConvertCsdlToOpenApi(Stream csdl) var settings = new OpenApiConvertSettings() { + AddSingleQuotesForStringParameters = true, + AddEnumDescriptionExtension = true, + DeclarePathParametersOnPathItem = true, EnableKeyAsSegment = true, EnableOperationId = true, + ErrorResponsesAsDefault = false, PrefixEntityTypeNameBeforeKey = true, TagDepth = 2, EnablePagination = true, From cd100d5392b3af1c84e9920a34174e1e351b59f9 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 28 Feb 2022 11:50:23 -0500 Subject: [PATCH 50/67] - fixes conversion tests and makes method async --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 6 +++--- .../Services/OpenApiServiceTests.cs | 13 +++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 730b8f894..e04fa4f3c 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -92,7 +92,7 @@ string filterbycollection version ??= OpenApiSpecVersion.OpenApi3_0; stream = await GetStream(csdl, logger); - document = ConvertCsdlToOpenApi(stream); + document = await ConvertCsdlToOpenApi(stream); } else { @@ -198,10 +198,10 @@ string filterbycollection /// /// The CSDL stream. /// An OpenAPI document. - public static OpenApiDocument ConvertCsdlToOpenApi(Stream csdl) + public static async Task ConvertCsdlToOpenApi(Stream csdl) { using var reader = new StreamReader(csdl); - var csdlText = reader.ReadToEndAsync().GetAwaiter().GetResult(); + var csdlText = await reader.ReadToEndAsync(); var edmModel = CsdlReader.Parse(XElement.Parse(csdlText).CreateReader()); var settings = new OpenApiConvertSettings() diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiServiceTests.cs index 1b94a3557..1c9fd003b 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiServiceTests.cs @@ -3,6 +3,7 @@ using System; using System.IO; +using System.Threading.Tasks; using Microsoft.OpenApi.Hidi; using Microsoft.OpenApi.Services; using Xunit; @@ -12,7 +13,7 @@ namespace Microsoft.OpenApi.Tests.Services public class OpenApiServiceTests { [Fact] - public void ReturnConvertedCSDLFile() + public async Task ReturnConvertedCSDLFile() { // Arrange var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\Todo.xml"); @@ -20,20 +21,20 @@ public void ReturnConvertedCSDLFile() var csdlStream = fileInput.OpenRead(); // Act - var openApiDoc = OpenApiService.ConvertCsdlToOpenApi(csdlStream); - var expectedPathCount = 5; + var openApiDoc = await OpenApiService.ConvertCsdlToOpenApi(csdlStream); + var expectedPathCount = 6; // Assert Assert.NotNull(openApiDoc); Assert.NotEmpty(openApiDoc.Paths); - Assert.Equal(openApiDoc.Paths.Count, expectedPathCount); + Assert.Equal(expectedPathCount, openApiDoc.Paths.Count); } [Theory] [InlineData("Todos.Todo.UpdateTodo",null, 1)] [InlineData("Todos.Todo.ListTodo",null, 1)] [InlineData(null, "Todos.Todo", 4)] - public void ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocument(string operationIds, string tags, int expectedPathCount) + public async Task ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocument(string operationIds, string tags, int expectedPathCount) { // Arrange var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\Todo.xml"); @@ -41,7 +42,7 @@ public void ReturnFilteredOpenApiDocBasedOnOperationIdsAndInputCsdlDocument(stri var csdlStream = fileInput.OpenRead(); // Act - var openApiDoc = OpenApiService.ConvertCsdlToOpenApi(csdlStream); + var openApiDoc = await OpenApiService.ConvertCsdlToOpenApi(csdlStream); var predicate = OpenApiFilterService.CreatePredicate(operationIds, tags); var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(openApiDoc, predicate); From ee063b7e1f95b56c0ca1f005629f6f11e44e738e Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 28 Feb 2022 11:50:38 -0500 Subject: [PATCH 51/67] - fixes outdated unit test data --- test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index f700fee15..263e5dd12 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -358,6 +358,7 @@ namespace Microsoft.OpenApi.Models public const string AuthorizationUrl = "authorizationUrl"; public const string BasePath = "basePath"; public const string Basic = "basic"; + public const string Bearer = "bearer"; public const string BearerFormat = "bearerFormat"; public const string BodyName = "x-bodyName"; public const string Callbacks = "callbacks"; @@ -400,6 +401,7 @@ namespace Microsoft.OpenApi.Models public const string In = "in"; public const string Info = "info"; public const string Items = "items"; + public const string Jwt = "JWT"; public const string License = "license"; public const string Links = "links"; public const string Mapping = "mapping"; @@ -1206,7 +1208,7 @@ namespace Microsoft.OpenApi.Validations.Rules public static Microsoft.OpenApi.Validations.ValidationRule ResponsesMustBeIdentifiedByDefaultOrStatusCode { get; } public static Microsoft.OpenApi.Validations.ValidationRule ResponsesMustContainAtLeastOneResponse { get; } } - [System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.All, AllowMultiple=false, Inherited=false)] + [System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=false)] public class OpenApiRuleAttribute : System.Attribute { public OpenApiRuleAttribute() { } From 92a9eb1e09fb2549fe42b4a071cd54414dd36004 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 28 Feb 2022 16:01:14 -0500 Subject: [PATCH 52/67] - fixes an issue where hidi would not process async --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 1 + src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 2c745fd70..cd8d14132 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -22,6 +22,7 @@ https://github.com/Microsoft/OpenAPI.NET - Upgrades Microsoft.OpenApi.OData to 1.0.10-preview1 +- Fixes an issue where hidi would not process async operations Microsoft.OpenApi.Hidi Microsoft.OpenApi.Hidi diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index e04fa4f3c..1f86e3c06 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -27,7 +27,7 @@ namespace Microsoft.OpenApi.Hidi { public class OpenApiService { - public static async void ProcessOpenApiDocument( + public static async Task ProcessOpenApiDocument( string openapi, string csdl, FileInfo output, From eca913737b6e9e4a02946c16ae01f69356de2353 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 28 Feb 2022 16:02:01 -0500 Subject: [PATCH 53/67] - updates vs code configuration files to be able to debug hidi --- .vscode/launch.json | 2 +- .vscode/tasks.json | 39 +++++++++++++++++++++++++++++++++------ 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index c26bf0c9f..b59349979 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,7 +10,7 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/bin/Debug/netcoreapp3.1/Microsoft.OpenApi.Hidi.dll", + "program": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/bin/Debug/net6.0/Microsoft.OpenApi.Hidi.dll", "args": [], "cwd": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 358fd0e1a..6040a610f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -5,16 +5,43 @@ "tasks": [ { "label": "build", - "type": "shell", - "command": "msbuild", + "command": "dotnet", + "type": "process", + "group": "build", + "args": [ + "build", + "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "test", + "command": "dotnet", + "type": "process", + "group": "test", "args": [ + "test", + "${workspaceFolder}/Microsoft.OpenApi.sln", "/property:GenerateFullPaths=true", - "/t:build" + "/consoleloggerparameters:NoSummary", + "--collect:\"XPlat Code Coverage\"" ], + "problemMatcher": "$msCompile" + }, + { + "label": "watch", + "command": "dotnet", + "type": "process", "group": "build", - "presentation": { - "reveal": "silent" - }, + "args": [ + "watch", + "run", + "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], "problemMatcher": "$msCompile" }, { From 23e3b3276d8de93c064f6eb03c2d6eafb3a36146 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Mon, 28 Feb 2022 19:20:45 -0500 Subject: [PATCH 54/67] Updated versions to preview5 --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- .../Microsoft.OpenApi.Readers.csproj | 4 ++-- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index cd8d14132..ff203cf5d 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -15,7 +15,7 @@ Microsoft.OpenApi.Hidi hidi ./../../artifacts - 0.6.0-preview1 + 0.5.0-preview5 OpenAPI.NET CLI tool for slicing OpenAPI documents © Microsoft Corporation. All rights reserved. OpenAPI .NET diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 1b4542073..b4c41e6aa 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -1,4 +1,4 @@ - + netstandard2.0 true @@ -10,7 +10,7 @@ Microsoft Microsoft.OpenApi.Readers Microsoft.OpenApi.Readers - 1.3.1-preview4 + 1.3.1-preview5 OpenAPI.NET Readers for JSON and YAML documents © Microsoft Corporation. All rights reserved. OpenAPI .NET diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index a1d9cab65..7f3671942 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -11,7 +11,7 @@ Microsoft Microsoft.OpenApi Microsoft.OpenApi - 1.3.1-preview4 + 1.3.1-preview5 .NET models with JSON and YAML writers for OpenAPI specification © Microsoft Corporation. All rights reserved. OpenAPI .NET From 8b2d347a451eac98146424a989c38ef0bf66c6d2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Mar 2022 00:25:51 +0000 Subject: [PATCH 55/67] Bump Moq from 4.16.1 to 4.17.1 Bumps [Moq](https://github.com/moq/moq4) from 4.16.1 to 4.17.1. - [Release notes](https://github.com/moq/moq4/releases) - [Changelog](https://github.com/moq/moq4/blob/main/CHANGELOG.md) - [Commits](https://github.com/moq/moq4/compare/v4.16.1...v4.17.1) --- updated-dependencies: - dependency-name: Moq dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index de827c62f..1dd8c21b6 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -17,7 +17,7 @@ - + From 656697e9b95d4ffabf17e4b1a3b5ae6387777171 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Mar 2022 12:23:38 +0000 Subject: [PATCH 56/67] Bump actions/setup-dotnet from 1 to 2 Bumps [actions/setup-dotnet](https://github.com/actions/setup-dotnet) from 1 to 2. - [Release notes](https://github.com/actions/setup-dotnet/releases) - [Commits](https://github.com/actions/setup-dotnet/compare/v1...v2) --- updated-dependencies: - dependency-name: actions/setup-dotnet dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci-cd.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 34647ed31..6f619ca85 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -14,7 +14,7 @@ jobs: GITHUB_RUN_NUMBER: ${{ github.run_number }} steps: - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v2 with: dotnet-version: 6.0.x diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 833635651..1d2d4106d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -17,7 +17,7 @@ jobs: uses: actions/checkout@v2 - name: Setup .NET - uses: actions/setup-dotnet@v1 + uses: actions/setup-dotnet@v2 with: dotnet-version: 6.0.x From be7861dd02a1b2d50ae3cbfed2148fa04b898791 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Mar 2022 12:23:43 +0000 Subject: [PATCH 57/67] Bump Verify from 16.1.2 to 16.3.2 Bumps [Verify](https://github.com/VerifyTests/Verify) from 16.1.2 to 16.3.2. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/16.1.2...16.3.2) --- updated-dependencies: - dependency-name: Verify dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 1dd8c21b6..67e5c009d 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -20,7 +20,7 @@ - + From 93d79155de2de0af4a1cf9d1a1a9b401a99db622 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Mar 2022 12:25:53 +0000 Subject: [PATCH 58/67] Bump Verify.Xunit from 16.1.2 to 16.3.2 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 16.1.2 to 16.3.2. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/16.1.2...16.3.2) --- updated-dependencies: - dependency-name: Verify.Xunit dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 67e5c009d..360eeea92 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -21,7 +21,7 @@ - + all From 2ecd4625d517349997fa567e30b849e87cac6616 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 28 Feb 2022 10:39:20 -0500 Subject: [PATCH 59/67] - ADO pipeline updates --- .azure-pipelines/ci-build.yml | 399 +++++++++++++++++++++------------- 1 file changed, 251 insertions(+), 148 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 5b1039d03..18ae1a889 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -16,151 +16,254 @@ pool: - msbuild - vstest -steps: -- task: UseDotNet@2 - displayName: 'Use .NET Core sdk' - inputs: - packageType: 'sdk' - version: '6.0.x' - includePreviewVersions: true - -- task: NuGetCommand@2 - displayName: 'NuGet restore' - -- task: MSBuild@1 - displayName: 'Build solution **/*.sln' - inputs: - configuration: Release - -- task: VSTest@2 - displayName: 'XUnit Tests' - inputs: - testAssemblyVer2: | - **\*.Tests.dll - - vsTestVersion: 16.0 - codeCoverageEnabled: true - -- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - displayName: 'ESRP CodeSigning' - inputs: - ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)' - FolderPath: src - signConfigType: inlineSignParams - inlineOperation: | - [ - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolSign", - "parameters": [ - { - "parameterName": "OpusName", - "parameterValue": "Microsoft" - }, - { - "parameterName": "OpusInfo", - "parameterValue": "http://www.microsoft.com" - }, - { - "parameterName": "FileDigest", - "parameterValue": "/fd \"SHA256\"" - }, - { - "parameterName": "PageHash", - "parameterValue": "/NPH" - }, - { - "parameterName": "TimeStamp", - "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" - } - ], - "toolName": "sign", - "toolVersion": "1.0" - }, - { - "keyCode": "CP-230012", - "operationSetCode": "SigntoolVerify", - "parameters": [ ], - "toolName": "sign", - "toolVersion": "1.0" - } - ] - SessionTimeout: 20 - -- task: MSBuild@1 - displayName: 'Pack OpenAPI' - inputs: - solution: src/Microsoft.OpenApi/Microsoft.OpenApi.csproj - configuration: Release - msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory)/Nugets /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg' - -- task: MSBuild@1 - displayName: 'Pack OpenAPI Readers' - inputs: - solution: src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj - configuration: Release - msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory)/Nugets /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg' - -- task: MSBuild@1 - displayName: 'Pack OpenApi Hidi' - inputs: - solution: src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj - configuration: Release - msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory)/Nugets /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg' - -- task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 - displayName: 'ESRP CodeSigning Nuget Packages' - inputs: - ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)' - FolderPath: '$(Build.ArtifactStagingDirectory)' - Pattern: '*.nupkg' - signConfigType: inlineSignParams - inlineOperation: | - [ - { - "keyCode": "CP-401405", - "operationSetCode": "NuGetSign", - "parameters": [ ], - "toolName": "sign", - "toolVersion": "1.0" - }, - { - "keyCode": "CP-401405", - "operationSetCode": "NuGetVerify", - "parameters": [ ], - "toolName": "sign", - "toolVersion": "1.0" - } - ] - SessionTimeout: 20 - -- task: PowerShell@2 - displayName: "Get Hidi's version-number from .csproj" - inputs: - targetType: 'inline' - script: | - $xml = [Xml] (Get-Content .\src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj) - $version = $xml.Project.PropertyGroup.Version - echo $version - echo "##vso[task.setvariable variable=version]$version" - -# publish hidi as an .exe -- task: DotNetCoreCLI@2 - inputs: - command: 'publish' - arguments: -c Release --runtime win-x64 /p:PublishSingleFile=true --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(version) --no-dependencies - projects: 'src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj' - publishWebProjects: False - zipAfterPublish: false - -- task: PublishBuildArtifacts@1 - displayName: 'Publish Artifact: Nugets' - inputs: - ArtifactName: Nugets - PathtoPublish: '$(Build.ArtifactStagingDirectory)/Nugets' - -- task: PublishBuildArtifacts@1 - displayName: 'Publish Artifact: Hidi' - inputs: - ArtifactName: Microsoft.OpenApi.Hidi-v$(version) - PathtoPublish: '$(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(version)' +variables: + buildPlatform: 'Any CPU' + buildConfiguration: 'Release' + ProductBinPath: '$(Build.SourcesDirectory)\bin\$(BuildConfiguration)' + + +stages: + +- stage: build + jobs: + - job: build + steps: + - task: UseDotNet@2 + displayName: 'Use .NET 6' + inputs: + version: 6.x + + - task: PoliCheck@1 + displayName: 'Run PoliCheck "/src"' + inputs: + inputType: CmdLine + cmdLineArgs: '/F:$(Build.SourcesDirectory)/src /T:9 /Sev:"1|2" /PE:2 /O:poli_result_src.xml' + + - task: PoliCheck@1 + displayName: 'Run PoliCheck "/test"' + inputs: + inputType: CmdLine + cmdLineArgs: '/F:$(Build.SourcesDirectory)/test /T:9 /Sev:"1|2" /PE:2 /O:poli_result_test.xml' + + - task: PoliCheck@1 + displayName: 'PoliCheck for /tool' + inputs: + inputType: CmdLine + cmdLineArgs: '/F:$(Build.SourcesDirectory)/tool /T:9 /Sev:"1|2" /PE:2 /O:poli_result_tool.xml' + + # Install the nuget tool. + - task: NuGetToolInstaller@0 + displayName: 'Use NuGet >=5.2.0' + inputs: + versionSpec: '>=5.2.0' + checkLatest: true + + # Build the Product project + - task: DotNetCoreCLI@2 + displayName: 'build' + inputs: + projects: '$(Build.SourcesDirectory)\Microsoft.OpenApi.sln' + arguments: '--configuration $(BuildConfiguration) --no-incremental' + + # Run the Unit test + - task: DotNetCoreCLI@2 + displayName: 'test' + inputs: + command: test + projects: '$(Build.SourcesDirectory)\Microsoft.OpenApi.sln' + arguments: '--configuration $(BuildConfiguration) --no-build' + + # CredScan + - task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2 + displayName: 'Run CredScan - Src' + inputs: + toolMajorVersion: 'V2' + scanFolder: '$(Build.SourcesDirectory)\src' + debugMode: false + + - task: securedevelopmentteam.vss-secure-development-tools.build-task-credscan.CredScan@2 + displayName: 'Run CredScan - Test' + inputs: + toolMajorVersion: 'V2' + scanFolder: '$(Build.SourcesDirectory)\test' + debugMode: false + + - task: AntiMalware@3 + displayName: 'Run MpCmdRun.exe - ProductBinPath' + inputs: + FileDirPath: '$(ProductBinPath)' + enabled: false + + - task: BinSkim@3 + displayName: 'Run BinSkim - Product Binaries' + inputs: + InputType: Basic + AnalyzeTarget: '$(ProductBinPath)\**\Microsoft.OpenApi.dll' + AnalyzeSymPath: '$(ProductBinPath)' + AnalyzeVerbose: true + AnalyzeHashes: true + AnalyzeEnvironment: true + + - task: PublishSecurityAnalysisLogs@2 + displayName: 'Publish Security Analysis Logs' + inputs: + ArtifactName: SecurityLogs + + - task: PostAnalysis@1 + displayName: 'Post Analysis' + inputs: + BinSkim: true + CredScan: true + PoliCheck: true + + - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + displayName: 'ESRP CodeSigning' + inputs: + ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)' + FolderPath: src + signConfigType: inlineSignParams + inlineOperation: | + [ + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolSign", + "parameters": [ + { + "parameterName": "OpusName", + "parameterValue": "Microsoft" + }, + { + "parameterName": "OpusInfo", + "parameterValue": "http://www.microsoft.com" + }, + { + "parameterName": "FileDigest", + "parameterValue": "/fd \"SHA256\"" + }, + { + "parameterName": "PageHash", + "parameterValue": "/NPH" + }, + { + "parameterName": "TimeStamp", + "parameterValue": "/tr \"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\" /td sha256" + } + ], + "toolName": "sign", + "toolVersion": "1.0" + }, + { + "keyCode": "CP-230012", + "operationSetCode": "SigntoolVerify", + "parameters": [ ], + "toolName": "sign", + "toolVersion": "1.0" + } + ] + SessionTimeout: 20 + + # Pack + - task: DotNetCoreCLI@2 + displayName: 'pack OpenAPI' + inputs: + command: pack + projects: src/Microsoft.OpenApi/Microsoft.OpenApi.csproj + arguments: '-o $(Build.ArtifactStagingDirectory)/Nugets --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg' + + # Pack + - task: DotNetCoreCLI@2 + displayName: 'pack Readers' + inputs: + command: pack + projects: src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj + arguments: '-o $(Build.ArtifactStagingDirectory)/Nugets --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg' + + # Pack + - task: DotNetCoreCLI@2 + displayName: 'pack Hidi' + inputs: + command: pack + projects: src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj + arguments: '-o $(Build.ArtifactStagingDirectory)/Nugets --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg' + + - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 + displayName: 'ESRP CodeSigning Nuget Packages' + inputs: + ConnectedServiceName: 'microsoftgraph ESRP CodeSign DLL and NuGet (AKV)' + FolderPath: '$(Build.ArtifactStagingDirectory)' + Pattern: '*.nupkg' + signConfigType: inlineSignParams + inlineOperation: | + [ + { + "keyCode": "CP-401405", + "operationSetCode": "NuGetSign", + "parameters": [ ], + "toolName": "sign", + "toolVersion": "1.0" + }, + { + "keyCode": "CP-401405", + "operationSetCode": "NuGetVerify", + "parameters": [ ], + "toolName": "sign", + "toolVersion": "1.0" + } + ] + SessionTimeout: 20 + + - task: PowerShell@2 + displayName: "Get Hidi's version-number from .csproj" + inputs: + targetType: 'inline' + script: | + $xml = [Xml] (Get-Content .\src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj) + $version = $xml.Project.PropertyGroup.Version + echo $version + echo "##vso[task.setvariable variable=version]$version" + + # publish hidi as an .exe + - task: DotNetCoreCLI@2 + inputs: + command: 'publish' + arguments: -c Release --runtime win-x64 /p:PublishSingleFile=true --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(version) --no-dependencies + projects: 'src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj' + publishWebProjects: False + zipAfterPublish: false + + - task: PublishBuildArtifacts@1 + displayName: 'Publish Artifact: Hidi' + inputs: + ArtifactName: Microsoft.OpenApi.Hidi-v$(version) + PathtoPublish: '$(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(version)' + + - task: PublishBuildArtifacts@1 + displayName: 'Publish Artifact: Nugets' + inputs: + ArtifactName: Nugets + PathtoPublish: '$(Build.ArtifactStagingDirectory)/Nugets' + +- stage: deploy + condition: and(contains(variables['build.sourceBranch'], 'refs/heads/vnext'), succeeded()) + dependsOn: build + jobs: + - deployment: deploy + environment: nuget-org + strategy: + runOnce: + deploy: + pool: + vmImage: ubuntu-latest + steps: + - task: DownloadPipelineArtifact@2 + displayName: Download nupkg from artifacts + inputs: + artifact: Nugets + source: current + - task: NuGetCommand@2 + displayName: 'NuGet push' + inputs: + command: push + packagesToPush: '$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.*.nupkg' + nuGetFeedType: external + publishFeedCredentials: 'OpenAPI Nuget Connection' From 8a0ef11069954de808c9ef8e8d63fe87b0477e79 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 28 Feb 2022 13:22:20 -0500 Subject: [PATCH 60/67] - removes policheck on inexistant tool directory --- .azure-pipelines/ci-build.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 18ae1a889..6d240e7a1 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -45,12 +45,6 @@ stages: inputType: CmdLine cmdLineArgs: '/F:$(Build.SourcesDirectory)/test /T:9 /Sev:"1|2" /PE:2 /O:poli_result_test.xml' - - task: PoliCheck@1 - displayName: 'PoliCheck for /tool' - inputs: - inputType: CmdLine - cmdLineArgs: '/F:$(Build.SourcesDirectory)/tool /T:9 /Sev:"1|2" /PE:2 /O:poli_result_tool.xml' - # Install the nuget tool. - task: NuGetToolInstaller@0 displayName: 'Use NuGet >=5.2.0' From a2e516fb722f7c5c23adb0c2946c3b03ae23c550 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 28 Feb 2022 15:11:00 -0500 Subject: [PATCH 61/67] - fixes dll path for binskim analysis Signed-off-by: Vincent Biret --- .azure-pipelines/ci-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 6d240e7a1..6e5fcda45 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -19,7 +19,7 @@ pool: variables: buildPlatform: 'Any CPU' buildConfiguration: 'Release' - ProductBinPath: '$(Build.SourcesDirectory)\bin\$(BuildConfiguration)' + ProductBinPath: '$(Build.SourcesDirectory)\src\Microsoft.OpenApi\bin\$(BuildConfiguration)' stages: From 0db148383cca625eb2cc791cfb7981a5e9f3f55a Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 1 Mar 2022 08:13:31 -0500 Subject: [PATCH 62/67] - adds PR trigger for pipeline Signed-off-by: Vincent Biret --- .azure-pipelines/ci-build.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 6e5fcda45..aa400b7b3 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -7,14 +7,16 @@ trigger: branches: include: - master -pr: none + - vnext +pr: + branches: + include: + - master + - vnext pool: name: Azure Pipelines vmImage: windows-latest - demands: - - msbuild - - vstest variables: buildPlatform: 'Any CPU' From f31d6bcbb7054b4999dedd51fb0d47821b01b59e Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 1 Mar 2022 08:44:32 -0500 Subject: [PATCH 63/67] - moves to separate jobs for each nupkg Signed-off-by: Vincent Biret --- .azure-pipelines/ci-build.yml | 98 +++++++++++++++++++++++++++++++---- 1 file changed, 89 insertions(+), 9 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index aa400b7b3..ea7703c76 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -216,34 +216,36 @@ stages: $xml = [Xml] (Get-Content .\src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj) $version = $xml.Project.PropertyGroup.Version echo $version - echo "##vso[task.setvariable variable=version]$version" + echo "##vso[task.setvariable variable=hidiversion]$version" # publish hidi as an .exe - task: DotNetCoreCLI@2 + displayName: publish Hidi as executable inputs: command: 'publish' - arguments: -c Release --runtime win-x64 /p:PublishSingleFile=true --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(version) --no-dependencies + arguments: -c Release --runtime win-x64 /p:PublishSingleFile=true --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(hidiversion) --no-dependencies projects: 'src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj' publishWebProjects: False zipAfterPublish: false - - task: PublishBuildArtifacts@1 - displayName: 'Publish Artifact: Hidi' - inputs: - ArtifactName: Microsoft.OpenApi.Hidi-v$(version) - PathtoPublish: '$(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(version)' - - task: PublishBuildArtifacts@1 displayName: 'Publish Artifact: Nugets' inputs: ArtifactName: Nugets PathtoPublish: '$(Build.ArtifactStagingDirectory)/Nugets' + - task: PublishBuildArtifacts@1 + displayName: 'Publish Artifact: Hidi' + inputs: + ArtifactName: Microsoft.OpenApi.Hidi-v$(hidiversion) + PathtoPublish: '$(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(hidiversion)' + - stage: deploy condition: and(contains(variables['build.sourceBranch'], 'refs/heads/vnext'), succeeded()) dependsOn: build jobs: - - deployment: deploy + - deployment: deploy_hidi + dependsOn: [] environment: nuget-org strategy: runOnce: @@ -256,6 +258,62 @@ stages: inputs: artifact: Nugets source: current + # TODO update that script so it looks at the artifact name (name starts with) rather than a fixed index + - powershell: | + $url = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$env:SYSTEM_TEAMPROJECTID/_apis/build/builds/$env:BUILD_BUILDID/artifacts?api-version=4.1" + Write-Host "URL: $url" + $pipeline = Invoke-RestMethod -Uri $url -Headers @{ + Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN" + } + Write-Host "artifactName:" ($artifactName = $Pipeline.value.name[1]) + #Set Variable $artifactName + Write-Host "##vso[task.setvariable variable=artifactName; isSecret=false; isOutput=true;]$artifactName" + displayName: 'Fetch Artifact Name' + - task: DownloadPipelineArtifact@2 + displayName: Download hidi executable from artifacts + inputs: + artifact: $(artifactName) + source: current + - task: NuGetCommand@2 + displayName: 'NuGet push' + inputs: + command: push + packagesToPush: '$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Hidi.*.nupkg' + nuGetFeedType: external + publishFeedCredentials: 'OpenAPI Nuget Connection' + - task: GitHubRelease@1 + displayName: 'GitHub release (create)' + inputs: + gitHubConnection: 'Github-MaggieKimani1' + tagSource: userSpecifiedTag + tag: '$(artifactName)' + title: '$(artifactName)' + releaseNotesSource: inline + assets: '$(System.DefaultWorkingDirectory)\**\*.exe' + changeLogType: issueBased + + - deployment: deploy_lib + dependsOn: [] + environment: nuget-org + strategy: + runOnce: + deploy: + pool: + vmImage: ubuntu-latest + steps: + - task: DownloadPipelineArtifact@2 + displayName: Download nupkg from artifacts + inputs: + artifact: Nugets + source: current + - powershell: | + $fileNames = "$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Hidi.*.nupkg", "$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Readers.*.nupkg", "$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Workbench.*.nupkg" + foreach($fileName in $fileNames) { + if(Test-Path $fileName) { + rm $fileName -Verbose + } + } + displayName: remove other nupkgs to avoid duplication - task: NuGetCommand@2 displayName: 'NuGet push' inputs: @@ -263,3 +321,25 @@ stages: packagesToPush: '$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.*.nupkg' nuGetFeedType: external publishFeedCredentials: 'OpenAPI Nuget Connection' + + - deployment: deploy_readers + dependsOn: deploy_lib + environment: nuget-org + strategy: + runOnce: + deploy: + pool: + vmImage: ubuntu-latest + steps: + - task: DownloadPipelineArtifact@2 + displayName: Download nupkg from artifacts + inputs: + artifact: Nugets + source: current + - task: NuGetCommand@2 + displayName: 'NuGet push' + inputs: + command: push + packagesToPush: '$(Pipeline.Workspace)/Nugets/Microsoft.OpenApi.Readers.*.nupkg' + nuGetFeedType: external + publishFeedCredentials: 'OpenAPI Nuget Connection' From 1127aedfe6d2ab6029b6c0e5e12474dbea99e86e Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 1 Mar 2022 08:47:14 -0500 Subject: [PATCH 64/67] - adds a copy task to align folder nams Signed-off-by: Vincent Biret --- .azure-pipelines/ci-build.yml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index ea7703c76..fa26c2519 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -164,7 +164,7 @@ stages: inputs: command: pack projects: src/Microsoft.OpenApi/Microsoft.OpenApi.csproj - arguments: '-o $(Build.ArtifactStagingDirectory)/Nugets --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg' + arguments: '-o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg' # Pack - task: DotNetCoreCLI@2 @@ -172,7 +172,7 @@ stages: inputs: command: pack projects: src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj - arguments: '-o $(Build.ArtifactStagingDirectory)/Nugets --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg' + arguments: '-o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg' # Pack - task: DotNetCoreCLI@2 @@ -180,7 +180,7 @@ stages: inputs: command: pack projects: src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj - arguments: '-o $(Build.ArtifactStagingDirectory)/Nugets --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg' + arguments: '-o $(Build.ArtifactStagingDirectory) --configuration $(BuildConfiguration) --no-build --include-symbols --include-source /p:SymbolPackageFormat=snupkg' - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 displayName: 'ESRP CodeSigning Nuget Packages' @@ -228,6 +228,13 @@ stages: publishWebProjects: False zipAfterPublish: false + - task: CopyFile@2 + displayName: Prepare staging folder for upload + inputs: + targetFolder: $(Build.ArtifactStagingDirectory)/Nugets + sourceFolder: $(Build.ArtifactStagingDirectory) + content: '*.nupkg' + - task: PublishBuildArtifacts@1 displayName: 'Publish Artifact: Nugets' inputs: From 8431e6e40cff64eb2b5945f9c858d206f5de03a6 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 1 Mar 2022 08:47:58 -0500 Subject: [PATCH 65/67] - fixes task name Signed-off-by: Vincent Biret --- .azure-pipelines/ci-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index fa26c2519..41a71ee62 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -228,7 +228,7 @@ stages: publishWebProjects: False zipAfterPublish: false - - task: CopyFile@2 + - task: CopyFiles@2 displayName: Prepare staging folder for upload inputs: targetFolder: $(Build.ArtifactStagingDirectory)/Nugets From 1752217130fe675470fe1b53e37598fba452ef00 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 1 Mar 2022 10:40:59 -0800 Subject: [PATCH 66/67] - enables trimming for hidi executable Co-authored-by: Maggie Kimani --- .azure-pipelines/ci-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 41a71ee62..35633cb2f 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -223,7 +223,7 @@ stages: displayName: publish Hidi as executable inputs: command: 'publish' - arguments: -c Release --runtime win-x64 /p:PublishSingleFile=true --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(hidiversion) --no-dependencies + arguments: -c Release --runtime win-x64 /p:PublishSingleFile=true --self-contained --output $(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(hidiversion) -p:PublishTrimmed=true projects: 'src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj' publishWebProjects: False zipAfterPublish: false From 75267c216e5f5e5f3224cf714406301b36cb9410 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 3 Mar 2022 13:09:29 -0500 Subject: [PATCH 67/67] - bumps reference to openapi.odata --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index ff203cf5d..e33f4777e 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -38,7 +38,7 @@ - +