From a29d4423543cc7a0ab79a1016e77404b3bc03784 Mon Sep 17 00:00:00 2001 From: Peter Ritchie Date: Fri, 2 Jul 2021 17:53:40 -0700 Subject: [PATCH 001/288] Made OpenApiVisitorBase Enter() and Exit() virtual, plus test --- .../Services/OpenApiVisitorBase.cs | 4 +- .../Visitors/InheritanceTests.cs | 346 ++++++++++++++++++ 2 files changed, 348 insertions(+), 2 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs diff --git a/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs b/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs index bc65fdfc2..c9679381a 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiVisitorBase.cs @@ -25,7 +25,7 @@ public abstract class OpenApiVisitorBase /// Allow Rule to indicate validation error occured at a deeper context level. /// /// Identifier for context - public void Enter(string segment) + public virtual void Enter(string segment) { this._path.Push(segment); } @@ -33,7 +33,7 @@ public void Enter(string segment) /// /// Exit from path context elevel. Enter and Exit calls should be matched. /// - public void Exit() + public virtual void Exit() { this._path.Pop(); } diff --git a/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs b/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs new file mode 100644 index 000000000..102100019 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Visitors/InheritanceTests.cs @@ -0,0 +1,346 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; +using Microsoft.OpenApi.Interfaces; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Services; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Visitors +{ + public class InheritanceTests + { + [Fact] + public void ExpectedVirtualsInvolved() + { + OpenApiVisitorBase visitor = null; + + visitor = new TestVisitor(); + + visitor.Enter(default(string)); + visitor.Visit(default(OpenApiDocument)); + visitor.Visit(default(OpenApiInfo)); + visitor.Visit(default(OpenApiContact)); + visitor.Visit(default(OpenApiLicense)); + visitor.Visit(default(IList)); + visitor.Visit(default(OpenApiServer)); + visitor.Visit(default(OpenApiPaths)); + visitor.Visit(default(OpenApiPathItem)); + visitor.Visit(default(OpenApiServerVariable)); + visitor.Visit(default(IDictionary)); + visitor.Visit(default(OpenApiOperation)); + visitor.Visit(default(IList)); + visitor.Visit(default(OpenApiParameter)); + visitor.Visit(default(OpenApiRequestBody)); + visitor.Visit(default(IDictionary)); + visitor.Visit(default(IDictionary)); + visitor.Visit(default(OpenApiResponse)); + visitor.Visit(default(OpenApiResponses)); + visitor.Visit(default(IDictionary)); + visitor.Visit(default(OpenApiMediaType)); + visitor.Visit(default(OpenApiEncoding)); + visitor.Visit(default(IDictionary)); + visitor.Visit(default(OpenApiComponents)); + visitor.Visit(default(OpenApiExternalDocs)); + visitor.Visit(default(OpenApiSchema)); + visitor.Visit(default(IDictionary)); + visitor.Visit(default(OpenApiLink)); + visitor.Visit(default(OpenApiCallback)); + visitor.Visit(default(OpenApiTag)); + visitor.Visit(default(OpenApiHeader)); + visitor.Visit(default(OpenApiOAuthFlow)); + visitor.Visit(default(OpenApiSecurityRequirement)); + visitor.Visit(default(OpenApiSecurityScheme)); + visitor.Visit(default(OpenApiExample)); + visitor.Visit(default(IList)); + visitor.Visit(default(IList)); + visitor.Visit(default(IOpenApiExtensible)); + visitor.Visit(default(IOpenApiExtension)); + visitor.Visit(default(IList)); + visitor.Visit(default(IDictionary)); + visitor.Visit(default(IDictionary)); + visitor.Visit(default(IOpenApiReferenceable)); + visitor.Exit(); + Assert.True(42 < ((TestVisitor)visitor).CallStack.Count()); + } + + internal protected class TestVisitor : OpenApiVisitorBase + { + public Stack CallStack { get; } = new Stack(); + + private string EncodeCall([CallerMemberName] string name="", [CallerLineNumber]int lineNumber = 0) + { + var encoding = $"{name}:{lineNumber}"; + CallStack.Push(encoding); + return encoding; + } + + public override void Enter(string segment) + { + EncodeCall(); + base.Enter(segment); + } + + public override void Exit() + { + EncodeCall(); + base.Exit(); + } + + public override void Visit(OpenApiDocument doc) + { + EncodeCall(); + base.Visit(doc); + } + + public override void Visit(OpenApiInfo info) + { + EncodeCall(); + base.Visit(info); + } + + public override void Visit(OpenApiContact contact) + { + EncodeCall(); + base.Visit(contact); + } + + public override void Visit(OpenApiLicense license) + { + EncodeCall(); + base.Visit(license); + } + + public override void Visit(IList servers) + { + EncodeCall(); + base.Visit(servers); + } + + public override void Visit(OpenApiServer server) + { + EncodeCall(); + base.Visit(server); + } + + public override void Visit(OpenApiPaths paths) + { + EncodeCall(); + base.Visit(paths); + } + + public override void Visit(OpenApiPathItem pathItem) + { + EncodeCall(); + base.Visit(pathItem); + } + + public override void Visit(OpenApiServerVariable serverVariable) + { + EncodeCall(); + base.Visit(serverVariable); + } + + public override void Visit(IDictionary operations) + { + EncodeCall(); + base.Visit(operations); + } + + public override void Visit(OpenApiOperation operation) + { + EncodeCall(); + base.Visit(operation); + } + + public override void Visit(IList parameters) + { + EncodeCall(); + base.Visit(parameters); + } + + public override void Visit(OpenApiParameter parameter) + { + EncodeCall(); + base.Visit(parameter); + } + + public override void Visit(OpenApiRequestBody requestBody) + { + EncodeCall(); + base.Visit(requestBody); + } + + public override void Visit(IDictionary headers) + { + EncodeCall(); + base.Visit(headers); + } + + public override void Visit(IDictionary callbacks) + { + EncodeCall(); + base.Visit(callbacks); + } + + public override void Visit(OpenApiResponse response) + { + EncodeCall(); + base.Visit(response); + } + + public override void Visit(OpenApiResponses response) + { + EncodeCall(); + base.Visit(response); + } + + public override void Visit(IDictionary content) + { + EncodeCall(); + base.Visit(content); + } + + public override void Visit(OpenApiMediaType mediaType) + { + EncodeCall(); + base.Visit(mediaType); + } + + public override void Visit(OpenApiEncoding encoding) + { + EncodeCall(); + base.Visit(encoding); + } + + public override void Visit(IDictionary examples) + { + EncodeCall(); + base.Visit(examples); + } + + public override void Visit(OpenApiComponents components) + { + EncodeCall(); + base.Visit(components); + } + + public override void Visit(OpenApiExternalDocs externalDocs) + { + EncodeCall(); + base.Visit(externalDocs); + } + + public override void Visit(OpenApiSchema schema) + { + EncodeCall(); + base.Visit(schema); + } + + public override void Visit(IDictionary links) + { + EncodeCall(); + base.Visit(links); + } + + public override void Visit(OpenApiLink link) + { + EncodeCall(); + base.Visit(link); + } + + public override void Visit(OpenApiCallback callback) + { + EncodeCall(); + base.Visit(callback); + } + + public override void Visit(OpenApiTag tag) + { + EncodeCall(); + base.Visit(tag); + } + + public override void Visit(OpenApiHeader tag) + { + EncodeCall(); + base.Visit(tag); + } + + public override void Visit(OpenApiOAuthFlow openApiOAuthFlow) + { + EncodeCall(); + base.Visit(openApiOAuthFlow); + } + + public override void Visit(OpenApiSecurityRequirement securityRequirement) + { + EncodeCall(); + base.Visit(securityRequirement); + } + + public override void Visit(OpenApiSecurityScheme securityScheme) + { + EncodeCall(); + base.Visit(securityScheme); + } + + public override void Visit(OpenApiExample example) + { + EncodeCall(); + base.Visit(example); + } + + public override void Visit(IList openApiTags) + { + EncodeCall(); + base.Visit(openApiTags); + } + + public override void Visit(IList openApiSecurityRequirements) + { + EncodeCall(); + base.Visit(openApiSecurityRequirements); + } + + public override void Visit(IOpenApiExtensible openApiExtensible) + { + EncodeCall(); + base.Visit(openApiExtensible); + } + + public override void Visit(IOpenApiExtension openApiExtension) + { + EncodeCall(); + base.Visit(openApiExtension); + } + + public override void Visit(IList example) + { + EncodeCall(); + base.Visit(example); + } + + public override void Visit(IDictionary serverVariables) + { + EncodeCall(); + base.Visit(serverVariables); + } + + public override void Visit(IDictionary encodings) + { + EncodeCall(); + base.Visit(encodings); + } + + public override void Visit(IOpenApiReferenceable referenceable) + { + EncodeCall(); + base.Visit(referenceable); + } + } + } +} From 549111afeed29dadfecc988b9b0edbb7b5819c2c Mon Sep 17 00:00:00 2001 From: Peter Ritchie Date: Fri, 2 Jul 2021 18:13:54 -0700 Subject: [PATCH 002/288] updated Public.approved.txt file to include two methods now being virtual --- test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index d5a89e586..7ff59d492 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -979,8 +979,8 @@ namespace Microsoft.OpenApi.Services protected OpenApiVisitorBase() { } public Microsoft.OpenApi.Services.CurrentKeys CurrentKeys { get; } public string PathString { get; } - public void Enter(string segment) { } - public void Exit() { } + public virtual void Enter(string segment) { } + public virtual void Exit() { } public virtual void Visit(Microsoft.OpenApi.Interfaces.IOpenApiExtensible openApiExtensible) { } public virtual void Visit(Microsoft.OpenApi.Interfaces.IOpenApiExtension openApiExtension) { } public virtual void Visit(Microsoft.OpenApi.Interfaces.IOpenApiReferenceable referenceable) { } From 45968f3263f39206bc31dbf9f8488e1991a380cf Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sun, 15 Aug 2021 13:34:03 -0400 Subject: [PATCH 003/288] Can validate external references now --- .../OpenApiYamlDocumentReader.cs | 6 +- .../Services/DefaultStreamLoader.cs | 21 ++++-- .../V3/OpenApiV3VersionService.cs | 20 +++++- src/Microsoft.OpenApi.Tool/OpenApiService.cs | 71 ++++++++++++++----- src/Microsoft.OpenApi.Tool/Program.cs | 5 +- .../Models/OpenApiReference.cs | 18 +++-- .../OpenApiWorkspaceStreamTests.cs | 5 +- .../Models/OpenApiReferenceTests.cs | 54 ++++++++++---- 8 files changed, 150 insertions(+), 50 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs index bb00fb370..63b78ccba 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs @@ -88,7 +88,7 @@ public async Task ReadAsync(YamlDocument input) // Parse the OpenAPI Document document = context.Parse(input); - await ResolveReferencesAsync(diagnostic, document); + await ResolveReferencesAsync(diagnostic, document, _settings.BaseUrl); } catch (OpenApiException ex) { @@ -133,7 +133,7 @@ private void ResolveReferences(OpenApiDiagnostic diagnostic, OpenApiDocument doc } } - private async Task ResolveReferencesAsync(OpenApiDiagnostic diagnostic, OpenApiDocument document) + private async Task ResolveReferencesAsync(OpenApiDiagnostic diagnostic, OpenApiDocument document, Uri baseUrl) { List errors = new List(); @@ -146,7 +146,7 @@ private async Task ResolveReferencesAsync(OpenApiDiagnostic diagnostic, OpenApiD var openApiWorkSpace = new OpenApiWorkspace(); // Load this root document into the workspace - var streamLoader = new DefaultStreamLoader(); + var streamLoader = new DefaultStreamLoader(baseUrl); var workspaceLoader = new OpenApiWorkspaceLoader(openApiWorkSpace, _settings.CustomExternalLoader ?? streamLoader, _settings); await workspaceLoader.LoadAsync(new OpenApiReference() { ExternalResource = "/" }, document); diff --git a/src/Microsoft.OpenApi.Readers/Services/DefaultStreamLoader.cs b/src/Microsoft.OpenApi.Readers/Services/DefaultStreamLoader.cs index 4659db711..09f16632b 100644 --- a/src/Microsoft.OpenApi.Readers/Services/DefaultStreamLoader.cs +++ b/src/Microsoft.OpenApi.Readers/Services/DefaultStreamLoader.cs @@ -14,18 +14,25 @@ namespace Microsoft.OpenApi.Readers.Services /// internal class DefaultStreamLoader : IStreamLoader { + private readonly Uri baseUrl; private HttpClient _httpClient = new HttpClient(); + + public DefaultStreamLoader(Uri baseUrl) + { + this.baseUrl = baseUrl; + } + public Stream Load(Uri uri) { + var absoluteUri = new Uri(baseUrl, uri); switch (uri.Scheme) { case "file": - return File.OpenRead(uri.AbsolutePath); + return File.OpenRead(absoluteUri.AbsolutePath); case "http": case "https": - return _httpClient.GetStreamAsync(uri).GetAwaiter().GetResult(); - + return _httpClient.GetStreamAsync(absoluteUri).GetAwaiter().GetResult(); default: throw new ArgumentException("Unsupported scheme"); } @@ -33,13 +40,15 @@ public Stream Load(Uri uri) public async Task LoadAsync(Uri uri) { - switch (uri.Scheme) + var absoluteUri = new Uri(baseUrl, uri); + + switch (absoluteUri.Scheme) { case "file": - return File.OpenRead(uri.AbsolutePath); + return File.OpenRead(absoluteUri.AbsolutePath); case "http": case "https": - return await _httpClient.GetStreamAsync(uri); + return await _httpClient.GetStreamAsync(absoluteUri); default: throw new ArgumentException("Unsupported scheme"); } diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs index 2663b6a3b..1a0b1bae2 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs @@ -53,6 +53,8 @@ internal class OpenApiV3VersionService : IOpenApiVersionService /// /// Parse the string to a object. /// + /// The URL of the reference + /// The type of object refefenced based on the context of the reference public OpenApiReference ConvertToOpenApiReference( string reference, ReferenceType? type) @@ -95,8 +97,22 @@ public OpenApiReference ConvertToOpenApiReference( // $ref: externalSource.yaml#/Pet if (id.StartsWith("/components/")) { - id = segments[1].Split('/')[3]; - } + var localSegments = segments[1].Split('/'); + var referencedType = localSegments[2].GetEnumFromDisplayName(); + if (type == null) + { + type = referencedType; + } + else + { + if (type != referencedType) + { + throw new OpenApiException("Referenced type mismatch"); + } + } + id = localSegments[3]; + } + return new OpenApiReference { ExternalResource = segments[0], diff --git a/src/Microsoft.OpenApi.Tool/OpenApiService.cs b/src/Microsoft.OpenApi.Tool/OpenApiService.cs index c52c08941..3b3afcbd0 100644 --- a/src/Microsoft.OpenApi.Tool/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Tool/OpenApiService.cs @@ -5,6 +5,7 @@ using System.Net; using System.Net.Http; using System.Text; +using System.Threading.Tasks; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers; @@ -29,14 +30,16 @@ public static void ProcessOpenApiDocument( throw new ArgumentNullException("input"); } - var stream = GetStream(input); + var inputUrl = GetInputUrl(input); + var stream = GetStream(inputUrl); OpenApiDocument document; var result = new OpenApiStreamReader(new OpenApiReaderSettings { ReferenceResolution = resolveExternal == true ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, - RuleSet = ValidationRuleSet.GetDefaultRuleSet() + RuleSet = ValidationRuleSet.GetDefaultRuleSet(), + BaseUrl = new Uri(inputUrl.AbsoluteUri) } ).ReadAsync(stream).GetAwaiter().GetResult(); @@ -91,10 +94,22 @@ public static void ProcessOpenApiDocument( } } - private static Stream GetStream(string input) + private static Uri GetInputUrl(string input) { - Stream stream; if (input.StartsWith("http")) + { + return new Uri(input); + } + else + { + return new Uri("file://" + Path.GetFullPath(input)); + } + } + + private static Stream GetStream(Uri input) + { + Stream stream; + if (input.Scheme == "http" || input.Scheme == "https") { var httpClient = new HttpClient(new HttpClientHandler() { @@ -105,32 +120,40 @@ private static Stream GetStream(string input) }; stream = httpClient.GetStreamAsync(input).Result; } - else + else if (input.Scheme == "file") { - var fileInput = new FileInfo(input); + var fileInput = new FileInfo(input.AbsolutePath); stream = fileInput.OpenRead(); + } + else + { + throw new ArgumentException("Unrecognized exception"); } return stream; } - internal static void ValidateOpenApiDocument(string input) + internal static async Task ValidateOpenApiDocument(string input, bool resolveExternal) { if (input == null) { throw new ArgumentNullException("input"); } - - var stream = GetStream(input); + var inputUrl = GetInputUrl(input); + var stream = GetStream(GetInputUrl(input)); OpenApiDocument document; - document = new OpenApiStreamReader(new OpenApiReaderSettings + var result = await new OpenApiStreamReader(new OpenApiReaderSettings { - //ReferenceResolution = resolveExternal == true ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, - RuleSet = ValidationRuleSet.GetDefaultRuleSet() + ReferenceResolution = resolveExternal == true ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, + RuleSet = ValidationRuleSet.GetDefaultRuleSet(), + BaseUrl = new Uri(inputUrl.AbsoluteUri) } - ).Read(stream, out var context); + ).ReadAsync(stream); + + document = result.OpenApiDocument; + var context = result.OpenApiDiagnostic; if (context.Errors.Count != 0) { @@ -140,11 +163,25 @@ internal static void ValidateOpenApiDocument(string input) } } - var statsVisitor = new StatsVisitor(); - var walker = new OpenApiWalker(statsVisitor); - walker.Walk(document); + if (document.Workspace == null) { + var statsVisitor = new StatsVisitor(); + var walker = new OpenApiWalker(statsVisitor); + walker.Walk(document); + Console.WriteLine(statsVisitor.GetStatisticsReport()); + } + else + { + foreach (var memberDocument in document.Workspace.Documents) + { + Console.WriteLine("Stats for " + memberDocument.Info.Title); + var statsVisitor = new StatsVisitor(); + var walker = new OpenApiWalker(statsVisitor); + walker.Walk(memberDocument); + Console.WriteLine(statsVisitor.GetStatisticsReport()); + } + } - Console.WriteLine(statsVisitor.GetStatisticsReport()); + } } } diff --git a/src/Microsoft.OpenApi.Tool/Program.cs b/src/Microsoft.OpenApi.Tool/Program.cs index 446e2829a..0ae4cb782 100644 --- a/src/Microsoft.OpenApi.Tool/Program.cs +++ b/src/Microsoft.OpenApi.Tool/Program.cs @@ -36,9 +36,10 @@ static async Task Main(string[] args) var validateCommand = new Command("validate") { - new Option("--input", "Input OpenAPI description file path or URL", typeof(string) ) + new Option("--input", "Input OpenAPI description file path or URL", typeof(string) ), + new Option("--resolveExternal","Resolve external $refs", typeof(bool)) }; - validateCommand.Handler = CommandHandler.Create(OpenApiService.ValidateOpenApiDocument); + validateCommand.Handler = CommandHandler.Create(OpenApiService.ValidateOpenApiDocument); var transformCommand = new Command("transform") { diff --git a/src/Microsoft.OpenApi/Models/OpenApiReference.cs b/src/Microsoft.OpenApi/Models/OpenApiReference.cs index 2c8f738ca..cbe64d3e6 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiReference.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiReference.cs @@ -54,7 +54,7 @@ public string ReferenceV3 { if (IsExternal) { - return GetExternalReference(); + return GetExternalReferenceV3(); } if (!Type.HasValue) @@ -85,7 +85,7 @@ public string ReferenceV2 { if (IsExternal) { - return GetExternalReference(); + return GetExternalReferenceV2(); } if (!Type.HasValue) @@ -171,11 +171,21 @@ public void SerializeAsV2(IOpenApiWriter writer) writer.WriteEndObject(); } - private string GetExternalReference() + private string GetExternalReferenceV3() { if (Id != null) { - return ExternalResource + "#/" + Id; + return ExternalResource + "#/components/" + Type.GetDisplayName() + "/"+ Id; + } + + return ExternalResource; + } + + private string GetExternalReferenceV2() + { + if (Id != null) + { + return ExternalResource + "#/" + GetReferenceTypeNameAsV2((ReferenceType)Type) + "/" + Id; } return ExternalResource; diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs index d684144cb..4a35301c6 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs @@ -19,7 +19,7 @@ public class OpenApiWorkspaceStreamTests // Use OpenApiWorkspace to load a document and a referenced document [Fact] - public async Task LoadDocumentIntoWorkspace() + public async Task LoadingDocumentWithResolveAllReferencesShouldLoadDocumentIntoWorkspace() { // Create a reader that will resolve all references var reader = new OpenApiStreamReader(new OpenApiReaderSettings() @@ -48,7 +48,7 @@ public async Task LoadDocumentIntoWorkspace() [Fact] - public async Task LoadTodoDocumentIntoWorkspace() + public async Task LoadDocumentWithExternalReferenceShouldLoadBothDocumentsIntoWorkspace() { // Create a reader that will resolve all references var reader = new OpenApiStreamReader(new OpenApiReaderSettings() @@ -65,6 +65,7 @@ public async Task LoadTodoDocumentIntoWorkspace() Assert.NotNull(result.OpenApiDocument.Workspace); Assert.True(result.OpenApiDocument.Workspace.Contains("TodoComponents.yaml")); + var referencedSchema = result.OpenApiDocument .Paths["/todos"] .Operations[OperationType.Get] diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs index c251814db..b9edd2a32 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiReferenceTests.cs @@ -37,30 +37,54 @@ public void SettingInternalReferenceForComponentsStyleReferenceShouldSucceed( } [Theory] - [InlineData("Pet.json", "Pet.json", null)] - [InlineData("Pet.yaml", "Pet.yaml", null)] - [InlineData("abc", "abc", null)] - [InlineData("Pet.json#/Pet", "Pet.json", "Pet")] - [InlineData("Pet.yaml#/Pet", "Pet.yaml", "Pet")] - [InlineData("abc#/Pet", "abc", "Pet")] - public void SettingExternalReferenceShouldSucceed(string expected, string externalResource, string id) + [InlineData("Pet.json", "Pet.json", null, null)] + [InlineData("Pet.yaml", "Pet.yaml", null, null)] + [InlineData("abc", "abc", null, null)] + [InlineData("Pet.json#/components/schemas/Pet", "Pet.json", "Pet", ReferenceType.Schema)] + [InlineData("Pet.yaml#/components/schemas/Pet", "Pet.yaml", "Pet", ReferenceType.Schema)] + [InlineData("abc#/components/schemas/Pet", "abc", "Pet", ReferenceType.Schema)] + public void SettingExternalReferenceV3ShouldSucceed(string expected, string externalResource, string id, ReferenceType? type) { // Arrange & Act var reference = new OpenApiReference { ExternalResource = externalResource, + Type = type, Id = id }; // Assert reference.ExternalResource.Should().Be(externalResource); - reference.Type.Should().BeNull(); reference.Id.Should().Be(id); reference.ReferenceV3.Should().Be(expected); + } + + [Theory] + [InlineData("Pet.json", "Pet.json", null, null)] + [InlineData("Pet.yaml", "Pet.yaml", null, null)] + [InlineData("abc", "abc", null, null)] + [InlineData("Pet.json#/definitions/Pet", "Pet.json", "Pet", ReferenceType.Schema)] + [InlineData("Pet.yaml#/definitions/Pet", "Pet.yaml", "Pet", ReferenceType.Schema)] + [InlineData("abc#/definitions/Pet", "abc", "Pet", ReferenceType.Schema)] + public void SettingExternalReferenceV2ShouldSucceed(string expected, string externalResource, string id, ReferenceType? type) + { + // Arrange & Act + var reference = new OpenApiReference + { + ExternalResource = externalResource, + Type = type, + Id = id + }; + + // Assert + reference.ExternalResource.Should().Be(externalResource); + reference.Id.Should().Be(id); + reference.ReferenceV2.Should().Be(expected); } + [Fact] public void SerializeSchemaReferenceAsJsonV3Works() { @@ -144,11 +168,12 @@ public void SerializeExternalReferenceAsJsonV2Works() var reference = new OpenApiReference { ExternalResource = "main.json", + Type= ReferenceType.Schema, Id = "Pets" }; var expected = @"{ - ""$ref"": ""main.json#/Pets"" + ""$ref"": ""main.json#/definitions/Pets"" }"; // Act @@ -167,9 +192,10 @@ public void SerializeExternalReferenceAsYamlV2Works() var reference = new OpenApiReference { ExternalResource = "main.json", + Type = ReferenceType.Schema, Id = "Pets" }; - var expected = @"$ref: main.json#/Pets"; + var expected = @"$ref: main.json#/definitions/Pets"; // Act var actual = reference.SerializeAsYaml(OpenApiSpecVersion.OpenApi2_0); @@ -182,10 +208,10 @@ public void SerializeExternalReferenceAsYamlV2Works() public void SerializeExternalReferenceAsJsonV3Works() { // Arrange - var reference = new OpenApiReference { ExternalResource = "main.json", Id = "Pets" }; + var reference = new OpenApiReference { ExternalResource = "main.json", Type = ReferenceType.Schema,Id = "Pets" }; var expected = @"{ - ""$ref"": ""main.json#/Pets"" + ""$ref"": ""main.json#/components/schemas/Pets"" }"; // Act @@ -201,8 +227,8 @@ public void SerializeExternalReferenceAsJsonV3Works() public void SerializeExternalReferenceAsYamlV3Works() { // Arrange - var reference = new OpenApiReference { ExternalResource = "main.json", Id = "Pets" }; - var expected = @"$ref: main.json#/Pets"; + var reference = new OpenApiReference { ExternalResource = "main.json", Type = ReferenceType.Schema, Id = "Pets" }; + var expected = @"$ref: main.json#/components/schemas/Pets"; // Act var actual = reference.SerializeAsYaml(OpenApiSpecVersion.OpenApi3_0); From 0dc267c1afc44336327b344b151584915de8583a Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 12 Oct 2021 12:21:47 +0300 Subject: [PATCH 004/288] Add a mock OpenApiDocument --- .../Documents/OpenApiDocumentMock.cs | 725 ++++++++++++++++++ 1 file changed, 725 insertions(+) create mode 100644 test/Microsoft.OpenApi.Tests/Documents/OpenApiDocumentMock.cs diff --git a/test/Microsoft.OpenApi.Tests/Documents/OpenApiDocumentMock.cs b/test/Microsoft.OpenApi.Tests/Documents/OpenApiDocumentMock.cs new file mode 100644 index 000000000..8b354b36f --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Documents/OpenApiDocumentMock.cs @@ -0,0 +1,725 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Interfaces; +using Microsoft.OpenApi.Models; +using System.Collections.Generic; + +namespace OpenAPIService.Test +{ + /// + /// Mock class that creates a sample OpenAPI document. + /// + public static class OpenApiDocumentMock + { + /// + /// Creates an OpenAPI document. + /// + /// Instance of an OpenApi document + public static OpenApiDocument CreateOpenApiDocument() + { + var applicationJsonMediaType = "application/json"; + + var document = new OpenApiDocument() + { + Paths = new OpenApiPaths() + { + ["/"] = new OpenApiPathItem() // root path + { + Operations = new Dictionary + { + { + OperationType.Get, new OpenApiOperation + { + OperationId = "graphService.GetGraphService", + Responses = new OpenApiResponses() + { + { + "200",new OpenApiResponse() + { + Description = "OK" + } + } + } + } + } + } + }, + ["/reports/microsoft.graph.getTeamsUserActivityCounts(period={period})"] = new OpenApiPathItem() + { + Operations = new Dictionary + { + { + OperationType.Get, new OpenApiOperation + { + Tags = new List + { + { + new OpenApiTag() + { + Name = "reports.Functions" + } + } + }, + OperationId = "reports.getTeamsUserActivityCounts", + Summary = "Invoke function getTeamsUserActivityUserCounts", + Parameters = new List + { + { + new OpenApiParameter() + { + Name = "period", + In = ParameterLocation.Path, + Required = true, + Schema = new OpenApiSchema() + { + Type = "string" + } + } + } + }, + Responses = new OpenApiResponses() + { + { + "200", new OpenApiResponse() + { + Description = "Success", + Content = new Dictionary + { + { + applicationJsonMediaType, + new OpenApiMediaType + { + Schema = new OpenApiSchema + { + Type = "array" + } + } + } + } + } + } + } + } + } + } + }, + ["/reports/microsoft.graph.getTeamsUserActivityUserDetail(date={date})"] = new OpenApiPathItem() + { + Operations = new Dictionary + { + { + OperationType.Get, new OpenApiOperation + { + Tags = new List + { + { + new OpenApiTag() + { + Name = "reports.Functions" + } + } + }, + OperationId = "reports.getTeamsUserActivityUserDetail-a3f1", + Summary = "Invoke function getTeamsUserActivityUserDetail", + Parameters = new List + { + { + new OpenApiParameter() + { + Name = "period", + In = ParameterLocation.Path, + Required = true, + Schema = new OpenApiSchema() + { + Type = "string" + } + } + } + }, + Responses = new OpenApiResponses() + { + { + "200", new OpenApiResponse() + { + Description = "Success", + Content = new Dictionary + { + { + applicationJsonMediaType, + new OpenApiMediaType + { + Schema = new OpenApiSchema + { + Type = "array" + } + } + } + } + } + } + } + } + } + } + }, + ["/users"] = new OpenApiPathItem() + { + Operations = new Dictionary + { + { + OperationType.Get, new OpenApiOperation + { + Tags = new List + { + { + new OpenApiTag() + { + Name = "users.user" + } + } + }, + OperationId = "users.user.ListUser", + Summary = "Get entities from users", + Responses = new OpenApiResponses() + { + { + "200", new OpenApiResponse() + { + Description = "Retrieved entities", + Content = new Dictionary + { + { + applicationJsonMediaType, + new OpenApiMediaType + { + Schema = new OpenApiSchema + { + Title = "Collection of user", + Type = "object", + Properties = new Dictionary + { + { + "value", + new OpenApiSchema + { + Type = "array", + Items = new OpenApiSchema + { + Reference = new OpenApiReference + { + Type = ReferenceType.Schema, + Id = "microsoft.graph.user" + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + }, + ["/users/{user-id}"] = new OpenApiPathItem() + { + Operations = new Dictionary + { + { + OperationType.Get, new OpenApiOperation + { + Tags = new List + { + { + new OpenApiTag() + { + Name = "users.user" + } + } + }, + OperationId = "users.user.GetUser", + Summary = "Get entity from users by key", + Responses = new OpenApiResponses() + { + { + "200", new OpenApiResponse() + { + Description = "Retrieved entity", + Content = new Dictionary + { + { + applicationJsonMediaType, + new OpenApiMediaType + { + Schema = new OpenApiSchema + { + Reference = new OpenApiReference + { + Type = ReferenceType.Schema, + Id = "microsoft.graph.user" + } + } + } + } + } + } + } + } + } + }, + { + OperationType.Patch, new OpenApiOperation + { + Tags = new List + { + { + new OpenApiTag() + { + Name = "users.user" + } + } + }, + OperationId = "users.user.UpdateUser", + Summary = "Update entity in users", + Responses = new OpenApiResponses() + { + { + "204", new OpenApiResponse() + { + Description = "Success" + } + } + } + } + } + } + }, + ["/users/{user-id}/messages/{message-id}"] = new OpenApiPathItem() + { + Operations = new Dictionary + { + { + OperationType.Get, new OpenApiOperation + { + Tags = new List + { + { + new OpenApiTag() + { + Name = "users.message" + } + } + }, + OperationId = "users.GetMessages", + Summary = "Get messages from users", + Description = "The messages in a mailbox or folder. Read-only. Nullable.", + Parameters = new List + { + new OpenApiParameter() + { + Name = "$select", + In = ParameterLocation.Query, + Required = true, + Description = "Select properties to be returned", + Schema = new OpenApiSchema() + { + Type = "array" + } + // missing explode parameter + } + }, + Responses = new OpenApiResponses() + { + { + "200", new OpenApiResponse() + { + Description = "Retrieved navigation property", + Content = new Dictionary + { + { + applicationJsonMediaType, + new OpenApiMediaType + { + Schema = new OpenApiSchema + { + Reference = new OpenApiReference + { + Type = ReferenceType.Schema, + Id = "microsoft.graph.message" + } + } + } + } + } + } + } + } + } + } + } + }, + ["/administrativeUnits/{administrativeUnit-id}/microsoft.graph.restore"] = new OpenApiPathItem() + { + Operations = new Dictionary + { + { + OperationType.Post, new OpenApiOperation + { + Tags = new List + { + { + new OpenApiTag() + { + Name = "administrativeUnits.Actions" + } + } + }, + OperationId = "administrativeUnits.restore", + Summary = "Invoke action restore", + Parameters = new List + { + { + new OpenApiParameter() + { + Name = "administrativeUnit-id", + In = ParameterLocation.Path, + Required = true, + Description = "key: id of administrativeUnit", + Schema = new OpenApiSchema() + { + Type = "string" + } + } + } + }, + Responses = new OpenApiResponses() + { + { + "200", new OpenApiResponse() + { + Description = "Success", + Content = new Dictionary + { + { + applicationJsonMediaType, + new OpenApiMediaType + { + Schema = new OpenApiSchema + { + AnyOf = new List + { + new OpenApiSchema + { + Type = "string" + } + }, + Nullable = true + } + } + } + } + } + } + } + } + } + } + }, + ["/applications/{application-id}/logo"] = new OpenApiPathItem() + { + Operations = new Dictionary + { + { + OperationType.Put, new OpenApiOperation + { + Tags = new List + { + { + new OpenApiTag() + { + Name = "applications.application" + } + } + }, + OperationId = "applications.application.UpdateLogo", + Summary = "Update media content for application in applications", + Responses = new OpenApiResponses() + { + { + "204", new OpenApiResponse() + { + Description = "Success" + } + } + } + } + } + } + }, + ["/security/hostSecurityProfiles"] = new OpenApiPathItem() + { + Operations = new Dictionary + { + { + OperationType.Get, new OpenApiOperation + { + Tags = new List + { + { + new OpenApiTag() + { + Name = "security.hostSecurityProfile" + } + } + }, + OperationId = "security.ListHostSecurityProfiles", + Summary = "Get hostSecurityProfiles from security", + Responses = new OpenApiResponses() + { + { + "200", new OpenApiResponse() + { + Description = "Retrieved navigation property", + Content = new Dictionary + { + { + applicationJsonMediaType, + new OpenApiMediaType + { + Schema = new OpenApiSchema + { + Title = "Collection of hostSecurityProfile", + Type = "object", + Properties = new Dictionary + { + { + "value", + new OpenApiSchema + { + Type = "array", + Items = new OpenApiSchema + { + Reference = new OpenApiReference + { + Type = ReferenceType.Schema, + Id = "microsoft.graph.networkInterface" + } + } + } + } + } + } + } + } + } + } + } + } + } + } + } + }, + ["/communications/calls/{call-id}/microsoft.graph.keepAlive"] = new OpenApiPathItem() + { + Operations = new Dictionary + { + { + OperationType.Post, new OpenApiOperation + { + Tags = new List + { + { + new OpenApiTag() + { + Name = "communications.Actions" + } + } + }, + OperationId = "communications.calls.call.keepAlive", + Summary = "Invoke action keepAlive", + Parameters = new List + { + new OpenApiParameter() + { + Name = "call-id", + In = ParameterLocation.Path, + Description = "key: id of call", + Required = true, + Schema = new OpenApiSchema() + { + Type = "string" + }, + Extensions = new Dictionary + { + { + "x-ms-docs-key-type", new OpenApiString("call") + } + } + } + }, + Responses = new OpenApiResponses() + { + { + "204", new OpenApiResponse() + { + Description = "Success" + } + } + }, + Extensions = new Dictionary + { + { + "x-ms-docs-operation-type", new OpenApiString("action") + } + } + } + } + } + }, + ["/groups/{group-id}/events/{event-id}/calendar/events/microsoft.graph.delta"] = new OpenApiPathItem() + { + Operations = new Dictionary + { + { + OperationType.Get, new OpenApiOperation + { + Tags = new List + { + new OpenApiTag() + { + Name = "groups.Functions" + } + }, + OperationId = "groups.group.events.event.calendar.events.delta", + Summary = "Invoke function delta", + Parameters = new List + { + new OpenApiParameter() + { + Name = "group-id", + In = ParameterLocation.Path, + Description = "key: id of group", + Required = true, + Schema = new OpenApiSchema() + { + Type = "string" + }, + Extensions = new Dictionary + { + { + "x-ms-docs-key-type", new OpenApiString("group") + } + } + }, + new OpenApiParameter() + { + Name = "event-id", + In = ParameterLocation.Path, + Description = "key: id of event", + Required = true, + Schema = new OpenApiSchema() + { + Type = "string" + }, + Extensions = new Dictionary + { + { + "x-ms-docs-key-type", new OpenApiString("event") + } + } + } + }, + Responses = new OpenApiResponses() + { + { + "200", new OpenApiResponse() + { + Description = "Success", + Content = new Dictionary + { + { + applicationJsonMediaType, + new OpenApiMediaType + { + Schema = new OpenApiSchema + { + Type = "array", + Reference = new OpenApiReference + { + Type = ReferenceType.Schema, + Id = "microsoft.graph.event" + } + } + } + } + } + } + } + }, + Extensions = new Dictionary + { + { + "x-ms-docs-operation-type", new OpenApiString("function") + } + } + } + } + } + }, + ["/applications/{application-id}/createdOnBehalfOf/$ref"] = new OpenApiPathItem() + { + Operations = new Dictionary + { + { + OperationType.Get, new OpenApiOperation + { + Tags = new List + { + new OpenApiTag() + { + Name = "applications.directoryObject" + } + }, + OperationId = "applications.GetRefCreatedOnBehalfOf", + Summary = "Get ref of createdOnBehalfOf from applications" + } + } + } + } + }, + Components = new OpenApiComponents + { + Schemas = new Dictionary + { + { + "microsoft.graph.networkInterface", new OpenApiSchema + { + Title = "networkInterface", + Type = "object", + Properties = new Dictionary + { + { + "description", new OpenApiSchema + { + Type = "string", + Description = "Description of the NIC (e.g. Ethernet adapter, Wireless LAN adapter Local Area Connection <#>, etc.).", + Nullable = true + } + } + } + } + } + } + } + }; + + return document; + } + } +} From 0ecca08551dcab24364ff3e1c02cc88b649a0fb9 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 12 Oct 2021 12:22:03 +0300 Subject: [PATCH 005/288] Add tests for filtering validation --- .../Services/OpenApiFilterServiceTests.cs | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs new file mode 100644 index 000000000..7fedd989c --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System; +using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Services; +using OpenAPIService.Test; +using Xunit; + +namespace Microsoft.OpenApi.Tests.Services +{ + public class OpenApiFilterServiceTests + { + private const string Title = "Partial Graph API"; + private const string GraphVersion = "mock"; + private readonly OpenApiFilterService _openApiFilterService; + private readonly OpenApiDocument _openApiDocumentMock; + + public OpenApiFilterServiceTests() + { + _openApiFilterService = new OpenApiFilterService(); + _openApiDocumentMock = OpenApiDocumentMock.CreateOpenApiDocument(); + } + + [Theory] + [InlineData("users.user.ListUser")] + [InlineData("users.user.GetUser")] + [InlineData("administrativeUnits.restore")] + [InlineData("graphService.GetGraphService")] + public void ReturnFilteredOpenApiDocumentBasedOnOperationIds(string operationId) + { + // Act + var predicate = _openApiFilterService.CreatePredicate(operationId); + var subsetOpenApiDocument = _openApiFilterService.CreateFilteredDocument(_openApiDocumentMock, Title, GraphVersion, predicate); + + // Assert + Assert.NotNull(subsetOpenApiDocument); + Assert.Single(subsetOpenApiDocument.Paths); + } + + [Fact] + public void ThrowsInvalidOperationExceptionInCreatePredicateWhenInvalidOperationIdIsSpecified() + { + // Act and Assert + var message = Assert.Throws(() =>_openApiFilterService.CreatePredicate(null)).Message; + Assert.Equal("OperationId needs to be specified.", message); + } + } +} From 2f4a1c8007a7bb6ad90137a5166563703c6bd81c Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 12 Oct 2021 12:24:08 +0300 Subject: [PATCH 006/288] Add an OpenApi filtering service for filtering an OpenApiDocument based on OperationId --- .../Services/OpenApiFilterService.cs | 186 ++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 src/Microsoft.OpenApi/Services/OpenApiFilterService.cs diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs new file mode 100644 index 000000000..4f1795bc6 --- /dev/null +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -0,0 +1,186 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.OpenApi.Models; + +namespace Microsoft.OpenApi.Services +{ + /// + /// + /// + public class OpenApiFilterService + { + public static readonly string GraphAuthorizationUrl = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"; + public static readonly string GraphTokenUrl = "https://login.microsoftonline.com/common/oauth2/v2.0/token"; + public static readonly string GraphUrl = "https://graph.microsoft.com/{0}/"; + public const string GraphVersion_V1 = "v1.0"; + + + public OpenApiDocument CreateSubsetOpenApiDocument(string operationIds, OpenApiDocument source, string title) + { + var predicate = CreatePredicate(operationIds); + + var subsetOpenApiDocument = CreateFilteredDocument(source, title, GraphVersion_V1, predicate); + + return subsetOpenApiDocument; + } + + public Func CreatePredicate(string operationIds) + { + string predicateSource = null; + + Func predicate; + if (operationIds != null) + { + if (operationIds == "*") + { + predicate = (o) => true; // All operations + } + else + { + var operationIdsArray = operationIds.Split(','); + predicate = (o) => operationIdsArray.Contains(o.OperationId); + } + + predicateSource = $"operationIds: {operationIds}"; + } + + else + { + throw new InvalidOperationException("OperationId needs to be specified."); + } + + return predicate; + } + /// + /// + /// + /// + /// + /// + /// + /// + public OpenApiDocument CreateFilteredDocument(OpenApiDocument source, string title, string graphVersion, Func predicate) + { + var subset = new OpenApiDocument + { + Info = new OpenApiInfo() + { + Title = title, + Version = graphVersion + }, + + Components = new OpenApiComponents() + }; + var aadv2Scheme = new OpenApiSecurityScheme() + { + Type = SecuritySchemeType.OAuth2, + Flows = new OpenApiOAuthFlows() + { + AuthorizationCode = new OpenApiOAuthFlow() + { + AuthorizationUrl = new Uri(GraphAuthorizationUrl), + TokenUrl = new Uri(GraphTokenUrl) + } + }, + Reference = new OpenApiReference() { Id = "azureaadv2", Type = ReferenceType.SecurityScheme }, + UnresolvedReference = false + }; + subset.Components.SecuritySchemes.Add("azureaadv2", aadv2Scheme); + + subset.SecurityRequirements.Add(new OpenApiSecurityRequirement() { { aadv2Scheme, Array.Empty() } }); + + subset.Servers.Add(new OpenApiServer() { Description = "Core", Url = string.Format(GraphUrl, graphVersion) }); + + var results = FindOperations(source, predicate); + foreach (var result in results) + { + OpenApiPathItem pathItem; + string pathKey = result.CurrentKeys.Path; + + if (subset.Paths == null) + { + subset.Paths = new OpenApiPaths(); + pathItem = new OpenApiPathItem(); + subset.Paths.Add(pathKey, pathItem); + } + else + { + if (!subset.Paths.TryGetValue(pathKey, out pathItem)) + { + pathItem = new OpenApiPathItem(); + subset.Paths.Add(pathKey, pathItem); + } + } + + pathItem.Operations.Add((OperationType)result.CurrentKeys.Operation, result.Operation); + } + + if (subset.Paths == null) + { + throw new ArgumentException("No paths found for the supplied parameters."); + } + + CopyReferences(subset); + + return subset; + } + + private static IList FindOperations(OpenApiDocument graphOpenApi, Func predicate) + { + var search = new OperationSearch(predicate); + var walker = new OpenApiWalker(search); + walker.Walk(graphOpenApi); + return search.SearchResults; + } + + private static void CopyReferences(OpenApiDocument target) + { + bool morestuff; + do + { + var copy = new CopyReferences(target); + var walker = new OpenApiWalker(copy); + walker.Walk(target); + + morestuff = AddReferences(copy.Components, target.Components); + + } while (morestuff); + } + + private static bool AddReferences(OpenApiComponents newComponents, OpenApiComponents target) + { + var moreStuff = false; + foreach (var item in newComponents.Schemas) + { + if (!target.Schemas.ContainsKey(item.Key)) + { + moreStuff = true; + target.Schemas.Add(item); + } + } + + foreach (var item in newComponents.Parameters) + { + if (!target.Parameters.ContainsKey(item.Key)) + { + moreStuff = true; + target.Parameters.Add(item); + } + } + + foreach (var item in newComponents.Responses) + { + if (!target.Responses.ContainsKey(item.Key)) + { + moreStuff = true; + target.Responses.Add(item); + } + } + return moreStuff; + } + } +} From 8e45f8b531cb03db9695c65d18bd6f40c156d746 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 12 Oct 2021 12:24:44 +0300 Subject: [PATCH 007/288] Add necessary packages --- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index d0ff2fbcd..4d305cfdc 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -1,6 +1,7 @@  netstandard2.0 + 9.0 true http://go.microsoft.com/fwlink/?LinkID=288890 https://github.com/Microsoft/OpenAPI.NET @@ -36,7 +37,8 @@ - + + From f270b908247e0bf9d5478d2b0f24e05233fa9ceb Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 12 Oct 2021 15:54:42 +0300 Subject: [PATCH 008/288] Simplify using statement and switch condition --- src/Microsoft.OpenApi.Tool/OpenApiService.cs | 49 +++++++------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/src/Microsoft.OpenApi.Tool/OpenApiService.cs b/src/Microsoft.OpenApi.Tool/OpenApiService.cs index c52c08941..80e6bf7bc 100644 --- a/src/Microsoft.OpenApi.Tool/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Tool/OpenApiService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -52,43 +52,26 @@ public static void ProcessOpenApiDocument( errorReport.AppendLine(error.ToString()); } - throw new ArgumentException(String.Join(Environment.NewLine, context.Errors.Select(e => e.Message).ToArray())); + throw new ArgumentException(string.Join(Environment.NewLine, context.Errors.Select(e => e.Message).ToArray())); } - using (var outputStream = output?.Create()) - { - TextWriter textWriter; + using var outputStream = output?.Create(); - if (outputStream != null) - { - textWriter = new StreamWriter(outputStream); - } - else - { - textWriter = Console.Out; - } + var textWriter = outputStream != null ? new StreamWriter(outputStream) : Console.Out; - var settings = new OpenApiWriterSettings() - { - ReferenceInline = inline == true ? ReferenceInlineSetting.InlineLocalReferences : ReferenceInlineSetting.DoNotInlineReferences - }; - IOpenApiWriter writer; - switch (format) - { - case OpenApiFormat.Json: - writer = new OpenApiJsonWriter(textWriter, settings); - break; - case OpenApiFormat.Yaml: - writer = new OpenApiYamlWriter(textWriter, settings); - break; - default: - throw new ArgumentException("Unknown format"); - } - - document.Serialize(writer, version); + var settings = new OpenApiWriterSettings() + { + ReferenceInline = inline ? ReferenceInlineSetting.InlineLocalReferences : ReferenceInlineSetting.DoNotInlineReferences + }; + IOpenApiWriter writer = format switch + { + OpenApiFormat.Json => new OpenApiJsonWriter(textWriter, settings), + OpenApiFormat.Yaml => new OpenApiYamlWriter(textWriter, settings), + _ => throw new ArgumentException("Unknown format"), + }; + document.Serialize(writer, version); - textWriter.Flush(); - } + textWriter.Flush(); } private static Stream GetStream(string input) From 9cda4fb5fc5467c8f5980bba930e27a58b773105 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 18 Oct 2021 11:00:52 +0300 Subject: [PATCH 009/288] Use static class reference --- .../Services/OpenApiFilterServiceTests.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs index 7fedd989c..4f6a9bcbf 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs @@ -13,12 +13,10 @@ public class OpenApiFilterServiceTests { private const string Title = "Partial Graph API"; private const string GraphVersion = "mock"; - private readonly OpenApiFilterService _openApiFilterService; private readonly OpenApiDocument _openApiDocumentMock; public OpenApiFilterServiceTests() { - _openApiFilterService = new OpenApiFilterService(); _openApiDocumentMock = OpenApiDocumentMock.CreateOpenApiDocument(); } @@ -30,8 +28,8 @@ public OpenApiFilterServiceTests() public void ReturnFilteredOpenApiDocumentBasedOnOperationIds(string operationId) { // Act - var predicate = _openApiFilterService.CreatePredicate(operationId); - var subsetOpenApiDocument = _openApiFilterService.CreateFilteredDocument(_openApiDocumentMock, Title, GraphVersion, predicate); + var predicate = OpenApiFilterService.CreatePredicate(operationId); + var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(_openApiDocumentMock, Title, GraphVersion, predicate); // Assert Assert.NotNull(subsetOpenApiDocument); @@ -42,7 +40,7 @@ public void ReturnFilteredOpenApiDocumentBasedOnOperationIds(string operationId) public void ThrowsInvalidOperationExceptionInCreatePredicateWhenInvalidOperationIdIsSpecified() { // Act and Assert - var message = Assert.Throws(() =>_openApiFilterService.CreatePredicate(null)).Message; + var message = Assert.Throws(() =>OpenApiFilterService.CreatePredicate(null)).Message; Assert.Equal("OperationId needs to be specified.", message); } } From af61c14ff792cb3bcdda8b115caa23a7a4c6b774 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 18 Oct 2021 11:01:53 +0300 Subject: [PATCH 010/288] Add --filterbyOperationId command option --- src/Microsoft.OpenApi.Tool/Program.cs | 31 +++++---------------------- 1 file changed, 5 insertions(+), 26 deletions(-) diff --git a/src/Microsoft.OpenApi.Tool/Program.cs b/src/Microsoft.OpenApi.Tool/Program.cs index 446e2829a..938986350 100644 --- a/src/Microsoft.OpenApi.Tool/Program.cs +++ b/src/Microsoft.OpenApi.Tool/Program.cs @@ -1,34 +1,12 @@ -using System; -using System.CommandLine; +using System.CommandLine; using System.CommandLine.Invocation; using System.IO; using System.Threading.Tasks; -using Microsoft.OpenApi; namespace Microsoft.OpenApi.Tool { - class Program + static class Program { - static async Task OldMain(string[] args) - { - - var command = new RootCommand - { - new Option("--input", "Input OpenAPI description 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) ), - new Option("--inline", "Inline $ref instances", typeof(bool) ), - new Option("--resolveExternal","Resolve external $refs", typeof(bool)) - }; - - command.Handler = CommandHandler.Create( - OpenApiService.ProcessOpenApiDocument); - - // Parse the incoming args and invoke the handler - return await command.InvokeAsync(args); - } - static async Task Main(string[] args) { var rootCommand = new RootCommand() { @@ -47,9 +25,10 @@ static async Task Main(string[] args) new Option("--version", "OpenAPI specification version", typeof(OpenApiSpecVersion)), new Option("--format", "File format",typeof(OpenApiFormat) ), new Option("--inline", "Inline $ref instances", typeof(bool) ), - new Option("--resolveExternal","Resolve external $refs", typeof(bool)) + new Option("--resolveExternal","Resolve external $refs", typeof(bool)), + new Option("--filterByOperationId", "Filters by OperationId provided", typeof(string)) }; - transformCommand.Handler = CommandHandler.Create( + transformCommand.Handler = CommandHandler.Create( OpenApiService.ProcessOpenApiDocument); rootCommand.Add(transformCommand); From d24442d45833859d9c73ccb8840c7f918cd3ac93 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 18 Oct 2021 11:02:39 +0300 Subject: [PATCH 011/288] Add filterByOperationId param and logic --- src/Microsoft.OpenApi.Tool/OpenApiService.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Tool/OpenApiService.cs b/src/Microsoft.OpenApi.Tool/OpenApiService.cs index 80e6bf7bc..7b56f4516 100644 --- a/src/Microsoft.OpenApi.Tool/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Tool/OpenApiService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -16,11 +16,15 @@ namespace Microsoft.OpenApi.Tool { static class OpenApiService { + public const string GraphVersion_V1 = "v1.0"; + public const string Title = "Partial Graph API"; + public static void ProcessOpenApiDocument( string input, FileInfo output, OpenApiSpecVersion version, OpenApiFormat format, + string filterbyOperationId, bool inline, bool resolveExternal) { @@ -35,12 +39,20 @@ public static void ProcessOpenApiDocument( var result = new OpenApiStreamReader(new OpenApiReaderSettings { - ReferenceResolution = resolveExternal == true ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, + ReferenceResolution = resolveExternal ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, RuleSet = ValidationRuleSet.GetDefaultRuleSet() } ).ReadAsync(stream).GetAwaiter().GetResult(); document = result.OpenApiDocument; + + // Check if filter options are provided, then execute + if (!string.IsNullOrEmpty(filterbyOperationId)) + { + var predicate = OpenApiFilterService.CreatePredicate(filterbyOperationId); + document = OpenApiFilterService.CreateFilteredDocument(document, Title, GraphVersion_V1, predicate); + } + var context = result.OpenApiDiagnostic; if (context.Errors.Count != 0) From 501e88cebec533095d1fade8e3e43f45c54d904c Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 18 Oct 2021 11:56:26 +0300 Subject: [PATCH 012/288] Add static modifier --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 4f1795bc6..86722316f 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.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; @@ -63,7 +63,7 @@ public Func CreatePredicate(string operationIds) /// /// /// - public OpenApiDocument CreateFilteredDocument(OpenApiDocument source, string title, string graphVersion, Func predicate) + public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, string title, string graphVersion, Func predicate) { var subset = new OpenApiDocument { From d5b1b5e3c61547259f1aa6704c1533ca0c337c6d Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 18 Oct 2021 12:10:27 +0300 Subject: [PATCH 013/288] Clean up and add xml comments --- .../Services/OpenApiFilterService.cs | 36 +++++++++---------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 86722316f..49cecd41e 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.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; @@ -9,26 +9,21 @@ namespace Microsoft.OpenApi.Services { /// - /// + /// A service that slices an OpenApiDocument into a subset document /// - public class OpenApiFilterService + public static class OpenApiFilterService { public static readonly string GraphAuthorizationUrl = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"; public static readonly string GraphTokenUrl = "https://login.microsoftonline.com/common/oauth2/v2.0/token"; public static readonly string GraphUrl = "https://graph.microsoft.com/{0}/"; public const string GraphVersion_V1 = "v1.0"; - - public OpenApiDocument CreateSubsetOpenApiDocument(string operationIds, OpenApiDocument source, string title) - { - var predicate = CreatePredicate(operationIds); - - var subsetOpenApiDocument = CreateFilteredDocument(source, title, GraphVersion_V1, predicate); - - return subsetOpenApiDocument; - } - - public Func CreatePredicate(string operationIds) + /// + /// Create predicate function based on passed query parameters + /// + /// Comma delimited list of operationIds or * for all operations. + /// A predicate. + public static Func CreatePredicate(string operationIds) { string predicateSource = null; @@ -55,14 +50,15 @@ public Func CreatePredicate(string operationIds) return predicate; } + /// - /// + /// Create partial OpenAPI document based on the provided predicate. /// - /// - /// - /// - /// - /// + /// The target . + /// The OpenAPI document title. + /// Version of the target Microsoft Graph API. + /// A predicate function. + /// A partial OpenAPI document. public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, string title, string graphVersion, Func predicate) { var subset = new OpenApiDocument From 4016ba1fe3a09bbb1fade1e3d43ea5e8bdbb97b5 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 18 Oct 2021 12:37:34 +0300 Subject: [PATCH 014/288] Add a class that visits the OpenApi operations and returns the search results --- .../Services/OperationSearch.cs | 67 +++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 src/Microsoft.OpenApi/Services/OperationSearch.cs diff --git a/src/Microsoft.OpenApi/Services/OperationSearch.cs b/src/Microsoft.OpenApi/Services/OperationSearch.cs new file mode 100644 index 000000000..01b1b5f56 --- /dev/null +++ b/src/Microsoft.OpenApi/Services/OperationSearch.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System; +using System.Collections.Generic; +using System.Linq; +using Microsoft.OpenApi.Models; + +namespace Microsoft.OpenApi.Services +{ + public class OperationSearch : OpenApiVisitorBase + { + private readonly Func _predicate; + private readonly List _searchResults = new(); + + public IList SearchResults => _searchResults; + + public OperationSearch(Func predicate) + { + _predicate = predicate ?? throw new ArgumentNullException(nameof(predicate)); + } + + /// + /// Visits . + /// + /// The target . + public override void Visit(OpenApiOperation operation) + { + if (_predicate(operation)) + { + _searchResults.Add(new SearchResult() + { + Operation = operation, + CurrentKeys = CopyCurrentKeys(CurrentKeys) + }); + } + } + + /// + /// Visits list of . + /// + /// The target list of . + public override void Visit(IList parameters) + { + /* The Parameter.Explode property should be true + * if Parameter.Style == Form; but OData query params + * as used in Microsoft Graph implement explode: false + * ex: $select=id,displayName,givenName + */ + foreach (var parameter in parameters.Where(x => x.Style == ParameterStyle.Form)) + { + parameter.Explode = false; + } + + base.Visit(parameters); + } + + private static CurrentKeys CopyCurrentKeys(CurrentKeys currentKeys) + { + return new CurrentKeys + { + Path = currentKeys.Path, + Operation = currentKeys.Operation + }; + } + } +} From 73bef228c86b86abf96043855ecb981c2f39e720 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 18 Oct 2021 12:38:06 +0300 Subject: [PATCH 015/288] Add a search result object model --- src/Microsoft.OpenApi/Services/SearchResult.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 src/Microsoft.OpenApi/Services/SearchResult.cs diff --git a/src/Microsoft.OpenApi/Services/SearchResult.cs b/src/Microsoft.OpenApi/Services/SearchResult.cs new file mode 100644 index 000000000..2b7d9f94a --- /dev/null +++ b/src/Microsoft.OpenApi/Services/SearchResult.cs @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using Microsoft.OpenApi.Models; + +namespace Microsoft.OpenApi.Services +{ + public class SearchResult + { + public CurrentKeys CurrentKeys { get; set; } + public OpenApiOperation Operation { get; set; } + } +} From a1d46e57da451ac5d68ccc2b26f811b4cd607896 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 18 Oct 2021 12:43:03 +0300 Subject: [PATCH 016/288] Copies OpenApiOperation references to the new subset document --- .../Services/CopyReferences.cs | 101 ++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 src/Microsoft.OpenApi/Services/CopyReferences.cs diff --git a/src/Microsoft.OpenApi/Services/CopyReferences.cs b/src/Microsoft.OpenApi/Services/CopyReferences.cs new file mode 100644 index 000000000..9fc25b210 --- /dev/null +++ b/src/Microsoft.OpenApi/Services/CopyReferences.cs @@ -0,0 +1,101 @@ +using System.Collections.Generic; +using Microsoft.OpenApi.Interfaces; +using Microsoft.OpenApi.Models; + +namespace Microsoft.OpenApi.Services +{ + internal class CopyReferences : OpenApiVisitorBase + { + private readonly OpenApiDocument target; + public OpenApiComponents Components = new OpenApiComponents(); + + public CopyReferences(OpenApiDocument target) + { + this.target = target; + } + + public override void Visit(IOpenApiReferenceable referenceable) + { + switch (referenceable) + { + case OpenApiSchema schema: + EnsureComponentsExists(); + EnsureSchemasExists(); + if (!Components.Schemas.ContainsKey(schema.Reference.Id)) + { + Components.Schemas.Add(schema.Reference.Id, schema); + } + break; + + case OpenApiParameter parameter: + EnsureComponentsExists(); + EnsureParametersExists(); + if (!Components.Parameters.ContainsKey(parameter.Reference.Id)) + { + Components.Parameters.Add(parameter.Reference.Id, parameter); + } + break; + + case OpenApiResponse response: + EnsureComponentsExists(); + EnsureResponsesExists(); + if (!Components.Responses.ContainsKey(response.Reference.Id)) + { + Components.Responses.Add(response.Reference.Id, response); + } + break; + + default: + break; + } + base.Visit(referenceable); + } + + public override void Visit(OpenApiSchema schema) + { + // This is needed to handle schemas used in Responses in components + if (schema.Reference != null) + { + EnsureComponentsExists(); + EnsureSchemasExists(); + if (!Components.Schemas.ContainsKey(schema.Reference.Id)) + { + Components.Schemas.Add(schema.Reference.Id, schema); + } + } + base.Visit(schema); + } + + private void EnsureComponentsExists() + { + if (target.Components == null) + { + target.Components = new OpenApiComponents(); + } + } + + private void EnsureSchemasExists() + { + if (target.Components.Schemas == null) + { + target.Components.Schemas = new Dictionary(); + } + } + + private void EnsureParametersExists() + { + if (target.Components.Parameters == null) + { + target.Components.Parameters = new Dictionary(); + } + } + + private void EnsureResponsesExists() + { + if (target.Components.Responses == null) + { + target.Components.Responses = new Dictionary(); + } + } + } +} From b3c79eb037df7027f9dc8456d92b17add26e1414 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 20 Oct 2021 09:57:44 +0300 Subject: [PATCH 017/288] Copy OpenApiInfo and components from the source document to the new subset doc --- .../Services/OpenApiFilterService.cs | 35 ++++--------------- 1 file changed, 7 insertions(+), 28 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 49cecd41e..37f7f5610 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -13,11 +13,6 @@ namespace Microsoft.OpenApi.Services /// public static class OpenApiFilterService { - public static readonly string GraphAuthorizationUrl = "https://login.microsoftonline.com/common/oauth2/v2.0/authorize"; - public static readonly string GraphTokenUrl = "https://login.microsoftonline.com/common/oauth2/v2.0/token"; - public static readonly string GraphUrl = "https://graph.microsoft.com/{0}/"; - public const string GraphVersion_V1 = "v1.0"; - /// /// Create predicate function based on passed query parameters /// @@ -55,41 +50,25 @@ public static Func CreatePredicate(string operationIds) /// Create partial OpenAPI document based on the provided predicate. /// /// The target . - /// The OpenAPI document title. - /// Version of the target Microsoft Graph API. /// A predicate function. /// A partial OpenAPI document. - public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, string title, string graphVersion, Func predicate) + public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Func predicate) { + // Fetch and copy title, graphVersion and server info from OpenApiDoc var subset = new OpenApiDocument { Info = new OpenApiInfo() { - Title = title, - Version = graphVersion + Title = source.Info.Title, + Version = source.Info.Version }, Components = new OpenApiComponents() }; - var aadv2Scheme = new OpenApiSecurityScheme() - { - Type = SecuritySchemeType.OAuth2, - Flows = new OpenApiOAuthFlows() - { - AuthorizationCode = new OpenApiOAuthFlow() - { - AuthorizationUrl = new Uri(GraphAuthorizationUrl), - TokenUrl = new Uri(GraphTokenUrl) - } - }, - Reference = new OpenApiReference() { Id = "azureaadv2", Type = ReferenceType.SecurityScheme }, - UnresolvedReference = false - }; - subset.Components.SecuritySchemes.Add("azureaadv2", aadv2Scheme); - - subset.SecurityRequirements.Add(new OpenApiSecurityRequirement() { { aadv2Scheme, Array.Empty() } }); - subset.Servers.Add(new OpenApiServer() { Description = "Core", Url = string.Format(GraphUrl, graphVersion) }); + subset.Components.SecuritySchemes = source.Components.SecuritySchemes; + subset.SecurityRequirements = source.SecurityRequirements; + subset.Servers = source.Servers; var results = FindOperations(source, predicate); foreach (var result in results) From cd5f3faff6dd1e962cdaf103513f5e520950af34 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 20 Oct 2021 09:58:00 +0300 Subject: [PATCH 018/288] Add an info object to the mock document --- .../Microsoft.OpenApi.Tests/Documents/OpenApiDocumentMock.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/Microsoft.OpenApi.Tests/Documents/OpenApiDocumentMock.cs b/test/Microsoft.OpenApi.Tests/Documents/OpenApiDocumentMock.cs index 8b354b36f..676bf8e65 100644 --- a/test/Microsoft.OpenApi.Tests/Documents/OpenApiDocumentMock.cs +++ b/test/Microsoft.OpenApi.Tests/Documents/OpenApiDocumentMock.cs @@ -23,6 +23,11 @@ public static OpenApiDocument CreateOpenApiDocument() var document = new OpenApiDocument() { + Info = new OpenApiInfo() + { + Title = "People", + Version = "v1.0" + }, Paths = new OpenApiPaths() { ["/"] = new OpenApiPathItem() // root path From 3c43ea176ac08db90ea02b561a8fb75092935595 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 20 Oct 2021 09:58:22 +0300 Subject: [PATCH 019/288] Clean up: Remove unnecessary params --- src/Microsoft.OpenApi.Tool/OpenApiService.cs | 5 +---- .../Services/OpenApiFilterServiceTests.cs | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.OpenApi.Tool/OpenApiService.cs b/src/Microsoft.OpenApi.Tool/OpenApiService.cs index 7b56f4516..fe1a9d9b4 100644 --- a/src/Microsoft.OpenApi.Tool/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Tool/OpenApiService.cs @@ -16,9 +16,6 @@ namespace Microsoft.OpenApi.Tool { static class OpenApiService { - public const string GraphVersion_V1 = "v1.0"; - public const string Title = "Partial Graph API"; - public static void ProcessOpenApiDocument( string input, FileInfo output, @@ -50,7 +47,7 @@ public static void ProcessOpenApiDocument( if (!string.IsNullOrEmpty(filterbyOperationId)) { var predicate = OpenApiFilterService.CreatePredicate(filterbyOperationId); - document = OpenApiFilterService.CreateFilteredDocument(document, Title, GraphVersion_V1, predicate); + document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } var context = result.OpenApiDiagnostic; diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs index 4f6a9bcbf..308f00952 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs @@ -11,8 +11,6 @@ namespace Microsoft.OpenApi.Tests.Services { public class OpenApiFilterServiceTests { - private const string Title = "Partial Graph API"; - private const string GraphVersion = "mock"; private readonly OpenApiDocument _openApiDocumentMock; public OpenApiFilterServiceTests() @@ -29,7 +27,7 @@ public void ReturnFilteredOpenApiDocumentBasedOnOperationIds(string operationId) { // Act var predicate = OpenApiFilterService.CreatePredicate(operationId); - var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(_openApiDocumentMock, Title, GraphVersion, predicate); + var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(_openApiDocumentMock, predicate); // Assert Assert.NotNull(subsetOpenApiDocument); From 43f48ec9fc5caf2ed4a4b5b9b973b1b2c738de78 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 21 Oct 2021 23:11:11 +0300 Subject: [PATCH 020/288] Remove package reference --- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 4d305cfdc..e16b84db0 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -38,7 +38,6 @@ - From 77063ae270bd5c22fa63fba3e3ddb7aeefb5da0b Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 25 Oct 2021 16:20:49 +0300 Subject: [PATCH 021/288] Add test cases for filtering OpenApiDocument by tags provided --- .../Services/OpenApiFilterServiceTests.cs | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs index 308f00952..9676bd1f4 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs @@ -19,19 +19,28 @@ public OpenApiFilterServiceTests() } [Theory] - [InlineData("users.user.ListUser")] - [InlineData("users.user.GetUser")] - [InlineData("administrativeUnits.restore")] - [InlineData("graphService.GetGraphService")] - public void ReturnFilteredOpenApiDocumentBasedOnOperationIds(string operationId) + [InlineData("users.user.ListUser", null)] + [InlineData("users.user.GetUser", null)] + [InlineData("administrativeUnits.restore", null)] + [InlineData("graphService.GetGraphService", null)] + [InlineData(null, "users.user")] + [InlineData(null, "applications.application")] + public void ReturnFilteredOpenApiDocumentBasedOnOperationIds(string operationIds, string tags) { // Act - var predicate = OpenApiFilterService.CreatePredicate(operationId); + var predicate = OpenApiFilterService.CreatePredicate(operationIds, tags); var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(_openApiDocumentMock, predicate); // Assert Assert.NotNull(subsetOpenApiDocument); - Assert.Single(subsetOpenApiDocument.Paths); + if (!string.IsNullOrEmpty(operationIds)) + { + Assert.Single(subsetOpenApiDocument.Paths); + } + else if (!string.IsNullOrEmpty(tags)) + { + Assert.NotEmpty(subsetOpenApiDocument.Paths); + } } [Fact] From 8a60acf2958548eebf3bd1f935f6fcdb6f31f40d Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 25 Oct 2021 16:21:49 +0300 Subject: [PATCH 022/288] Add --filterByTag command option --- src/Microsoft.OpenApi.Tool/Program.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Tool/Program.cs b/src/Microsoft.OpenApi.Tool/Program.cs index 938986350..5eaedbde8 100644 --- a/src/Microsoft.OpenApi.Tool/Program.cs +++ b/src/Microsoft.OpenApi.Tool/Program.cs @@ -26,9 +26,10 @@ static async Task Main(string[] args) new Option("--format", "File format",typeof(OpenApiFormat) ), new Option("--inline", "Inline $ref instances", typeof(bool) ), new Option("--resolveExternal","Resolve external $refs", typeof(bool)), - new Option("--filterByOperationId", "Filters by OperationId provided", typeof(string)) + new Option("--filterByOperationId", "Filters OpenApiDocument by OperationId provided", typeof(string)), + new Option("--filterByTag", "Filters OpenApiDocument by Tag(s) provided", typeof(string)) }; - transformCommand.Handler = CommandHandler.Create( + transformCommand.Handler = CommandHandler.Create( OpenApiService.ProcessOpenApiDocument); rootCommand.Add(transformCommand); From c4aed08331877db063c0d44009684b096c088b61 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 25 Oct 2021 16:26:01 +0300 Subject: [PATCH 023/288] Add a tags parameter to the filtering service to allow for slicing of OpenApiDocument based on tags provided --- .../Services/OpenApiFilterService.cs | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 37f7f5610..94458fc83 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Text.RegularExpressions; using Microsoft.OpenApi.Models; namespace Microsoft.OpenApi.Services @@ -17,8 +18,9 @@ public static class OpenApiFilterService /// Create predicate function based on passed query parameters /// /// Comma delimited list of operationIds or * for all operations. + /// Comma delimited list of tags or a single regex. /// A predicate. - public static Func CreatePredicate(string operationIds) + public static Func CreatePredicate(string operationIds = null, string tags = null) { string predicateSource = null; @@ -37,10 +39,26 @@ public static Func CreatePredicate(string operationIds) predicateSource = $"operationIds: {operationIds}"; } + else if (tags != null) + { + var tagsArray = tags.Split(','); + if (tagsArray.Length == 1) + { + var regex = new Regex(tagsArray[0]); + + predicate = (o) => o.Tags.Any(t => regex.IsMatch(t.Name)); + } + else + { + predicate = (o) => o.Tags.Any(t => tagsArray.Contains(t.Name)); + } + + predicateSource = $"tags: {tags}"; + } else { - throw new InvalidOperationException("OperationId needs to be specified."); + throw new InvalidOperationException("Either operationId(s) or tag(s) need to be specified."); } return predicate; From 849d84182230e4f44db0e78e84c98c56b9e5959f Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 25 Oct 2021 16:26:30 +0300 Subject: [PATCH 024/288] Add a filterByTag param and logic --- src/Microsoft.OpenApi.Tool/OpenApiService.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Tool/OpenApiService.cs b/src/Microsoft.OpenApi.Tool/OpenApiService.cs index fe1a9d9b4..4bc28adcf 100644 --- a/src/Microsoft.OpenApi.Tool/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Tool/OpenApiService.cs @@ -21,7 +21,8 @@ public static void ProcessOpenApiDocument( FileInfo output, OpenApiSpecVersion version, OpenApiFormat format, - string filterbyOperationId, + string filterbyOperationIds, + string filterByTags, bool inline, bool resolveExternal) { @@ -44,9 +45,9 @@ public static void ProcessOpenApiDocument( document = result.OpenApiDocument; // Check if filter options are provided, then execute - if (!string.IsNullOrEmpty(filterbyOperationId)) + if (!string.IsNullOrEmpty(filterbyOperationIds) || !string.IsNullOrEmpty(filterByTags)) { - var predicate = OpenApiFilterService.CreatePredicate(filterbyOperationId); + var predicate = OpenApiFilterService.CreatePredicate(filterbyOperationIds, filterByTags); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } From 1553a0c862c029a31a45f047cb6920b01e95a6c9 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 26 Oct 2021 09:36:36 +0300 Subject: [PATCH 025/288] Code refactoring --- src/Microsoft.OpenApi.Tool/OpenApiService.cs | 9 +++++++-- src/Microsoft.OpenApi.Tool/Program.cs | 4 ++-- .../Services/OpenApiFilterServiceTests.cs | 5 +++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.OpenApi.Tool/OpenApiService.cs b/src/Microsoft.OpenApi.Tool/OpenApiService.cs index 4bc28adcf..317306a1f 100644 --- a/src/Microsoft.OpenApi.Tool/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Tool/OpenApiService.cs @@ -45,9 +45,14 @@ public static void ProcessOpenApiDocument( document = result.OpenApiDocument; // Check if filter options are provided, then execute - if (!string.IsNullOrEmpty(filterbyOperationIds) || !string.IsNullOrEmpty(filterByTags)) + if (!string.IsNullOrEmpty(filterbyOperationIds)) { - var predicate = OpenApiFilterService.CreatePredicate(filterbyOperationIds, filterByTags); + var predicate = OpenApiFilterService.CreatePredicate(operationIds: filterbyOperationIds); + document = OpenApiFilterService.CreateFilteredDocument(document, predicate); + } + if (!string.IsNullOrEmpty(filterByTags)) + { + var predicate = OpenApiFilterService.CreatePredicate(tags: filterByTags); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } diff --git a/src/Microsoft.OpenApi.Tool/Program.cs b/src/Microsoft.OpenApi.Tool/Program.cs index 5eaedbde8..ae3967181 100644 --- a/src/Microsoft.OpenApi.Tool/Program.cs +++ b/src/Microsoft.OpenApi.Tool/Program.cs @@ -26,8 +26,8 @@ static async Task Main(string[] args) new Option("--format", "File format",typeof(OpenApiFormat) ), new Option("--inline", "Inline $ref instances", typeof(bool) ), new Option("--resolveExternal","Resolve external $refs", typeof(bool)), - new Option("--filterByOperationId", "Filters OpenApiDocument by OperationId provided", typeof(string)), - new Option("--filterByTag", "Filters OpenApiDocument by Tag(s) provided", typeof(string)) + new Option("--filterByOperationIds", "Filters OpenApiDocument by OperationId provided", typeof(string)), + new Option("--filterByTags", "Filters OpenApiDocument by Tag(s) provided", typeof(string)) }; transformCommand.Handler = CommandHandler.Create( OpenApiService.ProcessOpenApiDocument); diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs index 9676bd1f4..058fc8c42 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs @@ -25,6 +25,7 @@ public OpenApiFilterServiceTests() [InlineData("graphService.GetGraphService", null)] [InlineData(null, "users.user")] [InlineData(null, "applications.application")] + [InlineData(null, "reports.Functions")] public void ReturnFilteredOpenApiDocumentBasedOnOperationIds(string operationIds, string tags) { // Act @@ -47,8 +48,8 @@ public void ReturnFilteredOpenApiDocumentBasedOnOperationIds(string operationIds public void ThrowsInvalidOperationExceptionInCreatePredicateWhenInvalidOperationIdIsSpecified() { // Act and Assert - var message = Assert.Throws(() =>OpenApiFilterService.CreatePredicate(null)).Message; - Assert.Equal("OperationId needs to be specified.", message); + var message = Assert.Throws(() =>OpenApiFilterService.CreatePredicate(null, null)).Message; + Assert.Equal("Either operationId(s) or tag(s) need to be specified.", message); } } } From 8ba33cdbba85b5ce517168e7554e7a503efe6891 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 21 Oct 2021 23:11:11 +0300 Subject: [PATCH 026/288] Revert "Remove package reference" This reverts commit 43f48ec9fc5caf2ed4a4b5b9b973b1b2c738de78. --- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index e16b84db0..4d305cfdc 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -38,6 +38,7 @@ + From 2397e9d94370f212668e10eb3eecb21354cc7350 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 26 Oct 2021 17:09:23 +0300 Subject: [PATCH 027/288] Update the Public API interface text file --- .../PublicApi/PublicApi.approved.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index d5a89e586..180a7fd81 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -954,6 +954,11 @@ namespace Microsoft.OpenApi.Services public string Response { get; set; } public string ServerVariable { get; } } + public static class OpenApiFilterService + { + public static Microsoft.OpenApi.Models.OpenApiDocument CreateFilteredDocument(Microsoft.OpenApi.Models.OpenApiDocument source, System.Func predicate) { } + public static System.Func CreatePredicate(string operationIds) { } + } public class OpenApiReferenceError : Microsoft.OpenApi.Models.OpenApiError { public OpenApiReferenceError(Microsoft.OpenApi.Exceptions.OpenApiException exception) { } @@ -1044,6 +1049,19 @@ namespace Microsoft.OpenApi.Services public System.IO.Stream GetArtifact(string location) { } public Microsoft.OpenApi.Interfaces.IOpenApiReferenceable ResolveReference(Microsoft.OpenApi.Models.OpenApiReference reference) { } } + public class OperationSearch : Microsoft.OpenApi.Services.OpenApiVisitorBase + { + public OperationSearch(System.Func predicate) { } + public System.Collections.Generic.IList SearchResults { get; } + public override void Visit(Microsoft.OpenApi.Models.OpenApiOperation operation) { } + public override void Visit(System.Collections.Generic.IList parameters) { } + } + public class SearchResult + { + public SearchResult() { } + public Microsoft.OpenApi.Services.CurrentKeys CurrentKeys { get; set; } + public Microsoft.OpenApi.Models.OpenApiOperation Operation { get; set; } + } } namespace Microsoft.OpenApi.Validations { From d13dcf41f987fba5585cfe8186bde9a47a689b20 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 26 Oct 2021 17:09:50 +0300 Subject: [PATCH 028/288] Remove unnecessary package dependency --- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 4d305cfdc..9c36ab07c 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -37,7 +37,6 @@ - From ad0bda07c819f112c4141d7122429db81aeaaf98 Mon Sep 17 00:00:00 2001 From: Peter Ritchie Date: Fri, 29 Oct 2021 13:59:56 -0700 Subject: [PATCH 029/288] Fixed spelling of "Path" (from "Past") --- .../Validations/OpenApiParameterValidationTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs index 41a9a6ab0..a7abfd9d8 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs @@ -218,7 +218,7 @@ public void PathParameterNotInThePathShouldReturnAnError() } [Fact] - public void PathParameterInThePastShouldBeOk() + public void PathParameterInThePathShouldBeOk() { // Arrange IEnumerable errors; From 89cc609f419df85a48008391e0f1dbc671967fed Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sun, 31 Oct 2021 21:30:09 -0400 Subject: [PATCH 030/288] Fixed inlining settings --- .../OpenApiStreamReader.cs | 7 ++ .../EnumBindingSourceExtension.cs | 53 ++++++++++ src/Microsoft.OpenApi.Workbench/MainModel.cs | 98 +++++++++++++++---- .../MainWindow.xaml | 5 +- .../MainWindow.xaml.cs | 11 ++- .../Microsoft.OpenApi.Workbench.csproj | 1 + .../Models/OpenApiCallback.cs | 2 +- .../Models/OpenApiComponents.cs | 2 +- .../Models/OpenApiDocument.cs | 2 +- .../Models/OpenApiExample.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiHeader.cs | 4 +- src/Microsoft.OpenApi/Models/OpenApiLink.cs | 2 +- .../Models/OpenApiParameter.cs | 4 +- .../Models/OpenApiPathItem.cs | 4 +- .../Models/OpenApiResponse.cs | 4 +- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 4 +- .../Writers/OpenApiWriterSettings.cs | 54 +++++++++- .../OpenApiWorkspaceStreamTests.cs | 6 +- .../PublicApi/PublicApi.approved.txt | 4 + .../Writers/OpenApiYamlWriterTests.cs | 8 +- 20 files changed, 229 insertions(+), 48 deletions(-) create mode 100644 src/Microsoft.OpenApi.Workbench/EnumBindingSourceExtension.cs diff --git a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs index cab5d1a83..7f721cadd 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.IO; using System.Threading.Tasks; using Microsoft.OpenApi.Interfaces; @@ -23,6 +24,12 @@ public class OpenApiStreamReader : IOpenApiReader public OpenApiStreamReader(OpenApiReaderSettings settings = null) { _settings = settings ?? new OpenApiReaderSettings(); + + if(_settings.ReferenceResolution == ReferenceResolutionSetting.ResolveAllReferences + && _settings.BaseUrl == null) + { + throw new ArgumentException("BaseUrl must be provided to resolve external references."); + } } /// diff --git a/src/Microsoft.OpenApi.Workbench/EnumBindingSourceExtension.cs b/src/Microsoft.OpenApi.Workbench/EnumBindingSourceExtension.cs new file mode 100644 index 000000000..d1f8bd798 --- /dev/null +++ b/src/Microsoft.OpenApi.Workbench/EnumBindingSourceExtension.cs @@ -0,0 +1,53 @@ +// Thanks Brian! https://brianlagunas.com/a-better-way-to-data-bind-enums-in-wpf/ +using System; +using System.Windows.Markup; + +namespace Microsoft.OpenApi.Workbench +{ + public class EnumBindingSourceExtension : MarkupExtension + { + private Type _enumType; + public Type EnumType + { + get { return this._enumType; } + set + { + if (value != this._enumType) + { + if (null != value) + { + Type enumType = Nullable.GetUnderlyingType(value) ?? value; + if (!enumType.IsEnum) + throw new ArgumentException("Type must be for an Enum."); + } + + this._enumType = value; + } + } + } + + public EnumBindingSourceExtension() { } + + public EnumBindingSourceExtension(Type enumType) + { + this.EnumType = enumType; + } + + public override object ProvideValue(IServiceProvider serviceProvider) + { + if (null == this._enumType) + throw new InvalidOperationException("The EnumType must be specified."); + + Type actualEnumType = Nullable.GetUnderlyingType(this._enumType) ?? this._enumType; + Array enumValues = Enum.GetValues(actualEnumType); + + if (actualEnumType == this._enumType) + return enumValues; + + Array tempArray = Array.CreateInstance(actualEnumType, enumValues.Length + 1); + enumValues.CopyTo(tempArray, 1); + return tempArray; + } + } + +} diff --git a/src/Microsoft.OpenApi.Workbench/MainModel.cs b/src/Microsoft.OpenApi.Workbench/MainModel.cs index 6304b7f23..70074736b 100644 --- a/src/Microsoft.OpenApi.Workbench/MainModel.cs +++ b/src/Microsoft.OpenApi.Workbench/MainModel.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; @@ -6,7 +6,9 @@ using System.Diagnostics; using System.Globalization; using System.IO; +using System.Net.Http; using System.Text; +using System.Threading.Tasks; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers; @@ -23,6 +25,11 @@ public class MainModel : INotifyPropertyChanged { private string _input; + private bool _inlineLocal = false; + private bool _inlineExternal = false; + + private bool _resolveExternal = false; + private string _inputFile; private string _output; @@ -33,11 +40,7 @@ public class MainModel : INotifyPropertyChanged private string _renderTime; - /// - /// Default format. - /// - private bool _Inline = false; - + /// /// Default format. /// @@ -48,6 +51,9 @@ public class MainModel : INotifyPropertyChanged /// private OpenApiSpecVersion _version = OpenApiSpecVersion.OpenApi3_0; + + private HttpClient _httpClient = new HttpClient(); + public string Input { get => _input; @@ -58,6 +64,16 @@ public string Input } } + public bool ResolveExternal + { + get => _resolveExternal; + set + { + _resolveExternal = value; + OnPropertyChanged(nameof(ResolveExternal)); + } + } + public string InputFile { get => _inputFile; @@ -67,7 +83,6 @@ public string InputFile OnPropertyChanged(nameof(InputFile)); } } - public string Output { get => _output; @@ -119,13 +134,23 @@ public OpenApiFormat Format } } - public bool Inline + public bool InlineLocal + { + get => _inlineLocal; + set + { + _inlineLocal = value; + OnPropertyChanged(nameof(InlineLocal)); + } + } + + public bool InlineExternal { - get => _Inline; + get => _inlineExternal; set { - _Inline = value; - OnPropertyChanged(nameof(Inline)); + _inlineExternal = value; + OnPropertyChanged(nameof(InlineExternal)); } } @@ -180,17 +205,28 @@ protected void OnPropertyChanged(string propertyName) /// The core method of the class. /// Runs the parsing and serializing. /// - internal void ParseDocument() + internal async Task ParseDocument() { + Stream stream = null; try { - Stream stream; - if (!String.IsNullOrWhiteSpace(_inputFile)) + if (!string.IsNullOrWhiteSpace(_inputFile)) { - stream = new FileStream(_inputFile, FileMode.Open); + if (_inputFile.StartsWith("http")) + { + stream = await _httpClient.GetStreamAsync(_inputFile); + } + else + { + stream = new FileStream(_inputFile, FileMode.Open); + } } else { + if (ResolveExternal) + { + throw new ArgumentException("Input file must be used to resolve external references"); + } stream = CreateStream(_input); } @@ -198,12 +234,27 @@ internal void ParseDocument() var stopwatch = new Stopwatch(); stopwatch.Start(); - var document = new OpenApiStreamReader(new OpenApiReaderSettings + var settings = new OpenApiReaderSettings { - ReferenceResolution = ReferenceResolutionSetting.ResolveLocalReferences, + ReferenceResolution = ResolveExternal ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, RuleSet = ValidationRuleSet.GetDefaultRuleSet() + }; + if (ResolveExternal) + { + if (_inputFile.StartsWith("http")) + { + settings.BaseUrl = new Uri(_inputFile); + } + else + { + settings.BaseUrl = new Uri("file://" + Path.GetDirectoryName(_inputFile) + "/"); + } } - ).Read(stream, out var context); + var readResult = await new OpenApiStreamReader(settings + ).ReadAsync(stream); + var document = readResult.OpenApiDocument; + var context = readResult.OpenApiDiagnostic; + stopwatch.Stop(); ParseTime = $"{stopwatch.ElapsedMilliseconds} ms"; @@ -241,6 +292,14 @@ internal void ParseDocument() Output = string.Empty; Errors = "Failed to parse input: " + ex.Message; } + finally { + if (stream != null) + { + stream.Close(); + stream.Dispose(); + } + + } } /// @@ -255,7 +314,8 @@ private string WriteContents(OpenApiDocument document) Version, Format, new OpenApiWriterSettings() { - ReferenceInline = this.Inline == true ? ReferenceInlineSetting.InlineLocalReferences : ReferenceInlineSetting.DoNotInlineReferences + InlineLocalReferences = InlineLocal, + InlineExternalReferences = InlineExternal }); outputStream.Position = 0; diff --git a/src/Microsoft.OpenApi.Workbench/MainWindow.xaml b/src/Microsoft.OpenApi.Workbench/MainWindow.xaml index daf8a2209..41a4f2543 100644 --- a/src/Microsoft.OpenApi.Workbench/MainWindow.xaml +++ b/src/Microsoft.OpenApi.Workbench/MainWindow.xaml @@ -4,6 +4,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:Microsoft.OpenApi.Workbench" + xmlns:writers="clr-namespace:Microsoft.OpenApi.Writers;assembly=Microsoft.OpenApi" mc:Ignorable="d" Title="OpenAPI Workbench" Height="600" Width="800"> @@ -42,7 +43,9 @@ - + + + diff --git a/src/Microsoft.OpenApi.Workbench/MainWindow.xaml.cs b/src/Microsoft.OpenApi.Workbench/MainWindow.xaml.cs index f33132359..08bbb177d 100644 --- a/src/Microsoft.OpenApi.Workbench/MainWindow.xaml.cs +++ b/src/Microsoft.OpenApi.Workbench/MainWindow.xaml.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.Windows; namespace Microsoft.OpenApi.Workbench @@ -18,9 +19,15 @@ public MainWindow() DataContext = _mainModel; } - private void Button_Click(object sender, RoutedEventArgs e) + private async void Button_Click(object sender, RoutedEventArgs e) { - _mainModel.ParseDocument(); + try + { + await _mainModel.ParseDocument(); + } catch (Exception ex) + { + _mainModel.Errors = ex.Message; + } } } } diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj index 47a9d6ffe..8d8239222 100644 --- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj +++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj @@ -58,6 +58,7 @@ MSBuild:Compile Designer + MSBuild:Compile diff --git a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs index 4f685d2de..644334ab4 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs @@ -70,7 +70,7 @@ public void SerializeAsV3(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && writer.GetSettings().ReferenceInline != ReferenceInlineSetting.InlineLocalReferences) + if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) { Reference.SerializeAsV3(writer); return; diff --git a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs index 08b8bd020..cd8cdae74 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiComponents.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiComponents.cs @@ -80,7 +80,7 @@ public void SerializeAsV3(IOpenApiWriter writer) // If references have been inlined we don't need the to render the components section // however if they have cycles, then we will need a component rendered - if (writer.GetSettings().ReferenceInline != ReferenceInlineSetting.DoNotInlineReferences) + if (writer.GetSettings().InlineLocalReferences) { var loops = writer.GetSettings().LoopDetector.Loops; writer.WriteStartObject(); diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 0db9b2391..4f4e673af 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -135,7 +135,7 @@ public void SerializeAsV2(IOpenApiWriter writer) // If references have been inlined we don't need the to render the components section // however if they have cycles, then we will need a component rendered - if (writer.GetSettings().ReferenceInline != ReferenceInlineSetting.DoNotInlineReferences) + if (writer.GetSettings().InlineLocalReferences) { var loops = writer.GetSettings().LoopDetector.Loops; diff --git a/src/Microsoft.OpenApi/Models/OpenApiExample.cs b/src/Microsoft.OpenApi/Models/OpenApiExample.cs index d9bc08e30..787c2972e 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExample.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExample.cs @@ -64,7 +64,7 @@ public void SerializeAsV3(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && writer.GetSettings().ReferenceInline != ReferenceInlineSetting.InlineLocalReferences) + if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) { Reference.SerializeAsV3(writer); return; diff --git a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs index eb6736183..d94681a1c 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs @@ -96,7 +96,7 @@ public void SerializeAsV3(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && writer.GetSettings().ReferenceInline != ReferenceInlineSetting.InlineLocalReferences) + if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) { Reference.SerializeAsV3(writer); return; @@ -161,7 +161,7 @@ public void SerializeAsV2(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && writer.GetSettings().ReferenceInline != ReferenceInlineSetting.InlineLocalReferences) + if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) { Reference.SerializeAsV2(writer); return; diff --git a/src/Microsoft.OpenApi/Models/OpenApiLink.cs b/src/Microsoft.OpenApi/Models/OpenApiLink.cs index fb7396db2..82502f14a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLink.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLink.cs @@ -71,7 +71,7 @@ public void SerializeAsV3(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && writer.GetSettings().ReferenceInline != ReferenceInlineSetting.InlineLocalReferences) + if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) { Reference.SerializeAsV3(writer); return; diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index 03b465109..50d78ae00 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -145,7 +145,7 @@ public void SerializeAsV3(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && writer.GetSettings().ReferenceInline != ReferenceInlineSetting.InlineLocalReferences) + if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) { Reference.SerializeAsV3(writer); return; @@ -216,7 +216,7 @@ public void SerializeAsV2(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && writer.GetSettings().ReferenceInline != ReferenceInlineSetting.InlineLocalReferences) + if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) { Reference.SerializeAsV2(writer); return; diff --git a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs index b222ba34f..78e97ec18 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs @@ -75,7 +75,7 @@ public void SerializeAsV3(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && writer.GetSettings().ReferenceInline != ReferenceInlineSetting.InlineAllReferences) + if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) { Reference.SerializeAsV3(writer); return; @@ -95,7 +95,7 @@ public void SerializeAsV2(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && writer.GetSettings().ReferenceInline != ReferenceInlineSetting.InlineAllReferences) + if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) { Reference.SerializeAsV2(writer); return; diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs index bc2e4e525..ef30602b9 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs @@ -61,7 +61,7 @@ public void SerializeAsV3(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && writer.GetSettings().ReferenceInline != ReferenceInlineSetting.InlineLocalReferences) + if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) { Reference.SerializeAsV3(writer); return; @@ -105,7 +105,7 @@ public void SerializeAsV2(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && writer.GetSettings().ReferenceInline != ReferenceInlineSetting.InlineLocalReferences) + if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) { Reference.SerializeAsV2(writer); return; diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 60e314fcf..1d579a89a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -255,7 +255,7 @@ public void SerializeAsV3(IOpenApiWriter writer) if (Reference != null) { - if (settings.ReferenceInline != ReferenceInlineSetting.InlineLocalReferences) + if (!settings.ShouldInlineReference(Reference)) { Reference.SerializeAsV3(writer); return; @@ -445,7 +445,7 @@ internal void SerializeAsV2( if (Reference != null) { var settings = writer.GetSettings(); - if (settings.ReferenceInline != ReferenceInlineSetting.InlineLocalReferences) + if (!settings.ShouldInlineReference(Reference)) { Reference.SerializeAsV2(writer); return; diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs index 45eedc831..458d8f4a3 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs @@ -1,36 +1,80 @@  +using System; +using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Services; namespace Microsoft.OpenApi.Writers { /// - /// Indicates if and when the reader should convert references into complete object renderings + /// Indicates if and when the writer should convert references into complete object renderings /// + [Obsolete("Use InlineLocalReference and InlineExternalReference settings instead")] public enum ReferenceInlineSetting { /// - /// Create placeholder objects with an OpenApiReference instance and UnresolvedReference set to true. + /// Render all references as $ref. /// DoNotInlineReferences, /// - /// Convert local references to references of valid domain objects. + /// Render all local references as inline objects /// InlineLocalReferences, /// - /// Convert all references to references of valid domain objects. + /// Render all references as inline objects. /// InlineAllReferences } + /// /// Configuration settings to control how OpenAPI documents are written /// public class OpenApiWriterSettings { + private ReferenceInlineSetting referenceInline = ReferenceInlineSetting.DoNotInlineReferences; + internal LoopDetector LoopDetector { get; } = new LoopDetector(); /// /// Indicates how references in the source document should be handled. /// - public ReferenceInlineSetting ReferenceInline { get; set; } = ReferenceInlineSetting.DoNotInlineReferences; + [Obsolete("Use InlineLocalReference and InlineExternalReference settings instead")] + public ReferenceInlineSetting ReferenceInline { + get { return referenceInline; } + set { + referenceInline = value; + switch(referenceInline) + { + case ReferenceInlineSetting.DoNotInlineReferences: + InlineLocalReferences = false; + InlineExternalReferences = false; + break; + case ReferenceInlineSetting.InlineLocalReferences: + InlineLocalReferences = true; + InlineExternalReferences = false; + break; + case ReferenceInlineSetting.InlineAllReferences: + InlineLocalReferences = true; + InlineExternalReferences = true; + break; + } + } + } + /// + /// Indicates if local references should be rendered as an inline object + /// + public bool InlineLocalReferences { get; set; } = false; + + /// + /// Indicates if external references should be rendered as an inline object + /// + public bool InlineExternalReferences { get; set; } = false; + + + internal bool ShouldInlineReference(OpenApiReference reference) + { + return (reference.IsLocal && InlineLocalReferences) + || (reference.IsExternal && InlineExternalReferences); + } + } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs index 4a35301c6..b3cbb8c6d 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs @@ -25,7 +25,8 @@ public async Task LoadingDocumentWithResolveAllReferencesShouldLoadDocumentIntoW var reader = new OpenApiStreamReader(new OpenApiReaderSettings() { ReferenceResolution = ReferenceResolutionSetting.ResolveAllReferences, - CustomExternalLoader = new MockLoader() + CustomExternalLoader = new MockLoader(), + BaseUrl = new Uri("file://c:\\") }); // Todo: this should be ReadAsync @@ -54,7 +55,8 @@ public async Task LoadDocumentWithExternalReferenceShouldLoadBothDocumentsIntoWo var reader = new OpenApiStreamReader(new OpenApiReaderSettings() { ReferenceResolution = ReferenceResolutionSetting.ResolveAllReferences, - CustomExternalLoader = new ResourceLoader() + CustomExternalLoader = new ResourceLoader(), + BaseUrl = new Uri("fie://c:\\") }); ReadResult result; diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index d5a89e586..e4c3f4282 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -1323,6 +1323,9 @@ namespace Microsoft.OpenApi.Writers public class OpenApiWriterSettings { public OpenApiWriterSettings() { } + public bool InlineExternalReferences { get; set; } + public bool InlineLocalReferences { get; set; } + [System.Obsolete("Use InlineLocalReference and InlineExternalReference settings instead")] public Microsoft.OpenApi.Writers.ReferenceInlineSetting ReferenceInline { get; set; } } public class OpenApiYamlWriter : Microsoft.OpenApi.Writers.OpenApiWriterBase @@ -1341,6 +1344,7 @@ namespace Microsoft.OpenApi.Writers public override void WriteValue(string value) { } protected override void WriteValueSeparator() { } } + [System.Obsolete("Use InlineLocalReference and InlineExternalReference settings instead")] public enum ReferenceInlineSetting { DoNotInlineReferences = 0, diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs index a73fdbb9b..29e8c7676 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs @@ -373,7 +373,7 @@ public void WriteInlineSchema() components: { }"; var outputString = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiYamlWriter(outputString, new OpenApiWriterSettings { ReferenceInline = ReferenceInlineSetting.InlineLocalReferences}); + var writer = new OpenApiYamlWriter(outputString, new OpenApiWriterSettings { InlineLocalReferences = true } ); // Act doc.SerializeAsV3(writer); @@ -409,7 +409,7 @@ public void WriteInlineSchemaV2() type: object"; var outputString = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiYamlWriter(outputString, new OpenApiWriterSettings { ReferenceInline = ReferenceInlineSetting.InlineLocalReferences }); + var writer = new OpenApiYamlWriter(outputString, new OpenApiWriterSettings { InlineLocalReferences = true }); // Act doc.SerializeAsV2(writer); @@ -515,7 +515,7 @@ public void WriteInlineRecursiveSchema() // Component schemas that are there due to cycles are still inlined because the items they reference may not exist in the components because they don't have cycles. var outputString = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiYamlWriter(outputString, new OpenApiWriterSettings { ReferenceInline = ReferenceInlineSetting.InlineLocalReferences }); + var writer = new OpenApiYamlWriter(outputString, new OpenApiWriterSettings { InlineLocalReferences = true }); // Act doc.SerializeAsV3(writer); @@ -629,7 +629,7 @@ public void WriteInlineRecursiveSchemav2() // Component schemas that are there due to cycles are still inlined because the items they reference may not exist in the components because they don't have cycles. var outputString = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiYamlWriter(outputString, new OpenApiWriterSettings { ReferenceInline = ReferenceInlineSetting.InlineLocalReferences }); + var writer = new OpenApiYamlWriter(outputString, new OpenApiWriterSettings { InlineLocalReferences = true }); // Act doc.SerializeAsV2(writer); From 00dd9c47202e66c3dc031cb5aab72a4c66d8e003 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 1 Nov 2021 10:49:02 +0300 Subject: [PATCH 031/288] Allow filtering for multiple operationIds --- src/Microsoft.OpenApi.Tool/OpenApiService.cs | 9 ++++----- src/Microsoft.OpenApi.Tool/Program.cs | 2 +- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.OpenApi.Tool/OpenApiService.cs b/src/Microsoft.OpenApi.Tool/OpenApiService.cs index fe1a9d9b4..fca5999a1 100644 --- a/src/Microsoft.OpenApi.Tool/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Tool/OpenApiService.cs @@ -1,5 +1,4 @@ -using System; -using System.Collections.Generic; +using System; using System.IO; using System.Linq; using System.Net; @@ -21,7 +20,7 @@ public static void ProcessOpenApiDocument( FileInfo output, OpenApiSpecVersion version, OpenApiFormat format, - string filterbyOperationId, + string filterByOperationIds, bool inline, bool resolveExternal) { @@ -44,9 +43,9 @@ public static void ProcessOpenApiDocument( document = result.OpenApiDocument; // Check if filter options are provided, then execute - if (!string.IsNullOrEmpty(filterbyOperationId)) + if (!string.IsNullOrEmpty(filterByOperationIds)) { - var predicate = OpenApiFilterService.CreatePredicate(filterbyOperationId); + var predicate = OpenApiFilterService.CreatePredicate(filterByOperationIds); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } diff --git a/src/Microsoft.OpenApi.Tool/Program.cs b/src/Microsoft.OpenApi.Tool/Program.cs index 938986350..570f2ea1e 100644 --- a/src/Microsoft.OpenApi.Tool/Program.cs +++ b/src/Microsoft.OpenApi.Tool/Program.cs @@ -26,7 +26,7 @@ static async Task Main(string[] args) new Option("--format", "File format",typeof(OpenApiFormat) ), new Option("--inline", "Inline $ref instances", typeof(bool) ), new Option("--resolveExternal","Resolve external $refs", typeof(bool)), - new Option("--filterByOperationId", "Filters by OperationId provided", typeof(string)) + new Option("--filterByOperationIds", "Filters by OperationId provided", typeof(string)) }; transformCommand.Handler = CommandHandler.Create( OpenApiService.ProcessOpenApiDocument); diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 37f7f5610..36a31fa26 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -59,7 +59,7 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun { Info = new OpenApiInfo() { - Title = source.Info.Title, + Title = source.Info.Title + " - subset", Version = source.Info.Version }, From 3f3dae04bdff4da9b3801b2f1acd016ee1922b5d Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 1 Nov 2021 10:49:59 +0300 Subject: [PATCH 032/288] Add check for writing to an already existing file --- src/Microsoft.OpenApi.Tool/OpenApiService.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Tool/OpenApiService.cs b/src/Microsoft.OpenApi.Tool/OpenApiService.cs index fca5999a1..34f51af64 100644 --- a/src/Microsoft.OpenApi.Tool/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Tool/OpenApiService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Linq; using System.Net; @@ -63,6 +63,11 @@ public static void ProcessOpenApiDocument( throw new ArgumentException(string.Join(Environment.NewLine, context.Errors.Select(e => e.Message).ToArray())); } + if (output.Exists) + { + throw new IOException("The file you're writing to already exists.Please input a new output path."); + } + using var outputStream = output?.Create(); var textWriter = outputStream != null ? new StreamWriter(outputStream) : Console.Out; From 5a3da1a0b5c6ac2fed216f642078c3ab6c23bfbf Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 1 Nov 2021 12:00:00 +0300 Subject: [PATCH 033/288] Code cleanup --- src/Microsoft.OpenApi.Tool/OpenApiService.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Tool/OpenApiService.cs b/src/Microsoft.OpenApi.Tool/OpenApiService.cs index b7972bc0a..2431856e8 100644 --- a/src/Microsoft.OpenApi.Tool/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Tool/OpenApiService.cs @@ -20,7 +20,7 @@ public static void ProcessOpenApiDocument( FileInfo output, OpenApiSpecVersion version, OpenApiFormat format, - string filterbyOperationIds, + string filterByOperationIds, string filterByTags, bool inline, bool resolveExternal) @@ -44,9 +44,14 @@ public static void ProcessOpenApiDocument( document = result.OpenApiDocument; // Check if filter options are provided, then execute - if (!string.IsNullOrEmpty(filterbyOperationIds)) + if (!string.IsNullOrEmpty(filterByOperationIds) && !string.IsNullOrEmpty(filterByTags)) { - var predicate = OpenApiFilterService.CreatePredicate(operationIds: filterbyOperationIds); + throw new InvalidOperationException("Cannot filter by operationIds and tags at the same time."); + } + + if (!string.IsNullOrEmpty(filterByOperationIds)) + { + var predicate = OpenApiFilterService.CreatePredicate(operationIds: filterByOperationIds); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } if (!string.IsNullOrEmpty(filterByTags)) From 9af85db99924d5bb712dd026737a2c928a6cafa0 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 1 Nov 2021 13:10:23 +0300 Subject: [PATCH 034/288] Update the 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 180a7fd81..0b681a8ec 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -957,7 +957,7 @@ namespace Microsoft.OpenApi.Services public static class OpenApiFilterService { public static Microsoft.OpenApi.Models.OpenApiDocument CreateFilteredDocument(Microsoft.OpenApi.Models.OpenApiDocument source, System.Func predicate) { } - public static System.Func CreatePredicate(string operationIds) { } + public static System.Func CreatePredicate(string operationIds = null, string tags = null) { } } public class OpenApiReferenceError : Microsoft.OpenApi.Models.OpenApiError { From f33d1f6b969e4c2d91009ab92e5f76468ac89553 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 2 Nov 2021 09:16:37 +0300 Subject: [PATCH 035/288] Add license header --- src/Microsoft.OpenApi.Tool/OpenApiService.cs | 5 ++++- src/Microsoft.OpenApi.Tool/Program.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Tool/OpenApiService.cs b/src/Microsoft.OpenApi.Tool/OpenApiService.cs index 2431856e8..895d4ff17 100644 --- a/src/Microsoft.OpenApi.Tool/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Tool/OpenApiService.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System; using System.IO; using System.Linq; using System.Net; diff --git a/src/Microsoft.OpenApi.Tool/Program.cs b/src/Microsoft.OpenApi.Tool/Program.cs index ae3967181..71507ad8b 100644 --- a/src/Microsoft.OpenApi.Tool/Program.cs +++ b/src/Microsoft.OpenApi.Tool/Program.cs @@ -1,4 +1,7 @@ -using System.CommandLine; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System.CommandLine; using System.CommandLine.Invocation; using System.IO; using System.Threading.Tasks; From 27ab7f7655bd74aa038534288d66e8bc8b22c801 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 2 Nov 2021 09:30:58 +0300 Subject: [PATCH 036/288] Copy over all Info properties --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 36a31fa26..1ef69ef18 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -59,7 +59,11 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun { Info = new OpenApiInfo() { - Title = source.Info.Title + " - subset", + Title = source.Info.Title + " - Subset", + Description = source.Info.Description, + TermsOfService = source.Info.TermsOfService, + Contact = source.Info.Contact, + License = source.Info.License, Version = source.Info.Version }, From c3c0abcd97d68aa4cae19776c4a02dab9377b413 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 2 Nov 2021 21:57:25 +0300 Subject: [PATCH 037/288] Add license header --- src/Microsoft.OpenApi.Tool/Program.cs | 5 ++++- src/Microsoft.OpenApi/Services/CopyReferences.cs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Tool/Program.cs b/src/Microsoft.OpenApi.Tool/Program.cs index 570f2ea1e..21be3406b 100644 --- a/src/Microsoft.OpenApi.Tool/Program.cs +++ b/src/Microsoft.OpenApi.Tool/Program.cs @@ -1,4 +1,7 @@ -using System.CommandLine; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System.CommandLine; using System.CommandLine.Invocation; using System.IO; using System.Threading.Tasks; diff --git a/src/Microsoft.OpenApi/Services/CopyReferences.cs b/src/Microsoft.OpenApi/Services/CopyReferences.cs index 9fc25b210..e1db1360d 100644 --- a/src/Microsoft.OpenApi/Services/CopyReferences.cs +++ b/src/Microsoft.OpenApi/Services/CopyReferences.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System.Collections.Generic; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; From dbd8d925f6ed24a3e20fb5e7008f2ff46b7e352b Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 2 Nov 2021 21:58:56 +0300 Subject: [PATCH 038/288] Clean up and add XML documentations for public methods --- src/Microsoft.OpenApi.Tool/OpenApiService.cs | 20 ++++++------ .../Services/CopyReferences.cs | 32 ++++++++++++------- .../Services/OpenApiFilterService.cs | 6 +--- 3 files changed, 32 insertions(+), 26 deletions(-) diff --git a/src/Microsoft.OpenApi.Tool/OpenApiService.cs b/src/Microsoft.OpenApi.Tool/OpenApiService.cs index 34f51af64..d9e9fa930 100644 --- a/src/Microsoft.OpenApi.Tool/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Tool/OpenApiService.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System; using System.IO; using System.Linq; using System.Net; @@ -24,9 +27,13 @@ public static void ProcessOpenApiDocument( bool inline, bool resolveExternal) { - if (input == null) + if (string.IsNullOrEmpty(input)) { - throw new ArgumentNullException("input"); + throw new ArgumentNullException(nameof(input)); + } + if (output.Exists) + { + throw new IOException("The file you're writing to already exists. Please input a new output path."); } var stream = GetStream(input); @@ -51,7 +58,7 @@ public static void ProcessOpenApiDocument( var context = result.OpenApiDiagnostic; - if (context.Errors.Count != 0) + if (context.Errors.Count > 0) { var errorReport = new StringBuilder(); @@ -63,11 +70,6 @@ public static void ProcessOpenApiDocument( throw new ArgumentException(string.Join(Environment.NewLine, context.Errors.Select(e => e.Message).ToArray())); } - if (output.Exists) - { - throw new IOException("The file you're writing to already exists.Please input a new output path."); - } - using var outputStream = output?.Create(); var textWriter = outputStream != null ? new StreamWriter(outputStream) : Console.Out; diff --git a/src/Microsoft.OpenApi/Services/CopyReferences.cs b/src/Microsoft.OpenApi/Services/CopyReferences.cs index e1db1360d..24dcfee25 100644 --- a/src/Microsoft.OpenApi/Services/CopyReferences.cs +++ b/src/Microsoft.OpenApi/Services/CopyReferences.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.Collections.Generic; @@ -9,14 +9,18 @@ namespace Microsoft.OpenApi.Services { internal class CopyReferences : OpenApiVisitorBase { - private readonly OpenApiDocument target; - public OpenApiComponents Components = new OpenApiComponents(); + private readonly OpenApiDocument _target; + public OpenApiComponents Components = new(); public CopyReferences(OpenApiDocument target) { - this.target = target; + _target = target; } + /// + /// Visits IOpenApiReferenceable instances that are references and not in components. + /// + /// An IOpenApiReferenceable object. public override void Visit(IOpenApiReferenceable referenceable) { switch (referenceable) @@ -54,6 +58,10 @@ public override void Visit(IOpenApiReferenceable referenceable) base.Visit(referenceable); } + /// + /// Visits + /// + /// The OpenApiSchema to be visited. public override void Visit(OpenApiSchema schema) { // This is needed to handle schemas used in Responses in components @@ -71,33 +79,33 @@ public override void Visit(OpenApiSchema schema) private void EnsureComponentsExists() { - if (target.Components == null) + if (_target.Components == null) { - target.Components = new OpenApiComponents(); + _target.Components = new OpenApiComponents(); } } private void EnsureSchemasExists() { - if (target.Components.Schemas == null) + if (_target.Components.Schemas == null) { - target.Components.Schemas = new Dictionary(); + _target.Components.Schemas = new Dictionary(); } } private void EnsureParametersExists() { - if (target.Components.Parameters == null) + if (_target.Components.Parameters == null) { - target.Components.Parameters = new Dictionary(); + _target.Components.Parameters = new Dictionary(); } } private void EnsureResponsesExists() { - if (target.Components.Responses == null) + if (_target.Components.Responses == null) { - target.Components.Responses = new Dictionary(); + _target.Components.Responses = new Dictionary(); } } } diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 1ef69ef18..ce347c234 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.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; @@ -20,8 +20,6 @@ public static class OpenApiFilterService /// A predicate. public static Func CreatePredicate(string operationIds) { - string predicateSource = null; - Func predicate; if (operationIds != null) { @@ -34,8 +32,6 @@ public static Func CreatePredicate(string operationIds) var operationIdsArray = operationIds.Split(','); predicate = (o) => operationIdsArray.Contains(o.OperationId); } - - predicateSource = $"operationIds: {operationIds}"; } else From a689c3631c212d2eccf22d6807ba5fbb413ad5cd Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 2 Nov 2021 21:59:20 +0300 Subject: [PATCH 039/288] Copy over extensions object to new document --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index ce347c234..4fd09314e 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.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; @@ -60,7 +60,8 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun TermsOfService = source.Info.TermsOfService, Contact = source.Info.Contact, License = source.Info.License, - Version = source.Info.Version + Version = source.Info.Version, + Extensions = source.Info.Extensions }, Components = new OpenApiComponents() From 8fbb809d4390d97ec32343ebf79abfcaea8108d9 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 2 Nov 2021 22:07:18 +0300 Subject: [PATCH 040/288] Update ci-build.yml for Azure Pipelines --- .azure-pipelines/ci-build.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 5649e50c5..3edcedeb8 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -94,6 +94,13 @@ steps: configuration: Release msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory) /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg' +- task: MSBuild@1 + displayName: 'Pack OpenAPI.Tool' + inputs: + solution: src/Microsoft.OpenApi.Tool/Microsoft.OpenApi.Tool.csproj + configuration: Release + msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory) /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg' + - task: SFP.build-tasks.custom-build-task-1.EsrpCodeSigning@1 displayName: 'ESRP CodeSigning Nuget Packages' inputs: From deaa2fed7de2b21464307018ba5af574c5fd7128 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 3 Nov 2021 10:01:31 +0300 Subject: [PATCH 041/288] Move declaration closer to first reference point --- src/Microsoft.OpenApi.Tool/OpenApiService.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Tool/OpenApiService.cs b/src/Microsoft.OpenApi.Tool/OpenApiService.cs index d9e9fa930..74f9455f0 100644 --- a/src/Microsoft.OpenApi.Tool/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Tool/OpenApiService.cs @@ -37,9 +37,6 @@ public static void ProcessOpenApiDocument( } var stream = GetStream(input); - - OpenApiDocument document; - var result = new OpenApiStreamReader(new OpenApiReaderSettings { ReferenceResolution = resolveExternal ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, @@ -47,6 +44,7 @@ public static void ProcessOpenApiDocument( } ).ReadAsync(stream).GetAwaiter().GetResult(); + OpenApiDocument document; document = result.OpenApiDocument; // Check if filter options are provided, then execute From 015b3cd27b7454e7b905c5e804365ec5fa013b5c Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 4 Nov 2021 13:21:57 +0300 Subject: [PATCH 042/288] Code cleanup --- src/Microsoft.OpenApi.Tool/OpenApiService.cs | 5 ++++- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 2 +- src/Microsoft.OpenApi/Services/OperationSearch.cs | 10 ++++++++++ src/Microsoft.OpenApi/Services/SearchResult.cs | 10 ++++++++++ .../Workspaces/OpenApiWorkspaceTests.cs | 9 +++++---- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.OpenApi.Tool/OpenApiService.cs b/src/Microsoft.OpenApi.Tool/OpenApiService.cs index 74f9455f0..87f02dcce 100644 --- a/src/Microsoft.OpenApi.Tool/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Tool/OpenApiService.cs @@ -31,6 +31,10 @@ public static void ProcessOpenApiDocument( { throw new ArgumentNullException(nameof(input)); } + if(output == null) + { + throw new ArgumentException(nameof(output)); + } if (output.Exists) { throw new IOException("The file you're writing to already exists. Please input a new output path."); @@ -123,7 +127,6 @@ internal static void ValidateOpenApiDocument(string input) document = new OpenApiStreamReader(new OpenApiReaderSettings { - //ReferenceResolution = resolveExternal == true ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, RuleSet = ValidationRuleSet.GetDefaultRuleSet() } ).Read(stream, out var context); diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 4fd09314e..5b5e6f59f 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -75,7 +75,7 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun foreach (var result in results) { OpenApiPathItem pathItem; - string pathKey = result.CurrentKeys.Path; + var pathKey = result.CurrentKeys.Path; if (subset.Paths == null) { diff --git a/src/Microsoft.OpenApi/Services/OperationSearch.cs b/src/Microsoft.OpenApi/Services/OperationSearch.cs index 01b1b5f56..35d36b38f 100644 --- a/src/Microsoft.OpenApi/Services/OperationSearch.cs +++ b/src/Microsoft.OpenApi/Services/OperationSearch.cs @@ -8,13 +8,23 @@ namespace Microsoft.OpenApi.Services { + /// + /// Visits OpenApi operations and parameters. + /// public class OperationSearch : OpenApiVisitorBase { private readonly Func _predicate; private readonly List _searchResults = new(); + /// + /// A list of operations from the operation search. + /// public IList SearchResults => _searchResults; + /// + /// The OperationSearch constructor. + /// + /// A predicate function. public OperationSearch(Func predicate) { _predicate = predicate ?? throw new ArgumentNullException(nameof(predicate)); diff --git a/src/Microsoft.OpenApi/Services/SearchResult.cs b/src/Microsoft.OpenApi/Services/SearchResult.cs index 2b7d9f94a..381a11f95 100644 --- a/src/Microsoft.OpenApi/Services/SearchResult.cs +++ b/src/Microsoft.OpenApi/Services/SearchResult.cs @@ -5,9 +5,19 @@ namespace Microsoft.OpenApi.Services { + /// + /// Defines a search result model for visited operations. + /// public class SearchResult { + /// + /// An object containing contextual information based on where the walker is currently referencing in an OpenApiDocument. + /// public CurrentKeys CurrentKeys { get; set; } + + /// + /// An Operation object. + /// public OpenApiOperation Operation { get; set; } } } diff --git a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs index b82327a5d..2102328eb 100644 --- a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs @@ -1,5 +1,5 @@ // Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT license. +// Licensed under the MIT license. using System; using System.Collections.Generic; @@ -12,7 +12,7 @@ namespace Microsoft.OpenApi.Tests { - + public class OpenApiWorkspaceTests { [Fact] @@ -61,7 +61,7 @@ public void OpenApiWorkspacesAllowDocumentsToReferenceEachOther() } } } - } + } } }); workspace.AddDocument("common", new OpenApiDocument() { @@ -111,7 +111,7 @@ public void OpenApiWorkspacesAllowDocumentsToReferenceEachOther_short() re.CreateContent("application/json", co => co.Schema = new OpenApiSchema() { - Reference = new OpenApiReference() // Reference + Reference = new OpenApiReference() // Reference { Id = "test", Type = ReferenceType.Schema, @@ -150,6 +150,7 @@ public void OpenApiWorkspacesShouldNormalizeDocumentLocations() // Enable Workspace to load from any reader, not just streams. // Test fragments + [Fact] public void OpenApiWorkspacesShouldLoadDocumentFragments() { Assert.True(false); From d259cc1c40ccdaf91f3608851200d52dca6707a0 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 5 Nov 2021 11:15:40 +0300 Subject: [PATCH 043/288] Remove [Fact] attribute --- test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs index 2102328eb..dd6e2554b 100644 --- a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs @@ -150,7 +150,6 @@ public void OpenApiWorkspacesShouldNormalizeDocumentLocations() // Enable Workspace to load from any reader, not just streams. // Test fragments - [Fact] public void OpenApiWorkspacesShouldLoadDocumentFragments() { Assert.True(false); From 526162e3a1bc4a45d7142b2d380ba47ab8e81c8b Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 5 Nov 2021 12:21:01 +0300 Subject: [PATCH 044/288] Remove unused variable --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index cfe1c09eb..4e2ae7051 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -48,8 +48,6 @@ public static Func CreatePredicate(string operationIds = { predicate = (o) => o.Tags.Any(t => tagsArray.Contains(t.Name)); } - - predicateSource = $"tags: {tags}"; } else From 1321c1e2999b99db476f9cf6b073e6e65228dc41 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 8 Nov 2021 12:49:28 +0300 Subject: [PATCH 045/288] Rename project and update namespaces --- .../Microsoft.Hidi.csproj} | 2 +- .../OpenApiService.cs | 3 ++- src/{Microsoft.OpenApi.Tool => Microsoft.Hidi}/Program.cs | 3 ++- .../StatsVisitor.cs | 5 +---- 4 files changed, 6 insertions(+), 7 deletions(-) rename src/{Microsoft.OpenApi.Tool/Microsoft.OpenApi.Tool.csproj => Microsoft.Hidi/Microsoft.Hidi.csproj} (93%) rename src/{Microsoft.OpenApi.Tool => Microsoft.Hidi}/OpenApiService.cs (98%) rename src/{Microsoft.OpenApi.Tool => Microsoft.Hidi}/Program.cs (97%) rename src/{Microsoft.OpenApi.Tool => Microsoft.Hidi}/StatsVisitor.cs (95%) diff --git a/src/Microsoft.OpenApi.Tool/Microsoft.OpenApi.Tool.csproj b/src/Microsoft.Hidi/Microsoft.Hidi.csproj similarity index 93% rename from src/Microsoft.OpenApi.Tool/Microsoft.OpenApi.Tool.csproj rename to src/Microsoft.Hidi/Microsoft.Hidi.csproj index 40e46f1a4..27fc4b995 100644 --- a/src/Microsoft.OpenApi.Tool/Microsoft.OpenApi.Tool.csproj +++ b/src/Microsoft.Hidi/Microsoft.Hidi.csproj @@ -4,7 +4,7 @@ Exe netcoreapp3.1 true - openapi-parser + hidi ./../../artifacts 1.3.0-preview diff --git a/src/Microsoft.OpenApi.Tool/OpenApiService.cs b/src/Microsoft.Hidi/OpenApiService.cs similarity index 98% rename from src/Microsoft.OpenApi.Tool/OpenApiService.cs rename to src/Microsoft.Hidi/OpenApiService.cs index 87f02dcce..556eff071 100644 --- a/src/Microsoft.OpenApi.Tool/OpenApiService.cs +++ b/src/Microsoft.Hidi/OpenApiService.cs @@ -7,6 +7,7 @@ using System.Net; using System.Net.Http; using System.Text; +using Microsoft.OpenApi; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers; @@ -14,7 +15,7 @@ using Microsoft.OpenApi.Validations; using Microsoft.OpenApi.Writers; -namespace Microsoft.OpenApi.Tool +namespace Microsoft.Hidi { static class OpenApiService { diff --git a/src/Microsoft.OpenApi.Tool/Program.cs b/src/Microsoft.Hidi/Program.cs similarity index 97% rename from src/Microsoft.OpenApi.Tool/Program.cs rename to src/Microsoft.Hidi/Program.cs index 21be3406b..033e3625b 100644 --- a/src/Microsoft.OpenApi.Tool/Program.cs +++ b/src/Microsoft.Hidi/Program.cs @@ -5,8 +5,9 @@ using System.CommandLine.Invocation; using System.IO; using System.Threading.Tasks; +using Microsoft.OpenApi; -namespace Microsoft.OpenApi.Tool +namespace Microsoft.Hidi { static class Program { diff --git a/src/Microsoft.OpenApi.Tool/StatsVisitor.cs b/src/Microsoft.Hidi/StatsVisitor.cs similarity index 95% rename from src/Microsoft.OpenApi.Tool/StatsVisitor.cs rename to src/Microsoft.Hidi/StatsVisitor.cs index 3c633d860..7617edb97 100644 --- a/src/Microsoft.OpenApi.Tool/StatsVisitor.cs +++ b/src/Microsoft.Hidi/StatsVisitor.cs @@ -3,13 +3,10 @@ using System; using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Services; -namespace Microsoft.OpenApi.Tool +namespace Microsoft.Hidi { internal class StatsVisitor : OpenApiVisitorBase { From fb5512ce6cfba4e0d1a0891d607ffe8958051c0a Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 8 Nov 2021 12:49:46 +0300 Subject: [PATCH 046/288] Update build script and solution file --- Microsoft.OpenApi.sln | 2 +- build.cmd | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Microsoft.OpenApi.sln b/Microsoft.OpenApi.sln index e64ff3a24..71201a3cd 100644 --- a/Microsoft.OpenApi.sln +++ b/Microsoft.OpenApi.sln @@ -26,7 +26,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6357D7FD-2 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.SmokeTests", "test\Microsoft.OpenApi.SmokeTests\Microsoft.OpenApi.SmokeTests.csproj", "{AD79B61D-88CF-497C-9ED5-41AE3867C5AC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Tool", "src\Microsoft.OpenApi.Tool\Microsoft.OpenApi.Tool.csproj", "{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Hidi", "src\Microsoft.Hidi\Microsoft.Hidi.csproj", "{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/build.cmd b/build.cmd index b3612c9ed..48016eed2 100644 --- a/build.cmd +++ b/build.cmd @@ -1,21 +1,21 @@ @echo off -Echo Building Microsoft.OpenApi +Echo Building Microsoft.OpenApi -SET PROJ=%~dp0src\Microsoft.OpenApi\Microsoft.OpenApi.csproj +SET PROJ=%~dp0src\Microsoft.OpenApi\Microsoft.OpenApi.csproj dotnet msbuild %PROJ% /t:restore /p:Configuration=Release dotnet msbuild %PROJ% /t:build /p:Configuration=Release dotnet msbuild %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts Echo Building Microsoft.OpenApi.Readers -SET PROJ=%~dp0src\Microsoft.OpenApi.Readers\Microsoft.OpenApi.Readers.csproj +SET PROJ=%~dp0src\Microsoft.OpenApi.Readers\Microsoft.OpenApi.Readers.csproj dotnet msbuild %PROJ% /t:restore /p:Configuration=Release dotnet msbuild %PROJ% /t:build /p:Configuration=Release dotnet msbuild %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts -Echo Building Microsoft.OpenApi.Tool +Echo Building Microsoft.Hidi -SET PROJ=%~dp0src\Microsoft.OpenApi.Tool\Microsoft.OpenApi.Tool.csproj +SET PROJ=%~dp0src\Microsoft.Hidi\Microsoft.Hidi.csproj dotnet msbuild %PROJ% /t:restore /p:Configuration=Release dotnet msbuild %PROJ% /t:build /p:Configuration=Release dotnet msbuild %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts From e01b885edaabdfaabb632802829765e670f3e7e1 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 9 Nov 2021 08:51:19 +0300 Subject: [PATCH 047/288] Rename the OpenApi.Tool to Hidi --- .azure-pipelines/ci-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 3edcedeb8..31364a500 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -95,9 +95,9 @@ steps: msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory) /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg' - task: MSBuild@1 - displayName: 'Pack OpenAPI.Tool' + displayName: 'Pack Hidi' inputs: - solution: src/Microsoft.OpenApi.Tool/Microsoft.OpenApi.Tool.csproj + solution: src/Microsoft.Hidi/Microsoft.Hidi.csproj configuration: Release msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory) /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg' From c90020813dba37870c17fb5eaa6e29f3a850fd93 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 9 Nov 2021 12:35:30 +0300 Subject: [PATCH 048/288] Address PR feedback --- src/Microsoft.OpenApi.Tool/Program.cs | 2 +- .../Services/OpenApiFilterServiceTests.cs | 32 +++++++++---------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/Microsoft.OpenApi.Tool/Program.cs b/src/Microsoft.OpenApi.Tool/Program.cs index 71507ad8b..a4d32c31e 100644 --- a/src/Microsoft.OpenApi.Tool/Program.cs +++ b/src/Microsoft.OpenApi.Tool/Program.cs @@ -29,7 +29,7 @@ static async Task Main(string[] args) new Option("--format", "File format",typeof(OpenApiFormat) ), new Option("--inline", "Inline $ref instances", typeof(bool) ), new Option("--resolveExternal","Resolve external $refs", typeof(bool)), - new Option("--filterByOperationIds", "Filters OpenApiDocument by OperationId provided", typeof(string)), + new Option("--filterByOperationIds", "Filters OpenApiDocument by OperationId(s) provided", typeof(string)), new Option("--filterByTags", "Filters OpenApiDocument by Tag(s) provided", typeof(string)) }; transformCommand.Handler = CommandHandler.Create( diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs index 058fc8c42..c9b87f57f 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs @@ -19,14 +19,18 @@ public OpenApiFilterServiceTests() } [Theory] - [InlineData("users.user.ListUser", null)] - [InlineData("users.user.GetUser", null)] - [InlineData("administrativeUnits.restore", null)] - [InlineData("graphService.GetGraphService", null)] - [InlineData(null, "users.user")] - [InlineData(null, "applications.application")] - [InlineData(null, "reports.Functions")] - public void ReturnFilteredOpenApiDocumentBasedOnOperationIds(string operationIds, string tags) + [InlineData("users.user.ListUser", null, 1)] + [InlineData("users.user.GetUser", null, 1)] + [InlineData("users.user.ListUser,users.user.GetUser", null, 2)] + [InlineData("*", null, 12)] + [InlineData("administrativeUnits.restore", null, 1)] + [InlineData("graphService.GetGraphService", null, 1)] + [InlineData(null, "users.user,applications.application", 3)] + [InlineData(null, "^users\\.", 3)] + [InlineData(null, "users.user", 2)] + [InlineData(null, "applications.application", 1)] + [InlineData(null, "reports.Functions", 2)] + public void ReturnFilteredOpenApiDocumentBasedOnOperationIdsAndTags(string operationIds, string tags, int expectedPathCount) { // Act var predicate = OpenApiFilterService.CreatePredicate(operationIds, tags); @@ -34,18 +38,12 @@ public void ReturnFilteredOpenApiDocumentBasedOnOperationIds(string operationIds // Assert Assert.NotNull(subsetOpenApiDocument); - if (!string.IsNullOrEmpty(operationIds)) - { - Assert.Single(subsetOpenApiDocument.Paths); - } - else if (!string.IsNullOrEmpty(tags)) - { - Assert.NotEmpty(subsetOpenApiDocument.Paths); - } + Assert.NotEmpty(subsetOpenApiDocument.Paths); + Assert.Equal(expectedPathCount, subsetOpenApiDocument.Paths.Count); } [Fact] - public void ThrowsInvalidOperationExceptionInCreatePredicateWhenInvalidOperationIdIsSpecified() + public void ThrowsInvalidOperationExceptionInCreatePredicateWhenInvalidArgumentsArePassed() { // Act and Assert var message = Assert.Throws(() =>OpenApiFilterService.CreatePredicate(null, null)).Message; From d1a13a56e10c48a3f95c389ff655a81057eeaacd Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 9 Nov 2021 17:36:35 +0300 Subject: [PATCH 049/288] Update package name --- .azure-pipelines/ci-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 31364a500..4e0f23758 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -95,9 +95,9 @@ steps: msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory) /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg' - task: MSBuild@1 - displayName: 'Pack Hidi' + displayName: 'Pack OpenApi Hidi' inputs: - solution: src/Microsoft.Hidi/Microsoft.Hidi.csproj + solution: src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj configuration: Release msbuildArguments: '/t:pack /p:PackageOutputPath=$(Build.ArtifactStagingDirectory) /p:IncludeSymbols=true /p:SymbolPackageFormat=snupkg' From 6acf634798c74f4fe9f462b95254e85571366dbb Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 9 Nov 2021 18:43:02 +0300 Subject: [PATCH 050/288] Add validation check and add test --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 5 ++++- .../Services/OpenApiFilterServiceTests.cs | 7 +++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 4e2ae7051..08774995e 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -23,6 +23,10 @@ public static class OpenApiFilterService public static Func CreatePredicate(string operationIds = null, string tags = null) { Func predicate; + if (!string.IsNullOrEmpty(operationIds) && !string.IsNullOrEmpty(tags)) + { + throw new InvalidOperationException("Cannot specify both operationIds and tags at the same time."); + } if (operationIds != null) { if (operationIds == "*") @@ -49,7 +53,6 @@ public static Func CreatePredicate(string operationIds = predicate = (o) => o.Tags.Any(t => tagsArray.Contains(t.Name)); } } - else { throw new InvalidOperationException("Either operationId(s) or tag(s) need to be specified."); diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs index c9b87f57f..ab65ed744 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs @@ -46,8 +46,11 @@ public void ReturnFilteredOpenApiDocumentBasedOnOperationIdsAndTags(string opera public void ThrowsInvalidOperationExceptionInCreatePredicateWhenInvalidArgumentsArePassed() { // Act and Assert - var message = Assert.Throws(() =>OpenApiFilterService.CreatePredicate(null, null)).Message; - Assert.Equal("Either operationId(s) or tag(s) need to be specified.", message); + var message1 = Assert.Throws(() => OpenApiFilterService.CreatePredicate(null, null)).Message; + Assert.Equal("Either operationId(s) or tag(s) need to be specified.", message1); + + var message2 = Assert.Throws(() => OpenApiFilterService.CreatePredicate("users.user.ListUser", "users.user")).Message; + Assert.Equal("Cannot specify both operationIds and tags at the same time.", message2); } } } From 403a40ff85eeb780deccef692e48572adc5d9ba0 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 9 Nov 2021 21:57:22 +0300 Subject: [PATCH 051/288] Rename tool to OpenApi.Hidi --- Microsoft.OpenApi.sln | 2 +- build.cmd | 4 ++-- install-tool.ps1 | 8 ++++---- .../Microsoft.OpenApi.Hidi.csproj} | 0 .../OpenApiService.cs | 3 +-- src/{Microsoft.Hidi => Microsoft.OpenApi.Hidi}/Program.cs | 3 +-- .../StatsVisitor.cs | 2 +- 7 files changed, 10 insertions(+), 12 deletions(-) rename src/{Microsoft.Hidi/Microsoft.Hidi.csproj => Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj} (100%) rename src/{Microsoft.Hidi => Microsoft.OpenApi.Hidi}/OpenApiService.cs (98%) rename src/{Microsoft.Hidi => Microsoft.OpenApi.Hidi}/Program.cs (97%) rename src/{Microsoft.Hidi => Microsoft.OpenApi.Hidi}/StatsVisitor.cs (98%) diff --git a/Microsoft.OpenApi.sln b/Microsoft.OpenApi.sln index 71201a3cd..b24440dc5 100644 --- a/Microsoft.OpenApi.sln +++ b/Microsoft.OpenApi.sln @@ -26,7 +26,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6357D7FD-2 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.SmokeTests", "test\Microsoft.OpenApi.SmokeTests\Microsoft.OpenApi.SmokeTests.csproj", "{AD79B61D-88CF-497C-9ED5-41AE3867C5AC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Hidi", "src\Microsoft.Hidi\Microsoft.Hidi.csproj", "{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Hidi", "src\Microsoft.Hidi\Microsoft.OpenApi.Hidi.csproj", "{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/build.cmd b/build.cmd index 48016eed2..43cc95956 100644 --- a/build.cmd +++ b/build.cmd @@ -13,9 +13,9 @@ dotnet msbuild %PROJ% /t:restore /p:Configuration=Release dotnet msbuild %PROJ% /t:build /p:Configuration=Release dotnet msbuild %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts -Echo Building Microsoft.Hidi +Echo Building Microsoft.OpenApi.Hidi -SET PROJ=%~dp0src\Microsoft.Hidi\Microsoft.Hidi.csproj +SET PROJ=%~dp0src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj dotnet msbuild %PROJ% /t:restore /p:Configuration=Release dotnet msbuild %PROJ% /t:build /p:Configuration=Release dotnet msbuild %PROJ% /t:pack /p:Configuration=Release;PackageOutputPath=%~dp0artifacts diff --git a/install-tool.ps1 b/install-tool.ps1 index 0e6521110..d268e826e 100644 --- a/install-tool.ps1 +++ b/install-tool.ps1 @@ -1,7 +1,7 @@ -$latest = Get-ChildItem .\artifacts\ Microsoft.OpenApi.Tool* | select-object -Last 1 +$latest = Get-ChildItem .\artifacts\ Microsoft.OpenApi.Hidi* | select-object -Last 1 $version = $latest.Name.Split(".")[3..5] | join-string -Separator "." -if (Test-Path -Path ./artifacts/openapi-parser.exe) { - dotnet tool uninstall --tool-path artifacts Microsoft.OpenApi.Tool +if (Test-Path -Path ./artifacts/hidi.exe) { + dotnet tool uninstall --tool-path artifacts Microsoft.OpenApi.Hidi } -dotnet tool install --tool-path artifacts --add-source .\artifacts\ --version $version Microsoft.OpenApi.Tool \ No newline at end of file +dotnet tool install --tool-path artifacts --add-source .\artifacts\ --version $version Microsoft.OpenApi.Hidi \ No newline at end of file diff --git a/src/Microsoft.Hidi/Microsoft.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj similarity index 100% rename from src/Microsoft.Hidi/Microsoft.Hidi.csproj rename to src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj diff --git a/src/Microsoft.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs similarity index 98% rename from src/Microsoft.Hidi/OpenApiService.cs rename to src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 556eff071..5a415c115 100644 --- a/src/Microsoft.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -7,7 +7,6 @@ using System.Net; using System.Net.Http; using System.Text; -using Microsoft.OpenApi; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers; @@ -15,7 +14,7 @@ using Microsoft.OpenApi.Validations; using Microsoft.OpenApi.Writers; -namespace Microsoft.Hidi +namespace Microsoft.OpenApi.Hidi { static class OpenApiService { diff --git a/src/Microsoft.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs similarity index 97% rename from src/Microsoft.Hidi/Program.cs rename to src/Microsoft.OpenApi.Hidi/Program.cs index 033e3625b..31c5b3e69 100644 --- a/src/Microsoft.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -5,9 +5,8 @@ using System.CommandLine.Invocation; using System.IO; using System.Threading.Tasks; -using Microsoft.OpenApi; -namespace Microsoft.Hidi +namespace Microsoft.OpenApi.Hidi { static class Program { diff --git a/src/Microsoft.Hidi/StatsVisitor.cs b/src/Microsoft.OpenApi.Hidi/StatsVisitor.cs similarity index 98% rename from src/Microsoft.Hidi/StatsVisitor.cs rename to src/Microsoft.OpenApi.Hidi/StatsVisitor.cs index 7617edb97..b05b0de7c 100644 --- a/src/Microsoft.Hidi/StatsVisitor.cs +++ b/src/Microsoft.OpenApi.Hidi/StatsVisitor.cs @@ -6,7 +6,7 @@ using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Services; -namespace Microsoft.Hidi +namespace Microsoft.OpenApi.Hidi { internal class StatsVisitor : OpenApiVisitorBase { From 97f4ac3c06d99264d67714ea8507568d2b610e36 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 10 Nov 2021 13:09:22 +0300 Subject: [PATCH 052/288] Remove whitespace --- install-tool.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install-tool.ps1 b/install-tool.ps1 index d268e826e..0b4615c67 100644 --- a/install-tool.ps1 +++ b/install-tool.ps1 @@ -1,4 +1,4 @@ -$latest = Get-ChildItem .\artifacts\ Microsoft.OpenApi.Hidi* | select-object -Last 1 +$latest = Get-ChildItem .\artifacts\Microsoft.OpenApi.Hidi* | select-object -Last 1 $version = $latest.Name.Split(".")[3..5] | join-string -Separator "." if (Test-Path -Path ./artifacts/hidi.exe) { From ede11f10fd7abcc74be2fe66bddb05604da5fd30 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 10 Nov 2021 13:21:05 +0300 Subject: [PATCH 053/288] Update solution file with the correct directory path --- Microsoft.OpenApi.sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Microsoft.OpenApi.sln b/Microsoft.OpenApi.sln index b24440dc5..dc489bff8 100644 --- a/Microsoft.OpenApi.sln +++ b/Microsoft.OpenApi.sln @@ -26,7 +26,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6357D7FD-2 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.SmokeTests", "test\Microsoft.OpenApi.SmokeTests\Microsoft.OpenApi.SmokeTests.csproj", "{AD79B61D-88CF-497C-9ED5-41AE3867C5AC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Hidi", "src\Microsoft.Hidi\Microsoft.OpenApi.Hidi.csproj", "{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Hidi", "src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj", "{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution From 431a4e9ff0095db55a35e2d6726c374789f8c42a Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 12 Nov 2021 11:29:42 +0300 Subject: [PATCH 054/288] Add blank line --- .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 4e0f23758..b6944af2f 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -30,7 +30,7 @@ steps: inputs: testAssemblyVer2: | **\*.Tests.dll - + vsTestVersion: 16.0 codeCoverageEnabled: true From 561b07ac7810b6e7b4d5751283de399950783209 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 12 Nov 2021 11:34:11 +0300 Subject: [PATCH 055/288] Update .sln --- Microsoft.OpenApi.sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Microsoft.OpenApi.sln b/Microsoft.OpenApi.sln index dc489bff8..e64ff3a24 100644 --- a/Microsoft.OpenApi.sln +++ b/Microsoft.OpenApi.sln @@ -26,7 +26,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6357D7FD-2 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.SmokeTests", "test\Microsoft.OpenApi.SmokeTests\Microsoft.OpenApi.SmokeTests.csproj", "{AD79B61D-88CF-497C-9ED5-41AE3867C5AC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Hidi", "src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj", "{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Tool", "src\Microsoft.OpenApi.Tool\Microsoft.OpenApi.Tool.csproj", "{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution From 7b678a8a2c20d182f20e97735244b8b2c59b75f3 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 12 Nov 2021 11:47:44 +0300 Subject: [PATCH 056/288] Revert --- Microsoft.OpenApi.sln | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Microsoft.OpenApi.sln b/Microsoft.OpenApi.sln index e64ff3a24..dc489bff8 100644 --- a/Microsoft.OpenApi.sln +++ b/Microsoft.OpenApi.sln @@ -26,7 +26,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{6357D7FD-2 EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.SmokeTests", "test\Microsoft.OpenApi.SmokeTests\Microsoft.OpenApi.SmokeTests.csproj", "{AD79B61D-88CF-497C-9ED5-41AE3867C5AC}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Tool", "src\Microsoft.OpenApi.Tool\Microsoft.OpenApi.Tool.csproj", "{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.OpenApi.Hidi", "src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj", "{254841B5-7DAC-4D1D-A9C5-44FE5CE467BE}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution From 733ca6b349d5556e352a4f738677145fc6f53c37 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 12 Nov 2021 13:01:26 +0300 Subject: [PATCH 057/288] Update dll path in launch.json --- .vscode/launch.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.vscode/launch.json b/.vscode/launch.json index 0d20a9b46..c26bf0c9f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,9 +10,9 @@ "request": "launch", "preLaunchTask": "build", // If you have changed target frameworks, make sure to update the program path. - "program": "${workspaceFolder}/src/Microsoft.OpenApi.Tool/bin/Debug/netcoreapp3.1/Microsoft.OpenApi.Tool.dll", + "program": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi/bin/Debug/netcoreapp3.1/Microsoft.OpenApi.Hidi.dll", "args": [], - "cwd": "${workspaceFolder}/src/Microsoft.OpenApi.Tool", + "cwd": "${workspaceFolder}/src/Microsoft.OpenApi.Hidi", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console "console": "internalConsole", "stopAtEntry": false From 520a55e4d2bb7531dd4d493b534302c8b296e809 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 12 Nov 2021 13:16:28 +0300 Subject: [PATCH 058/288] Update ci-cd.yml and codeql.yml files --- .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 4ab9ed7c3..7afeeebed 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -62,7 +62,7 @@ jobs: $projectsArray = @( '.\src\Microsoft.OpenApi\Microsoft.OpenApi.csproj', '.\src\Microsoft.OpenApi.Readers\Microsoft.OpenApi.Readers.csproj', - '.\src\Microsoft.OpenApi.Tool\Microsoft.OpenApi.Tool.csproj' + '.\src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj' ) $gitNewVersion = if ("${{ steps.tag_generator.outputs.new_version }}") {"${{ steps.tag_generator.outputs.new_version }}"} else {$null} $projectCurrentVersion = ([xml](Get-Content .\src\Microsoft.OpenApi\Microsoft.OpenApi.csproj)).Project.PropertyGroup.Version diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 95c813772..999e48f53 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -33,7 +33,7 @@ jobs: $projectsArray = @( '.\src\Microsoft.OpenApi\Microsoft.OpenApi.csproj', '.\src\Microsoft.OpenApi.Readers\Microsoft.OpenApi.Readers.csproj', - '.\src\Microsoft.OpenApi.Tool\Microsoft.OpenApi.Tool.csproj' + '.\src\Microsoft.OpenApi.Hidi\Microsoft.OpenApi.Hidi.csproj' ) $projectsArray | ForEach-Object { From 39f5beaadd48079a099c9f1713b931ef3ff8fcec Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 16 Nov 2021 18:29:30 +0300 Subject: [PATCH 059/288] Update the tool's 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 27fc4b995..f0d7943e7 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -6,7 +6,7 @@ true hidi ./../../artifacts - 1.3.0-preview + 0.5.0-preview From c97bb13d873491b337ba94a63e700e4beaaea349 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 23 Nov 2021 17:36:01 +0300 Subject: [PATCH 060/288] Bump up library versions --- .../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 c52601ebb..7d3f196ec 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -10,14 +10,14 @@ Microsoft Microsoft.OpenApi.Readers Microsoft.OpenApi.Readers - 1.3.0-preview + 1.3.1-preview OpenAPI.NET Readers for JSON and YAML documents © Microsoft Corporation. All rights reserved. OpenAPI .NET https://github.com/Microsoft/OpenAPI.NET - Publish symbols. - + Microsoft.OpenApi.Readers Microsoft.OpenApi.Readers true diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 9c36ab07c..b0cd4e30e 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.0-preview + 1.3.1-preview .NET models with JSON and YAML writers for OpenAPI specification © Microsoft Corporation. All rights reserved. OpenAPI .NET From e95833a8c6a8cd15acb7ed889906212bd89f3658 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 23 Nov 2021 23:57:54 +0300 Subject: [PATCH 061/288] Add a push trigger filter in our main branch for the codeql analysis step --- .github/workflows/codeql-analysis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 95c813772..045a6cbf1 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -2,6 +2,7 @@ name: CodeQL Analysis on: push: + branches: [ vnext ] pull_request: schedule: - cron: '0 8 * * *' From 60063343e2e0ce82da5ff7caaedc39f240c04b19 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 24 Nov 2021 00:04:42 +0300 Subject: [PATCH 062/288] Fix indentation --- .github/workflows/codeql-analysis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 045a6cbf1..c26382cbf 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -2,7 +2,7 @@ name: CodeQL Analysis on: push: - branches: [ vnext ] + branches: [ vnext ] pull_request: schedule: - cron: '0 8 * * *' From 03b0e37d8547c62f49b538564a80d245c67a3c4e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Nov 2021 21:29:38 +0000 Subject: [PATCH 063/288] Bump Microsoft.SourceLink.GitHub from 1.0.0 to 1.1.1 Bumps [Microsoft.SourceLink.GitHub](https://github.com/dotnet/sourcelink) from 1.0.0 to 1.1.1. - [Release notes](https://github.com/dotnet/sourcelink/releases) - [Commits](https://github.com/dotnet/sourcelink/compare/1.0.0...1.1.1) --- updated-dependencies: - dependency-name: Microsoft.SourceLink.GitHub dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- src/Directory.Build.props | 2 +- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index adb086cc1..7f0f6e9c0 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -3,6 +3,6 @@ $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - + \ No newline at end of file diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index f0d7943e7..b13c9dc18 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -19,7 +19,7 @@ - + diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index c52601ebb..7ea8d9f62 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -36,7 +36,7 @@ - + diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 9c36ab07c..9ddde7b29 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -37,7 +37,7 @@ - + From f640726635f0c3681c10298d6746eede663a74c0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 23 Nov 2021 21:29:39 +0000 Subject: [PATCH 064/288] Bump FluentAssertions from 5.10.3 to 6.2.0 Bumps [FluentAssertions](https://github.com/fluentassertions/fluentassertions) from 5.10.3 to 6.2.0. - [Release notes](https://github.com/fluentassertions/fluentassertions/releases) - [Changelog](https://github.com/fluentassertions/fluentassertions/blob/master/AcceptApiChanges.ps1) - [Commits](https://github.com/fluentassertions/fluentassertions/compare/5.10.3...6.2.0) --- updated-dependencies: - dependency-name: FluentAssertions dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) mode change 100755 => 100644 test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj 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 0a4ed6494..166c51053 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 old mode 100755 new mode 100644 index 576e420cf..1850515e0 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -16,7 +16,7 @@ - + From 2e51617707964749e557cfb3a01c4629cb953422 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Nov 2021 22:47:43 +0000 Subject: [PATCH 065/288] Bump Microsoft.NET.Test.Sdk from 16.9.4 to 17.0.0 Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 16.9.4 to 17.0.0. - [Release notes](https://github.com/microsoft/vstest/releases) - [Commits](https://github.com/microsoft/vstest/compare/v16.9.4...v17.0.0) --- updated-dependencies: - dependency-name: Microsoft.NET.Test.Sdk dependency-type: direct:production update-type: version-update:semver-major ... 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(-) mode change 100755 => 100644 test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj 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 0a4ed6494..e2bf9f730 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 a4e017455..6792f2362 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 old mode 100755 new mode 100644 index 576e420cf..3c4f5b74b --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 55955426a1346d7b1dbd8bd43fe65734903390b7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 25 Nov 2021 23:21:32 +0000 Subject: [PATCH 066/288] Bump SharpYaml from 1.6.6 to 1.8.0 Bumps [SharpYaml](https://github.com/xoofx/SharpYaml) from 1.6.6 to 1.8.0. - [Release notes](https://github.com/xoofx/SharpYaml/releases) - [Changelog](https://github.com/xoofx/SharpYaml/blob/master/changelog.md) - [Commits](https://github.com/xoofx/SharpYaml/compare/v1.6.6...1.8.0) --- updated-dependencies: - dependency-name: SharpYaml dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 3 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 7ea8d9f62..f2870eb93 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -40,7 +40,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 e2bf9f730..265d134f7 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -247,7 +247,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 3c4f5b74b..346d1bcc4 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -18,7 +18,7 @@ - + all From ea99575ec7a7a0c7dd9ebb5125ac92903cc8399a Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 7 Dec 2021 12:41:16 +0300 Subject: [PATCH 067/288] Add filter by collection parameter and logic --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 11 ++++++++++- src/Microsoft.OpenApi.Hidi/Program.cs | 7 ++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 486666568..3cdb4a4dc 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; @@ -25,6 +25,7 @@ public static void ProcessOpenApiDocument( OpenApiFormat format, string filterByOperationIds, string filterByTags, + string filterByCollection, bool inline, bool resolveExternal) { @@ -69,6 +70,14 @@ public static void ProcessOpenApiDocument( document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } + if (!string.IsNullOrEmpty(filterByCollection)) + { + var fileStream = GetStream(filterByCollection); + var urlDictionary = OpenApiFilterService.ParseJsonCollectionFile(fileStream); + var predicate = OpenApiFilterService.CreatePredicate(urls: urlDictionary, source:document); + document = OpenApiFilterService.CreateFilteredDocument(document, predicate); + } + var context = result.OpenApiDiagnostic; if (context.Errors.Count > 0) diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 533878a0d..1889efb93 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.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.CommandLine; @@ -30,9 +30,10 @@ static async Task Main(string[] args) new Option("--inline", "Inline $ref instances", typeof(bool) ), new Option("--resolveExternal","Resolve external $refs", typeof(bool)), new Option("--filterByOperationIds", "Filters OpenApiDocument by OperationId(s) provided", typeof(string)), - new Option("--filterByTags", "Filters OpenApiDocument by Tag(s) provided", typeof(string)) + new Option("--filterByTags", "Filters OpenApiDocument by Tag(s) provided", typeof(string)), + new Option("--filterByCollection", "Filters OpenApiDocument by Postman collection provided", typeof(string)) }; - transformCommand.Handler = CommandHandler.Create( + transformCommand.Handler = CommandHandler.Create( OpenApiService.ProcessOpenApiDocument); rootCommand.Add(transformCommand); From e2d189c30b57396f7f605331f039a8a2eb8dcbcf Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 7 Dec 2021 12:42:47 +0300 Subject: [PATCH 068/288] Add library for json serialization --- src/Microsoft.OpenApi.Hidi/Program.cs | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 1889efb93..099eb70df 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.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.CommandLine; diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 9c36ab07c..506f082ef 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -38,6 +38,7 @@ + From 4b3722f69730fc8ecf81db4507623bb4eb9112cc Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 7 Dec 2021 12:43:15 +0300 Subject: [PATCH 069/288] Move declaration closer to assignment --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 3cdb4a4dc..42765a371 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; @@ -50,15 +50,13 @@ public static void ProcessOpenApiDocument( } ).ReadAsync(stream).GetAwaiter().GetResult(); - OpenApiDocument document; - document = result.OpenApiDocument; + var document = result.OpenApiDocument; // Check if filter options are provided, then execute if (!string.IsNullOrEmpty(filterByOperationIds) && !string.IsNullOrEmpty(filterByTags)) { throw new InvalidOperationException("Cannot filter by operationIds and tags at the same time."); } - if (!string.IsNullOrEmpty(filterByOperationIds)) { var predicate = OpenApiFilterService.CreatePredicate(operationIds: filterByOperationIds); From 494e59cdbef3ea3e091a770c138f41dbd2f4c78f Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 7 Dec 2021 12:43:54 +0300 Subject: [PATCH 070/288] Add necessary usings --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 08774995e..687801907 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -1,9 +1,11 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; using System.Collections.Generic; +using System.IO; using System.Linq; +using System.Text.Json; using System.Text.RegularExpressions; using Microsoft.OpenApi.Models; From 4789c8705bfd72556f3a32154846b130538f2ab8 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 7 Dec 2021 12:45:31 +0300 Subject: [PATCH 071/288] Add condition that forbids filtering two params at the same time --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 687801907..ff932da3e 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -22,9 +22,13 @@ public static class OpenApiFilterService /// Comma delimited list of operationIds or * for all operations. /// Comma delimited list of tags or a single regex. /// A predicate. - public static Func CreatePredicate(string operationIds = null, string tags = null) + public static Func CreatePredicate(string operationIds = null, string tags = null, Dictionary> urls = null, OpenApiDocument source = null) { Func predicate; + if (urls != null && (operationIds != null || tags != null)) + { + throw new InvalidOperationException("Cannot filter by postman collection and either operationIds and tags at the same time."); + } if (!string.IsNullOrEmpty(operationIds) && !string.IsNullOrEmpty(tags)) { throw new InvalidOperationException("Cannot specify both operationIds and tags at the same time."); From 03a6b54a24a27cd4529b54b171f8665131a6904e Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 7 Dec 2021 12:47:54 +0300 Subject: [PATCH 072/288] Add method for formatting url string to get the query path --- .../Services/OpenApiFilterService.cs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index ff932da3e..f39508b3e 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -183,5 +183,23 @@ private static bool AddReferences(OpenApiComponents newComponents, OpenApiCompon } return moreStuff; } + + private static string FormatUrlString(string url) + { + var graphVersions = new List() { "v1.0", "beta" }; + var queryPath = string.Empty; + foreach (var version in graphVersions) + { + if (!url.Contains(version)) + { + continue; + } + + var querySegments = url.Split(new[] { "v1.0", "beta" }, StringSplitOptions.None); + queryPath = querySegments[1]; + } + + return queryPath; + } } } From dd1fab68b2723331fb4e08a081d05e452e1264c8 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 7 Dec 2021 12:51:27 +0300 Subject: [PATCH 073/288] Add logic for parsing the JSON collection file, creating an OpenApiTree from the input OpenApi doc and getting a list of OpenApiOperations from the tree for urls in the collection --- .../Services/OpenApiFilterService.cs | 126 ++++++++++++++++++ 1 file changed, 126 insertions(+) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index f39508b3e..66ca5d446 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -130,6 +130,132 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun return subset; } + /// + /// Creates an from a collection of . + /// + /// Dictionary of labels and their corresponding objects. + /// The created . + public static OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(Dictionary sources) + { + var rootNode = OpenApiUrlTreeNode.Create(); + foreach (var source in sources) + { + rootNode.Attach(source.Value, source.Key); + } + return rootNode; + } + + /// + /// Takes in a file stream, parses the stream into a JsonDocument and gets a list of paths and Http methods + /// + /// A file stream. + /// A dictionary of request urls and http methods from a collection. + public static Dictionary> ParseJsonCollectionFile(Stream stream) + { + var requestUrls = new Dictionary>(); + + // Convert file to JsonDocument + using JsonDocument document = JsonDocument.Parse(stream); + JsonElement root = document.RootElement; + JsonElement itemElement = root.GetProperty("item"); + foreach(JsonElement item in itemElement.EnumerateArray()) + { + var requestObject = item.GetProperty("request"); + + // Fetch list of methods and urls from collection, store them in a dictionary + var path = requestObject.GetProperty("url").GetProperty("raw").ToString(); + var method = requestObject.GetProperty("method").ToString(); + + if (!requestUrls.ContainsKey(path)) + { + requestUrls.Add(path, new List() { method }); + } + else + { + requestUrls[path].Add(method); + } + } + + return requestUrls; + } + + private static IDictionary GetOpenApiOperations(OpenApiUrlTreeNode rootNode, string relativeUrl, string label) + { + if (relativeUrl.Equals("/", StringComparison.Ordinal) && rootNode.HasOperations(label)) + { + return rootNode.PathItems[label].Operations; + } + + var urlSegments = relativeUrl.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); + + IDictionary operations = null; + + var targetChild = rootNode; + + /* This will help keep track of whether we've skipped a segment + * in the target url due to a possible parameter naming mismatch + * with the corresponding OpenApiUrlTreeNode target child segment. + */ + var parameterNameOffset = 0; + + for (var i = 0; i < urlSegments?.Length; i++) + { + var tempTargetChild = targetChild?.Children? + .FirstOrDefault(x => x.Key.Equals(urlSegments[i], + StringComparison.OrdinalIgnoreCase)).Value; + + // Segment name mismatch + if (tempTargetChild == null) + { + if (i == 0) + { + /* If no match and we are at the 1st segment of the relative url, + * exit; no need to continue matching subsequent segments. + */ + break; + } + + /* Attempt to get the parameter segment from the children of the current node: + * We are assuming a failed match because of different parameter namings + * between the relative url segment and the corresponding OpenApiUrlTreeNode segment name + * ex.: matching '/users/12345/messages' with '/users/{user-id}/messages' + */ + tempTargetChild = targetChild?.Children? + .FirstOrDefault(x => x.Value.IsParameter).Value; + + /* If no parameter segment exists in the children of the + * current node or we've already skipped a parameter + * segment in the relative url from the last pass, + * then exit; there's no match. + */ + if (tempTargetChild == null || parameterNameOffset > 0) + { + break; + } + + /* To help us know we've skipped a + * corresponding segment in the relative url. + */ + parameterNameOffset++; + } + else + { + parameterNameOffset = 0; + } + + // Move to the next segment + targetChild = tempTargetChild; + + // We want the operations of the last segment of the path. + if (i == urlSegments.Length - 1 && targetChild.HasOperations(label)) + { + operations = targetChild.PathItems[label].Operations; + } + } + + return operations; + } + private static IList FindOperations(OpenApiDocument graphOpenApi, Func predicate) { var search = new OperationSearch(predicate); From 00a0545bdea1a5db894e0f23e351a17e2ecd4a3a Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 7 Dec 2021 12:53:11 +0300 Subject: [PATCH 074/288] Create predicate based on the urls from the postman collection --- .../Services/OpenApiFilterService.cs | 47 +++++++++++++++++-- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 66ca5d446..74497a81e 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -52,16 +52,57 @@ public static Func CreatePredicate(string operationIds = { var regex = new Regex(tagsArray[0]); - predicate = (o) => o.Tags.Any(t => regex.IsMatch(t.Name)); + predicate = (o) => o.Tags.Any(tag => regex.IsMatch(tag.Name)); } else { - predicate = (o) => o.Tags.Any(t => tagsArray.Contains(t.Name)); + predicate = (o) => o.Tags.Any(tag => tagsArray.Contains(tag.Name)); } } else { - throw new InvalidOperationException("Either operationId(s) or tag(s) need to be specified."); + List openApiOps = new List(); + if (urls != null) + { + var graphVersion = source.Info.Version; + + var sources = new Dictionary { { graphVersion, source } }; + var rootNode = CreateOpenApiUrlTreeNode(sources); + + //Iterate through urls dictionary and fetch each url + foreach (var path in urls) + { + var url = FormatUrlString(path.Key); + + var openApiOperations = GetOpenApiOperations(rootNode, url, graphVersion); + if (openApiOperations == null) + { + continue; + } + + foreach (var method in path.Value) + { + var ops = openApiOperations + .Where(x => x.Key.ToString().Equals(method, StringComparison.OrdinalIgnoreCase)) + .Select(x => x.Value).ToList(); + + openApiOps.AddRange(ops); + } + } + if (!(openApiOps?.Any() ?? false)) + { + throw new ArgumentException("The urls in the postman collection supplied could not be found."); + } + + // Fetch the corresponding Operations Id(s) for the matched url + var operationIdsArray = openApiOps.Select(x => x.OperationId).ToArray(); + + predicate = (o) => operationIdsArray.Contains(o.OperationId); + } + else + { + throw new InvalidOperationException("Either operationId(s),tag(s) or postman collection need to be specified."); + } } return predicate; From 0cf02d4e3f22b57765dd786f7f92565dc4b7e6cd Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 7 Dec 2021 12:57:07 +0300 Subject: [PATCH 075/288] Use object initializer --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 74497a81e..89d9cc593 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -130,12 +130,11 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun Extensions = source.Info.Extensions }, - Components = new OpenApiComponents() + Components = new OpenApiComponents {SecuritySchemes = source.Components.SecuritySchemes}, + SecurityRequirements = source.SecurityRequirements, + Servers = source.Servers }; - subset.Components.SecuritySchemes = source.Components.SecuritySchemes; - subset.SecurityRequirements = source.SecurityRequirements; - subset.Servers = source.Servers; var results = FindOperations(source, predicate); foreach (var result in results) From 13b351dcd05bb39a7ab4795940dbc614d6d7d7d6 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 7 Dec 2021 12:58:24 +0300 Subject: [PATCH 076/288] Fix line formatting --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 89d9cc593..1aeac900c 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -135,7 +135,6 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun Servers = source.Servers }; - var results = FindOperations(source, predicate); foreach (var result in results) { From 23a8991f78e09e8db3c25af1e31529257a41cfa2 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 7 Dec 2021 12:59:46 +0300 Subject: [PATCH 077/288] Check expression for null --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 1aeac900c..75a285ed0 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.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; @@ -156,7 +156,10 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun } } - pathItem.Operations.Add((OperationType)result.CurrentKeys.Operation, result.Operation); + if (result.CurrentKeys.Operation != null) + { + pathItem.Operations.Add((OperationType)result.CurrentKeys.Operation, result.Operation); + } } if (subset.Paths == null) From 21c1f20053abaff839b0d156332bdb45e651cd76 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 7 Dec 2021 16:22:52 +0300 Subject: [PATCH 078/288] Move declaration to the outer scope --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 42765a371..c08e0d84c 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -51,6 +51,7 @@ public static void ProcessOpenApiDocument( ).ReadAsync(stream).GetAwaiter().GetResult(); var document = result.OpenApiDocument; + Func predicate; // Check if filter options are provided, then execute if (!string.IsNullOrEmpty(filterByOperationIds) && !string.IsNullOrEmpty(filterByTags)) @@ -59,12 +60,12 @@ public static void ProcessOpenApiDocument( } if (!string.IsNullOrEmpty(filterByOperationIds)) { - var predicate = OpenApiFilterService.CreatePredicate(operationIds: filterByOperationIds); + predicate = OpenApiFilterService.CreatePredicate(operationIds: filterByOperationIds); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } if (!string.IsNullOrEmpty(filterByTags)) { - var predicate = OpenApiFilterService.CreatePredicate(tags: filterByTags); + predicate = OpenApiFilterService.CreatePredicate(tags: filterByTags); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } @@ -72,7 +73,7 @@ public static void ProcessOpenApiDocument( { var fileStream = GetStream(filterByCollection); var urlDictionary = OpenApiFilterService.ParseJsonCollectionFile(fileStream); - var predicate = OpenApiFilterService.CreatePredicate(urls: urlDictionary, source:document); + predicate = OpenApiFilterService.CreatePredicate(urls: urlDictionary, source:document); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } From 1915ae626b778a9fc887fb1aee9499c0cb205c88 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 7 Dec 2021 17:00:40 +0300 Subject: [PATCH 079/288] Clean up code --- .../Services/OpenApiFilterService.cs | 67 ++++++++++--------- 1 file changed, 34 insertions(+), 33 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 75a285ed0..03a97496c 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -59,52 +59,53 @@ public static Func CreatePredicate(string operationIds = predicate = (o) => o.Tags.Any(tag => tagsArray.Contains(tag.Name)); } } - else + else if (urls != null) { List openApiOps = new List(); - if (urls != null) - { - var graphVersion = source.Info.Version; - var sources = new Dictionary { { graphVersion, source } }; - var rootNode = CreateOpenApiUrlTreeNode(sources); + var graphVersion = source.Info.Version; - //Iterate through urls dictionary and fetch each url - foreach (var path in urls) - { - var url = FormatUrlString(path.Key); - - var openApiOperations = GetOpenApiOperations(rootNode, url, graphVersion); - if (openApiOperations == null) - { - continue; - } - - foreach (var method in path.Value) - { - var ops = openApiOperations - .Where(x => x.Key.ToString().Equals(method, StringComparison.OrdinalIgnoreCase)) - .Select(x => x.Value).ToList(); - - openApiOps.AddRange(ops); - } - } - if (!(openApiOps?.Any() ?? false)) + var sources = new Dictionary {{graphVersion, source}}; + var rootNode = CreateOpenApiUrlTreeNode(sources); + + //Iterate through urls dictionary and fetch each url + foreach (var path in urls) + { + var url = FormatUrlString(path.Key); + + var openApiOperations = GetOpenApiOperations(rootNode, url, graphVersion); + if (openApiOperations == null) { - throw new ArgumentException("The urls in the postman collection supplied could not be found."); + continue; } - // Fetch the corresponding Operations Id(s) for the matched url - var operationIdsArray = openApiOps.Select(x => x.OperationId).ToArray(); + foreach (var method in path.Value) + { + var ops = openApiOperations + .Where(x => x.Key.ToString().Equals(method, StringComparison.OrdinalIgnoreCase)) + .Select(x => x.Value).ToList(); - predicate = (o) => operationIdsArray.Contains(o.OperationId); + openApiOps.AddRange(ops); + } } - else + + if (!(openApiOps?.Any() ?? false)) { - throw new InvalidOperationException("Either operationId(s),tag(s) or postman collection need to be specified."); + throw new ArgumentException("The urls in the postman collection supplied could not be found."); } + + // Fetch the corresponding Operations Id(s) for the matched url + var operationIdsArray = openApiOps.Select(x => x.OperationId).ToArray(); + + predicate = (o) => operationIdsArray.Contains(o.OperationId); } + else + { + throw new InvalidOperationException("Either operationId(s),tag(s) or postman collection need to be specified."); + } + + return predicate; } From 4a940c95b97460687a5f1670be66b086957f5e55 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 7 Dec 2021 17:04:31 +0300 Subject: [PATCH 080/288] Fix line formatting --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 03a97496c..749cd8bb8 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -105,7 +105,6 @@ public static Func CreatePredicate(string operationIds = throw new InvalidOperationException("Either operationId(s),tag(s) or postman collection need to be specified."); } - return predicate; } From fd44771a6c9a88a90300f659d4813885f09c86a4 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Wed, 27 Oct 2021 11:00:39 +0200 Subject: [PATCH 081/288] Silence xUnit1013 warning --- .../Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs index dd6e2554b..bee746eae 100644 --- a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs @@ -150,7 +150,7 @@ public void OpenApiWorkspacesShouldNormalizeDocumentLocations() // Enable Workspace to load from any reader, not just streams. // Test fragments - public void OpenApiWorkspacesShouldLoadDocumentFragments() + internal void OpenApiWorkspacesShouldLoadDocumentFragments() { Assert.True(false); } From bac54ed620f3bc5ade7ac225249ab2bfe9c606d8 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Wed, 27 Oct 2021 11:01:00 +0200 Subject: [PATCH 082/288] Teach OpenApiJsonWriter to produce a terse output --- .../Writers/OpenApiJsonWriter.cs | 63 ++++++++++++++++--- .../Writers/OpenApiJsonWriterSettings.cs | 19 ++++++ .../Writers/WriterConstants.cs | 8 ++- .../PublicApi/PublicApi.approved.txt | 7 +++ 4 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 src/Microsoft.OpenApi/Writers/OpenApiJsonWriterSettings.cs diff --git a/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs b/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs index 72e74a51e..5454e8da8 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs @@ -18,6 +18,16 @@ public OpenApiJsonWriter(TextWriter textWriter) : base(textWriter, null) { } + /// + /// Initializes a new instance of the class. + /// + /// The text writer. + /// Settings for controlling how the OpenAPI document will be written out. + public OpenApiJsonWriter(TextWriter textWriter, OpenApiJsonWriterSettings settings) : base(textWriter, settings) + { + _produceTerseOutput = settings.Terse; + } + /// /// Initializes a new instance of the class. /// @@ -27,6 +37,11 @@ public OpenApiJsonWriter(TextWriter textWriter, OpenApiWriterSettings settings) { } + /// + /// Indicates whether or not the produced document will be written in a compact or pretty fashion. + /// + private bool _produceTerseOutput = false; + /// /// Base Indentation Level. /// This denotes how many indentations are needed for the property in the base object. @@ -51,7 +66,7 @@ public override void WriteStartObject() Writer.Write(WriterConstants.ArrayElementSeparator); } - Writer.WriteLine(); + WriteLine(); WriteIndentation(); } @@ -68,13 +83,16 @@ public override void WriteEndObject() var currentScope = EndScope(ScopeType.Object); if (currentScope.ObjectCount != 0) { - Writer.WriteLine(); + WriteLine(); DecreaseIndentation(); WriteIndentation(); } else { - Writer.Write(WriterConstants.WhiteSpaceForEmptyObject); + if (!_produceTerseOutput) + { + Writer.Write(WriterConstants.WhiteSpaceForEmptyObject); + } DecreaseIndentation(); } @@ -99,7 +117,7 @@ public override void WriteStartArray() Writer.Write(WriterConstants.ArrayElementSeparator); } - Writer.WriteLine(); + WriteLine(); WriteIndentation(); } @@ -115,7 +133,7 @@ public override void WriteEndArray() var current = EndScope(ScopeType.Array); if (current.ObjectCount != 0) { - Writer.WriteLine(); + WriteLine(); DecreaseIndentation(); WriteIndentation(); } @@ -143,7 +161,7 @@ public override void WritePropertyName(string name) Writer.Write(WriterConstants.ObjectMemberSeparator); } - Writer.WriteLine(); + WriteLine(); currentScope.ObjectCount++; @@ -154,6 +172,11 @@ public override void WritePropertyName(string name) Writer.Write(name); Writer.Write(WriterConstants.NameValueSeparator); + + if (!_produceTerseOutput) + { + Writer.Write(WriterConstants.NameValueSeparatorWhiteSpaceSuffix); + } } /// @@ -198,7 +221,7 @@ protected override void WriteValueSeparator() Writer.Write(WriterConstants.ArrayElementSeparator); } - Writer.WriteLine(); + WriteLine(); WriteIndentation(); currentScope.ObjectCount++; } @@ -212,5 +235,31 @@ public override void WriteRaw(string value) WriteValueSeparator(); Writer.Write(value); } + + /// + /// Write the indentation. + /// + public override void WriteIndentation() + { + if (_produceTerseOutput) + { + return; + } + + base.WriteIndentation(); + } + + /// + /// Writes a line terminator to the text string or stream. + /// + private void WriteLine() + { + if (_produceTerseOutput) + { + return; + } + + Writer.WriteLine(); + } } } diff --git a/src/Microsoft.OpenApi/Writers/OpenApiJsonWriterSettings.cs b/src/Microsoft.OpenApi/Writers/OpenApiJsonWriterSettings.cs new file mode 100644 index 000000000..4784dc9cf --- /dev/null +++ b/src/Microsoft.OpenApi/Writers/OpenApiJsonWriterSettings.cs @@ -0,0 +1,19 @@ +namespace Microsoft.OpenApi.Writers +{ + /// + /// Configuration settings to control how OpenAPI Json documents are written + /// + public class OpenApiJsonWriterSettings : OpenApiWriterSettings + { + /// + /// Initializes a new instance of the class. + /// + public OpenApiJsonWriterSettings() + { } + + /// + /// Indicates whether or not the produced document will be written in a compact or pretty fashion. + /// + public bool Terse { get; set; } = false; + } +} diff --git a/src/Microsoft.OpenApi/Writers/WriterConstants.cs b/src/Microsoft.OpenApi/Writers/WriterConstants.cs index bfc943797..5b4f2da91 100644 --- a/src/Microsoft.OpenApi/Writers/WriterConstants.cs +++ b/src/Microsoft.OpenApi/Writers/WriterConstants.cs @@ -81,7 +81,13 @@ internal static class WriterConstants /// /// The separator between the name and the value. /// - internal const string NameValueSeparator = ": "; + internal const string NameValueSeparator = ":"; + + /// + /// The white space postfixing + /// when producing pretty content. + /// + internal const string NameValueSeparatorWhiteSpaceSuffix = " "; /// /// The white space for empty object diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 0b681a8ec..dd02453e5 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -1253,10 +1253,12 @@ namespace Microsoft.OpenApi.Writers public class OpenApiJsonWriter : Microsoft.OpenApi.Writers.OpenApiWriterBase { public OpenApiJsonWriter(System.IO.TextWriter textWriter) { } + public OpenApiJsonWriter(System.IO.TextWriter textWriter, Microsoft.OpenApi.Writers.OpenApiJsonWriterSettings settings) { } public OpenApiJsonWriter(System.IO.TextWriter textWriter, Microsoft.OpenApi.Writers.OpenApiWriterSettings settings) { } protected override int BaseIndentation { get; } public override void WriteEndArray() { } public override void WriteEndObject() { } + public override void WriteIndentation() { } public override void WriteNull() { } public override void WritePropertyName(string name) { } public override void WriteRaw(string value) { } @@ -1265,6 +1267,11 @@ namespace Microsoft.OpenApi.Writers public override void WriteValue(string value) { } protected override void WriteValueSeparator() { } } + public class OpenApiJsonWriterSettings : Microsoft.OpenApi.Writers.OpenApiWriterSettings + { + public OpenApiJsonWriterSettings() { } + public bool Terse { get; set; } + } public static class OpenApiWriterAnyExtensions { public static void WriteAny(this Microsoft.OpenApi.Writers.IOpenApiWriter writer, T any) From 9868348be75fae9c3a803c5ab9a2adfd4a508a52 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 31 Oct 2021 14:48:10 +0100 Subject: [PATCH 083/288] Reference Verify test helper --- test/.gitignore | 1 + .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- .../Microsoft.OpenApi.SmokeTests.csproj | 4 ++-- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 4 +++- 4 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 test/.gitignore diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 000000000..1c9a99104 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +*.received.* 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 265d134f7..5eaa180aa 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 @@  - net462;net50 + net48;net50 false Microsoft diff --git a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj index 6792f2362..44d85ee21 100644 --- a/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj +++ b/test/Microsoft.OpenApi.SmokeTests/Microsoft.OpenApi.SmokeTests.csproj @@ -1,11 +1,11 @@  - net462 + net48 - TRACE;DEBUG;net462 + TRACE;DEBUG;NET48 diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 346d1bcc4..fa40b4a8a 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -1,6 +1,6 @@  - net462;net50 + net48;net50 false Microsoft @@ -19,6 +19,8 @@ + + all From 76a7cc1815085a58b20ab0c07edb31028351a161 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 31 Oct 2021 14:49:07 +0100 Subject: [PATCH 084/288] Ensure OpenApiCallbackTests cover terse output --- ...orks_produceTerseOutput=False.verified.txt | 20 +++++ ...Works_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 20 +++++ ...Works_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 3 + ...Works_produceTerseOutput=True.verified.txt | 1 + .../Models/OpenApiCallbackTests.cs | 86 +++++-------------- 7 files changed, 67 insertions(+), 65 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorks_produceTerseOutput=True.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..8017028d1 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,20 @@ +{ + "$request.body#/url": { + "post": { + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "responses": { + "200": { + "description": "Success" + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..690cc5e9d --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeAdvancedCallbackAsV3JsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"$request.body#/url":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Success"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..8017028d1 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,20 @@ +{ + "$request.body#/url": { + "post": { + "requestBody": { + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + } + }, + "responses": { + "200": { + "description": "Success" + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..690cc5e9d --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"$request.body#/url":{"post":{"requestBody":{"content":{"application/json":{"schema":{"type":"object"}}}},"responses":{"200":{"description":"Success"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..8c9f1f140 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,3 @@ +{ + "$ref": "#/components/callbacks/simpleHook" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..20e44f987 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.SerializeReferencedCallbackAsV3JsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"$ref":"#/components/callbacks/simpleHook"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs index fbc86e7f9..9d512566f 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs @@ -3,16 +3,18 @@ using System.Globalization; using System.IO; -using FluentAssertions; +using System.Threading.Tasks; using Microsoft.OpenApi.Expressions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; +using VerifyXunit; using Xunit; using Xunit.Abstractions; namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] + [UsesVerify] public class OpenApiCallbackTests { public static OpenApiCallback AdvancedCallback = new OpenApiCallback @@ -103,33 +105,14 @@ public OpenApiCallbackTests(ITestOutputHelper output) _output = output; } - [Fact] - public void SerializeAdvancedCallbackAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeAdvancedCallbackAsV3JsonWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""$request.body#/url"": { - ""post"": { - ""requestBody"": { - ""content"": { - ""application/json"": { - ""schema"": { - ""type"": ""object"" - } - } - } - }, - ""responses"": { - ""200"": { - ""description"": ""Success"" - } - } - } - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedCallback.SerializeAsV3(writer); @@ -137,21 +120,17 @@ public void SerializeAdvancedCallbackAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedCallbackAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedCallbackAsV3JsonWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""$ref"": ""#/components/callbacks/simpleHook"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedCallback.SerializeAsV3(writer); @@ -159,38 +138,17 @@ public void SerializeReferencedCallbackAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""$request.body#/url"": { - ""post"": { - ""requestBody"": { - ""content"": { - ""application/json"": { - ""schema"": { - ""type"": ""object"" - } - } - } - }, - ""responses"": { - ""200"": { - ""description"": ""Success"" - } - } - } - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedCallback.SerializeAsV3WithoutReference(writer); @@ -198,9 +156,7 @@ public void SerializeReferencedCallbackAsV3JsonWithoutReferenceWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } } } From d0cc1b6c82f4968081bdb289892888afc2f7990e Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 31 Oct 2021 14:49:58 +0100 Subject: [PATCH 085/288] Ensure OpenApiDocumentTests cover terse output --- ...orks_produceTerseOutput=False.verified.txt | 416 ++++ ...Works_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 495 +++++ ...Works_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 249 +++ ...Works_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 296 +++ ...Works_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 68 + ...Works_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 75 + ...Works_produceTerseOutput=True.verified.txt | 1 + .../Models/OpenApiDocumentTests.cs | 1677 +---------------- 13 files changed, 1644 insertions(+), 1638 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=True.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..96eff63d4 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,416 @@ +{ + "swagger": "2.0", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "url": "http://swagger.io", + "email": "foo@example.com" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.0.0" + }, + "host": "petstore.swagger.io", + "basePath": "/api", + "schemes": [ + "http" + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "produces": [ + "application/json", + "application/xml", + "text/html" + ], + "parameters": [ + { + "in": "query", + "name": "tags", + "description": "tags to filter by", + "type": "array", + "items": { + "type": "string" + } + }, + { + "in": "query", + "name": "limit", + "description": "maximum number of results to return", + "type": "integer", + "format": "int32" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json", + "text/html" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "Pet to add to the store", + "required": true, + "schema": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "produces": [ + "application/json", + "application/xml", + "text/html" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "ID of pet to fetch", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "produces": [ + "text/html" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "ID of pet to delete", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "definitions": { + "pet": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..903ff33f7 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV2JsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"}},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}},"5XX":{"description":"unexpected server error","schema":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}}}}},"definitions":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..a688f8525 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,495 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "url": "http://swagger.io", + "email": "foo@example.com" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.0.0" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/api" + } + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "tags to filter by", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "limit", + "in": "query", + "description": "maximum number of results to return", + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "requestBody": { + "description": "Pet to add to the store", + "content": { + "application/json": { + "schema": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + }, + "application/xml": { + "schema": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "pet": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..0bb1c9679 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentAsV3JsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","parameters":[{"name":"tags","in":"query","description":"tags to filter by","schema":{"type":"array","items":{"type":"string"}}},{"name":"limit","in":"query","description":"maximum number of results to return","schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"application/xml":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","requestBody":{"description":"Pet to add to the store","content":{"application/json":{"schema":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}},"required":true},"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","parameters":[{"name":"id","in":"path","description":"ID of pet to fetch","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}},"application/xml":{"schema":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","parameters":[{"name":"id","in":"path","description":"ID of pet to delete","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}}}}}},"components":{"schemas":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..0e3b74125 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,249 @@ +{ + "swagger": "2.0", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "url": "http://swagger.io", + "email": "foo@example.com" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.0.0" + }, + "host": "petstore.swagger.io", + "basePath": "/api", + "schemes": [ + "http" + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "produces": [ + "application/json", + "application/xml", + "text/html" + ], + "parameters": [ + { + "in": "query", + "name": "tags", + "description": "tags to filter by", + "type": "array", + "items": { + "type": "string" + } + }, + { + "in": "query", + "name": "limit", + "description": "maximum number of results to return", + "type": "integer", + "format": "int32" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/pet" + } + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "$ref": "#/definitions/errorModel" + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "$ref": "#/definitions/errorModel" + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json", + "text/html" + ], + "parameters": [ + { + "in": "body", + "name": "body", + "description": "Pet to add to the store", + "required": true, + "schema": { + "$ref": "#/definitions/newPet" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "$ref": "#/definitions/pet" + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "$ref": "#/definitions/errorModel" + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "$ref": "#/definitions/errorModel" + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "produces": [ + "application/json", + "application/xml", + "text/html" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "ID of pet to fetch", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "$ref": "#/definitions/pet" + } + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "$ref": "#/definitions/errorModel" + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "$ref": "#/definitions/errorModel" + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "produces": [ + "text/html" + ], + "parameters": [ + { + "in": "path", + "name": "id", + "description": "ID of pet to delete", + "required": true, + "type": "integer", + "format": "int64" + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "schema": { + "$ref": "#/definitions/errorModel" + } + }, + "5XX": { + "description": "unexpected server error", + "schema": { + "$ref": "#/definitions/errorModel" + } + } + } + } + } + }, + "definitions": { + "pet": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "format": "int32", + "type": "integer" + }, + "message": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..b54e2ac86 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV2JsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"query","name":"tags","description":"tags to filter by","type":"array","items":{"type":"string"}},{"in":"query","name":"limit","description":"maximum number of results to return","type":"integer","format":"int32"}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"$ref":"#/definitions/pet"}}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","consumes":["application/json"],"produces":["application/json","text/html"],"parameters":[{"in":"body","name":"body","description":"Pet to add to the store","required":true,"schema":{"$ref":"#/definitions/newPet"}}],"responses":{"200":{"description":"pet response","schema":{"$ref":"#/definitions/pet"}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","produces":["application/json","application/xml","text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to fetch","required":true,"type":"integer","format":"int64"}],"responses":{"200":{"description":"pet response","schema":{"$ref":"#/definitions/pet"}},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","produces":["text/html"],"parameters":[{"in":"path","name":"id","description":"ID of pet to delete","required":true,"type":"integer","format":"int64"}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","schema":{"$ref":"#/definitions/errorModel"}},"5XX":{"description":"unexpected server error","schema":{"$ref":"#/definitions/errorModel"}}}}}},"definitions":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"format":"int32","type":"integer"},"message":{"type":"string"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..f1da0b354 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,296 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "termsOfService": "http://helloreverb.com/terms/", + "contact": { + "name": "Swagger API team", + "url": "http://swagger.io", + "email": "foo@example.com" + }, + "license": { + "name": "MIT", + "url": "http://opensource.org/licenses/MIT" + }, + "version": "1.0.0" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/api" + } + ], + "paths": { + "/pets": { + "get": { + "description": "Returns all pets from the system that the user has access to", + "operationId": "findPets", + "parameters": [ + { + "name": "tags", + "in": "query", + "description": "tags to filter by", + "schema": { + "type": "array", + "items": { + "type": "string" + } + } + }, + { + "name": "limit", + "in": "query", + "description": "maximum number of results to return", + "schema": { + "type": "integer", + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + }, + "application/xml": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/pet" + } + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + } + } + }, + "post": { + "description": "Creates a new pet in the store. Duplicates are allowed", + "operationId": "addPet", + "requestBody": { + "description": "Pet to add to the store", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/newPet" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + } + } + } + }, + "/pets/{id}": { + "get": { + "description": "Returns a user based on a single ID, if the user does not have access to the pet", + "operationId": "findPetById", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to fetch", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/pet" + } + }, + "application/xml": { + "schema": { + "$ref": "#/components/schemas/pet" + } + } + } + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + } + } + }, + "delete": { + "description": "deletes a single pet based on the ID supplied", + "operationId": "deletePet", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "ID of pet to delete", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + ], + "responses": { + "204": { + "description": "pet deleted" + }, + "4XX": { + "description": "unexpected client error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + }, + "5XX": { + "description": "unexpected server error", + "content": { + "text/html": { + "schema": { + "$ref": "#/components/schemas/errorModel" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "pet": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "newPet": { + "required": [ + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + }, + "errorModel": { + "required": [ + "code", + "message" + ], + "type": "object", + "properties": { + "code": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..be8dcc627 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeAdvancedDocumentWithReferenceAsV3JsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","termsOfService":"http://helloreverb.com/terms/","contact":{"name":"Swagger API team","url":"http://swagger.io","email":"foo@example.com"},"license":{"name":"MIT","url":"http://opensource.org/licenses/MIT"},"version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","operationId":"findPets","parameters":[{"name":"tags","in":"query","description":"tags to filter by","schema":{"type":"array","items":{"type":"string"}}},{"name":"limit","in":"query","description":"maximum number of results to return","schema":{"type":"integer","format":"int32"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/pet"}}},"application/xml":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/pet"}}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}}}},"post":{"description":"Creates a new pet in the store. Duplicates are allowed","operationId":"addPet","requestBody":{"description":"Pet to add to the store","content":{"application/json":{"schema":{"$ref":"#/components/schemas/newPet"}}},"required":true},"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/pet"}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}}}}},"/pets/{id}":{"get":{"description":"Returns a user based on a single ID, if the user does not have access to the pet","operationId":"findPetById","parameters":[{"name":"id","in":"path","description":"ID of pet to fetch","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/pet"}},"application/xml":{"schema":{"$ref":"#/components/schemas/pet"}}}},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}}}},"delete":{"description":"deletes a single pet based on the ID supplied","operationId":"deletePet","parameters":[{"name":"id","in":"path","description":"ID of pet to delete","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"204":{"description":"pet deleted"},"4XX":{"description":"unexpected client error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}},"5XX":{"description":"unexpected server error","content":{"text/html":{"schema":{"$ref":"#/components/schemas/errorModel"}}}}}}}},"components":{"schemas":{"pet":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"newPet":{"required":["name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}},"errorModel":{"required":["code","message"],"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..671c21ec5 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,68 @@ +{ + "swagger": "2.0", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "version": "1.0.0" + }, + "host": "petstore.swagger.io", + "basePath": "/api", + "schemes": [ + "http" + ], + "paths": { + "/add/{operand1}/{operand2}": { + "get": { + "operationId": "addByOperand1AndByOperand2", + "produces": [ + "application/json" + ], + "parameters": [ + { + "in": "path", + "name": "operand1", + "description": "The first operand", + "required": true, + "type": "integer", + "my-extension": 4 + }, + { + "in": "path", + "name": "operand2", + "description": "The second operand", + "required": true, + "type": "integer", + "my-extension": 4 + } + ], + "responses": { + "200": { + "description": "pet response", + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "format": "int64", + "type": "integer" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..7dd31e201 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV2JsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"swagger":"2.0","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","version":"1.0.0"},"host":"petstore.swagger.io","basePath":"/api","schemes":["http"],"paths":{"/add/{operand1}/{operand2}":{"get":{"operationId":"addByOperand1AndByOperand2","produces":["application/json"],"parameters":[{"in":"path","name":"operand1","description":"The first operand","required":true,"type":"integer","my-extension":4},{"in":"path","name":"operand2","description":"The second operand","required":true,"type":"integer","my-extension":4}],"responses":{"200":{"description":"pet response","schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"format":"int64","type":"integer"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..c2e9f5312 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,75 @@ +{ + "openapi": "3.0.1", + "info": { + "title": "Swagger Petstore (Simple)", + "description": "A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification", + "version": "1.0.0" + }, + "servers": [ + { + "url": "http://petstore.swagger.io/api" + } + ], + "paths": { + "/add/{operand1}/{operand2}": { + "get": { + "operationId": "addByOperand1AndByOperand2", + "parameters": [ + { + "name": "operand1", + "in": "path", + "description": "The first operand", + "required": true, + "schema": { + "type": "integer", + "my-extension": 4 + }, + "my-extension": 4 + }, + { + "name": "operand2", + "in": "path", + "description": "The second operand", + "required": true, + "schema": { + "type": "integer", + "my-extension": 4 + }, + "my-extension": 4 + } + ], + "responses": { + "200": { + "description": "pet response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "required": [ + "id", + "name" + ], + "type": "object", + "properties": { + "id": { + "type": "integer", + "format": "int64" + }, + "name": { + "type": "string" + }, + "tag": { + "type": "string" + } + } + } + } + } + } + } + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..da61a8817 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"openapi":"3.0.1","info":{"title":"Swagger Petstore (Simple)","description":"A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification","version":"1.0.0"},"servers":[{"url":"http://petstore.swagger.io/api"}],"paths":{"/add/{operand1}/{operand2}":{"get":{"operationId":"addByOperand1AndByOperand2","parameters":[{"name":"operand1","in":"path","description":"The first operand","required":true,"schema":{"type":"integer","my-extension":4},"my-extension":4},{"name":"operand2","in":"path","description":"The second operand","required":true,"schema":{"type":"integer","my-extension":4},"my-extension":4}],"responses":{"200":{"description":"pet response","content":{"application/json":{"schema":{"type":"array","items":{"required":["id","name"],"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"},"tag":{"type":"string"}}}}}}}}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs index ea65ec6eb..10cadd597 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs @@ -5,17 +5,20 @@ using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Threading.Tasks; using FluentAssertions; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; +using VerifyXunit; using Xunit; using Xunit.Abstractions; namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] + [UsesVerify] public class OpenApiDocumentTests { public static OpenApiComponents TopLevelReferencingComponents = new OpenApiComponents() @@ -982,508 +985,14 @@ public OpenApiDocumentTests(ITestOutputHelper output) _output = output; } - [Fact] - public void SerializeAdvancedDocumentAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeAdvancedDocumentAsV3JsonWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""openapi"": ""3.0.1"", - ""info"": { - ""title"": ""Swagger Petstore (Simple)"", - ""description"": ""A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification"", - ""termsOfService"": ""http://helloreverb.com/terms/"", - ""contact"": { - ""name"": ""Swagger API team"", - ""url"": ""http://swagger.io"", - ""email"": ""foo@example.com"" - }, - ""license"": { - ""name"": ""MIT"", - ""url"": ""http://opensource.org/licenses/MIT"" - }, - ""version"": ""1.0.0"" - }, - ""servers"": [ - { - ""url"": ""http://petstore.swagger.io/api"" - } - ], - ""paths"": { - ""/pets"": { - ""get"": { - ""description"": ""Returns all pets from the system that the user has access to"", - ""operationId"": ""findPets"", - ""parameters"": [ - { - ""name"": ""tags"", - ""in"": ""query"", - ""description"": ""tags to filter by"", - ""schema"": { - ""type"": ""array"", - ""items"": { - ""type"": ""string"" - } - } - }, - { - ""name"": ""limit"", - ""in"": ""query"", - ""description"": ""maximum number of results to return"", - ""schema"": { - ""type"": ""integer"", - ""format"": ""int32"" - } - } - ], - ""responses"": { - ""200"": { - ""description"": ""pet response"", - ""content"": { - ""application/json"": { - ""schema"": { - ""type"": ""array"", - ""items"": { - ""required"": [ - ""id"", - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""type"": ""integer"", - ""format"": ""int64"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - } - } - }, - ""application/xml"": { - ""schema"": { - ""type"": ""array"", - ""items"": { - ""required"": [ - ""id"", - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""type"": ""integer"", - ""format"": ""int64"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - } - } - } - } - }, - ""4XX"": { - ""description"": ""unexpected client error"", - ""content"": { - ""text/html"": { - ""schema"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""type"": ""integer"", - ""format"": ""int32"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - } - } - }, - ""5XX"": { - ""description"": ""unexpected server error"", - ""content"": { - ""text/html"": { - ""schema"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""type"": ""integer"", - ""format"": ""int32"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - } - } - } - } - }, - ""post"": { - ""description"": ""Creates a new pet in the store. Duplicates are allowed"", - ""operationId"": ""addPet"", - ""requestBody"": { - ""description"": ""Pet to add to the store"", - ""content"": { - ""application/json"": { - ""schema"": { - ""required"": [ - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""type"": ""integer"", - ""format"": ""int64"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - } - } - }, - ""required"": true - }, - ""responses"": { - ""200"": { - ""description"": ""pet response"", - ""content"": { - ""application/json"": { - ""schema"": { - ""required"": [ - ""id"", - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""type"": ""integer"", - ""format"": ""int64"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - } - } - } - }, - ""4XX"": { - ""description"": ""unexpected client error"", - ""content"": { - ""text/html"": { - ""schema"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""type"": ""integer"", - ""format"": ""int32"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - } - } - }, - ""5XX"": { - ""description"": ""unexpected server error"", - ""content"": { - ""text/html"": { - ""schema"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""type"": ""integer"", - ""format"": ""int32"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - } - } - } - } - } - }, - ""/pets/{id}"": { - ""get"": { - ""description"": ""Returns a user based on a single ID, if the user does not have access to the pet"", - ""operationId"": ""findPetById"", - ""parameters"": [ - { - ""name"": ""id"", - ""in"": ""path"", - ""description"": ""ID of pet to fetch"", - ""required"": true, - ""schema"": { - ""type"": ""integer"", - ""format"": ""int64"" - } - } - ], - ""responses"": { - ""200"": { - ""description"": ""pet response"", - ""content"": { - ""application/json"": { - ""schema"": { - ""required"": [ - ""id"", - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""type"": ""integer"", - ""format"": ""int64"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - } - }, - ""application/xml"": { - ""schema"": { - ""required"": [ - ""id"", - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""type"": ""integer"", - ""format"": ""int64"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - } - } - } - }, - ""4XX"": { - ""description"": ""unexpected client error"", - ""content"": { - ""text/html"": { - ""schema"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""type"": ""integer"", - ""format"": ""int32"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - } - } - }, - ""5XX"": { - ""description"": ""unexpected server error"", - ""content"": { - ""text/html"": { - ""schema"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""type"": ""integer"", - ""format"": ""int32"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - } - } - } - } - }, - ""delete"": { - ""description"": ""deletes a single pet based on the ID supplied"", - ""operationId"": ""deletePet"", - ""parameters"": [ - { - ""name"": ""id"", - ""in"": ""path"", - ""description"": ""ID of pet to delete"", - ""required"": true, - ""schema"": { - ""type"": ""integer"", - ""format"": ""int64"" - } - } - ], - ""responses"": { - ""204"": { - ""description"": ""pet deleted"" - }, - ""4XX"": { - ""description"": ""unexpected client error"", - ""content"": { - ""text/html"": { - ""schema"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""type"": ""integer"", - ""format"": ""int32"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - } - } - }, - ""5XX"": { - ""description"": ""unexpected server error"", - ""content"": { - ""text/html"": { - ""schema"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""type"": ""integer"", - ""format"": ""int32"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - } - } - } - } - } - } - }, - ""components"": { - ""schemas"": { - ""pet"": { - ""required"": [ - ""id"", - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""type"": ""integer"", - ""format"": ""int64"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - }, - ""newPet"": { - ""required"": [ - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""type"": ""integer"", - ""format"": ""int64"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - }, - ""errorModel"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""type"": ""integer"", - ""format"": ""int32"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - } - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedDocument.SerializeAsV3(writer); @@ -1491,314 +1000,17 @@ public void SerializeAdvancedDocumentAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeAdvancedDocumentWithReferenceAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeAdvancedDocumentWithReferenceAsV3JsonWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""openapi"": ""3.0.1"", - ""info"": { - ""title"": ""Swagger Petstore (Simple)"", - ""description"": ""A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification"", - ""termsOfService"": ""http://helloreverb.com/terms/"", - ""contact"": { - ""name"": ""Swagger API team"", - ""url"": ""http://swagger.io"", - ""email"": ""foo@example.com"" - }, - ""license"": { - ""name"": ""MIT"", - ""url"": ""http://opensource.org/licenses/MIT"" - }, - ""version"": ""1.0.0"" - }, - ""servers"": [ - { - ""url"": ""http://petstore.swagger.io/api"" - } - ], - ""paths"": { - ""/pets"": { - ""get"": { - ""description"": ""Returns all pets from the system that the user has access to"", - ""operationId"": ""findPets"", - ""parameters"": [ - { - ""name"": ""tags"", - ""in"": ""query"", - ""description"": ""tags to filter by"", - ""schema"": { - ""type"": ""array"", - ""items"": { - ""type"": ""string"" - } - } - }, - { - ""name"": ""limit"", - ""in"": ""query"", - ""description"": ""maximum number of results to return"", - ""schema"": { - ""type"": ""integer"", - ""format"": ""int32"" - } - } - ], - ""responses"": { - ""200"": { - ""description"": ""pet response"", - ""content"": { - ""application/json"": { - ""schema"": { - ""type"": ""array"", - ""items"": { - ""$ref"": ""#/components/schemas/pet"" - } - } - }, - ""application/xml"": { - ""schema"": { - ""type"": ""array"", - ""items"": { - ""$ref"": ""#/components/schemas/pet"" - } - } - } - } - }, - ""4XX"": { - ""description"": ""unexpected client error"", - ""content"": { - ""text/html"": { - ""schema"": { - ""$ref"": ""#/components/schemas/errorModel"" - } - } - } - }, - ""5XX"": { - ""description"": ""unexpected server error"", - ""content"": { - ""text/html"": { - ""schema"": { - ""$ref"": ""#/components/schemas/errorModel"" - } - } - } - } - } - }, - ""post"": { - ""description"": ""Creates a new pet in the store. Duplicates are allowed"", - ""operationId"": ""addPet"", - ""requestBody"": { - ""description"": ""Pet to add to the store"", - ""content"": { - ""application/json"": { - ""schema"": { - ""$ref"": ""#/components/schemas/newPet"" - } - } - }, - ""required"": true - }, - ""responses"": { - ""200"": { - ""description"": ""pet response"", - ""content"": { - ""application/json"": { - ""schema"": { - ""$ref"": ""#/components/schemas/pet"" - } - } - } - }, - ""4XX"": { - ""description"": ""unexpected client error"", - ""content"": { - ""text/html"": { - ""schema"": { - ""$ref"": ""#/components/schemas/errorModel"" - } - } - } - }, - ""5XX"": { - ""description"": ""unexpected server error"", - ""content"": { - ""text/html"": { - ""schema"": { - ""$ref"": ""#/components/schemas/errorModel"" - } - } - } - } - } - } - }, - ""/pets/{id}"": { - ""get"": { - ""description"": ""Returns a user based on a single ID, if the user does not have access to the pet"", - ""operationId"": ""findPetById"", - ""parameters"": [ - { - ""name"": ""id"", - ""in"": ""path"", - ""description"": ""ID of pet to fetch"", - ""required"": true, - ""schema"": { - ""type"": ""integer"", - ""format"": ""int64"" - } - } - ], - ""responses"": { - ""200"": { - ""description"": ""pet response"", - ""content"": { - ""application/json"": { - ""schema"": { - ""$ref"": ""#/components/schemas/pet"" - } - }, - ""application/xml"": { - ""schema"": { - ""$ref"": ""#/components/schemas/pet"" - } - } - } - }, - ""4XX"": { - ""description"": ""unexpected client error"", - ""content"": { - ""text/html"": { - ""schema"": { - ""$ref"": ""#/components/schemas/errorModel"" - } - } - } - }, - ""5XX"": { - ""description"": ""unexpected server error"", - ""content"": { - ""text/html"": { - ""schema"": { - ""$ref"": ""#/components/schemas/errorModel"" - } - } - } - } - } - }, - ""delete"": { - ""description"": ""deletes a single pet based on the ID supplied"", - ""operationId"": ""deletePet"", - ""parameters"": [ - { - ""name"": ""id"", - ""in"": ""path"", - ""description"": ""ID of pet to delete"", - ""required"": true, - ""schema"": { - ""type"": ""integer"", - ""format"": ""int64"" - } - } - ], - ""responses"": { - ""204"": { - ""description"": ""pet deleted"" - }, - ""4XX"": { - ""description"": ""unexpected client error"", - ""content"": { - ""text/html"": { - ""schema"": { - ""$ref"": ""#/components/schemas/errorModel"" - } - } - } - }, - ""5XX"": { - ""description"": ""unexpected server error"", - ""content"": { - ""text/html"": { - ""schema"": { - ""$ref"": ""#/components/schemas/errorModel"" - } - } - } - } - } - } - } - }, - ""components"": { - ""schemas"": { - ""pet"": { - ""required"": [ - ""id"", - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""type"": ""integer"", - ""format"": ""int64"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - }, - ""newPet"": { - ""required"": [ - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""type"": ""integer"", - ""format"": ""int64"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - }, - ""errorModel"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""type"": ""integer"", - ""format"": ""int32"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - } - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedDocumentWithReference.SerializeAsV3(writer); @@ -1806,433 +1018,17 @@ public void SerializeAdvancedDocumentWithReferenceAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeAdvancedDocumentAsV2JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeAdvancedDocumentAsV2JsonWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = @"{ - ""swagger"": ""2.0"", - ""info"": { - ""title"": ""Swagger Petstore (Simple)"", - ""description"": ""A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification"", - ""termsOfService"": ""http://helloreverb.com/terms/"", - ""contact"": { - ""name"": ""Swagger API team"", - ""url"": ""http://swagger.io"", - ""email"": ""foo@example.com"" - }, - ""license"": { - ""name"": ""MIT"", - ""url"": ""http://opensource.org/licenses/MIT"" - }, - ""version"": ""1.0.0"" - }, - ""host"": ""petstore.swagger.io"", - ""basePath"": ""/api"", - ""schemes"": [ - ""http"" - ], - ""paths"": { - ""/pets"": { - ""get"": { - ""description"": ""Returns all pets from the system that the user has access to"", - ""operationId"": ""findPets"", - ""produces"": [ - ""application/json"", - ""application/xml"", - ""text/html"" - ], - ""parameters"": [ - { - ""in"": ""query"", - ""name"": ""tags"", - ""description"": ""tags to filter by"", - ""type"": ""array"", - ""items"": { - ""type"": ""string"" - } - }, - { - ""in"": ""query"", - ""name"": ""limit"", - ""description"": ""maximum number of results to return"", - ""type"": ""integer"", - ""format"": ""int32"" - } - ], - ""responses"": { - ""200"": { - ""description"": ""pet response"", - ""schema"": { - ""type"": ""array"", - ""items"": { - ""required"": [ - ""id"", - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""format"": ""int64"", - ""type"": ""integer"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - } - } - }, - ""4XX"": { - ""description"": ""unexpected client error"", - ""schema"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""format"": ""int32"", - ""type"": ""integer"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - }, - ""5XX"": { - ""description"": ""unexpected server error"", - ""schema"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""format"": ""int32"", - ""type"": ""integer"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - } - } - }, - ""post"": { - ""description"": ""Creates a new pet in the store. Duplicates are allowed"", - ""operationId"": ""addPet"", - ""consumes"": [ - ""application/json"" - ], - ""produces"": [ - ""application/json"", - ""text/html"" - ], - ""parameters"": [ - { - ""in"": ""body"", - ""name"": ""body"", - ""description"": ""Pet to add to the store"", - ""required"": true, - ""schema"": { - ""required"": [ - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""format"": ""int64"", - ""type"": ""integer"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - } - } - ], - ""responses"": { - ""200"": { - ""description"": ""pet response"", - ""schema"": { - ""required"": [ - ""id"", - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""format"": ""int64"", - ""type"": ""integer"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - } - }, - ""4XX"": { - ""description"": ""unexpected client error"", - ""schema"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""format"": ""int32"", - ""type"": ""integer"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - }, - ""5XX"": { - ""description"": ""unexpected server error"", - ""schema"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""format"": ""int32"", - ""type"": ""integer"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - } - } - } - }, - ""/pets/{id}"": { - ""get"": { - ""description"": ""Returns a user based on a single ID, if the user does not have access to the pet"", - ""operationId"": ""findPetById"", - ""produces"": [ - ""application/json"", - ""application/xml"", - ""text/html"" - ], - ""parameters"": [ - { - ""in"": ""path"", - ""name"": ""id"", - ""description"": ""ID of pet to fetch"", - ""required"": true, - ""type"": ""integer"", - ""format"": ""int64"" - } - ], - ""responses"": { - ""200"": { - ""description"": ""pet response"", - ""schema"": { - ""required"": [ - ""id"", - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""format"": ""int64"", - ""type"": ""integer"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - } - }, - ""4XX"": { - ""description"": ""unexpected client error"", - ""schema"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""format"": ""int32"", - ""type"": ""integer"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - }, - ""5XX"": { - ""description"": ""unexpected server error"", - ""schema"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""format"": ""int32"", - ""type"": ""integer"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - } - } - }, - ""delete"": { - ""description"": ""deletes a single pet based on the ID supplied"", - ""operationId"": ""deletePet"", - ""produces"": [ - ""text/html"" - ], - ""parameters"": [ - { - ""in"": ""path"", - ""name"": ""id"", - ""description"": ""ID of pet to delete"", - ""required"": true, - ""type"": ""integer"", - ""format"": ""int64"" - } - ], - ""responses"": { - ""204"": { - ""description"": ""pet deleted"" - }, - ""4XX"": { - ""description"": ""unexpected client error"", - ""schema"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""format"": ""int32"", - ""type"": ""integer"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - }, - ""5XX"": { - ""description"": ""unexpected server error"", - ""schema"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""format"": ""int32"", - ""type"": ""integer"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - } - } - } - } - }, - ""definitions"": { - ""pet"": { - ""required"": [ - ""id"", - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""format"": ""int64"", - ""type"": ""integer"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - }, - ""newPet"": { - ""required"": [ - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""format"": ""int64"", - ""type"": ""integer"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - }, - ""errorModel"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""format"": ""int32"", - ""type"": ""integer"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedDocument.SerializeAsV2(writer); @@ -2240,92 +1036,17 @@ public void SerializeAdvancedDocumentAsV2JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeDuplicateExtensionsAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeDuplicateExtensionsAsV3JsonWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = @"{ - ""openapi"": ""3.0.1"", - ""info"": { - ""title"": ""Swagger Petstore (Simple)"", - ""description"": ""A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification"", - ""version"": ""1.0.0"" - }, - ""servers"": [ - { - ""url"": ""http://petstore.swagger.io/api"" - } - ], - ""paths"": { - ""/add/{operand1}/{operand2}"": { - ""get"": { - ""operationId"": ""addByOperand1AndByOperand2"", - ""parameters"": [ - { - ""name"": ""operand1"", - ""in"": ""path"", - ""description"": ""The first operand"", - ""required"": true, - ""schema"": { - ""type"": ""integer"", - ""my-extension"": 4 - }, - ""my-extension"": 4 - }, - { - ""name"": ""operand2"", - ""in"": ""path"", - ""description"": ""The second operand"", - ""required"": true, - ""schema"": { - ""type"": ""integer"", - ""my-extension"": 4 - }, - ""my-extension"": 4 - } - ], - ""responses"": { - ""200"": { - ""description"": ""pet response"", - ""content"": { - ""application/json"": { - ""schema"": { - ""type"": ""array"", - ""items"": { - ""required"": [ - ""id"", - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""type"": ""integer"", - ""format"": ""int64"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - } - } - } - } - } - } - } - } - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act DuplicateExtensions.SerializeAsV3(writer); @@ -2333,85 +1054,17 @@ public void SerializeDuplicateExtensionsAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeDuplicateExtensionsAsV2JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeDuplicateExtensionsAsV2JsonWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = @"{ - ""swagger"": ""2.0"", - ""info"": { - ""title"": ""Swagger Petstore (Simple)"", - ""description"": ""A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification"", - ""version"": ""1.0.0"" - }, - ""host"": ""petstore.swagger.io"", - ""basePath"": ""/api"", - ""schemes"": [ - ""http"" - ], - ""paths"": { - ""/add/{operand1}/{operand2}"": { - ""get"": { - ""operationId"": ""addByOperand1AndByOperand2"", - ""produces"": [ - ""application/json"" - ], - ""parameters"": [ - { - ""in"": ""path"", - ""name"": ""operand1"", - ""description"": ""The first operand"", - ""required"": true, - ""type"": ""integer"", - ""my-extension"": 4 - }, - { - ""in"": ""path"", - ""name"": ""operand2"", - ""description"": ""The second operand"", - ""required"": true, - ""type"": ""integer"", - ""my-extension"": 4 - } - ], - ""responses"": { - ""200"": { - ""description"": ""pet response"", - ""schema"": { - ""type"": ""array"", - ""items"": { - ""required"": [ - ""id"", - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""format"": ""int64"", - ""type"": ""integer"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - } - } - } - } - } - } - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act DuplicateExtensions.SerializeAsV2(writer); @@ -2419,267 +1072,17 @@ public void SerializeDuplicateExtensionsAsV2JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeAdvancedDocumentWithReferenceAsV2JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeAdvancedDocumentWithReferenceAsV2JsonWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""swagger"": ""2.0"", - ""info"": { - ""title"": ""Swagger Petstore (Simple)"", - ""description"": ""A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification"", - ""termsOfService"": ""http://helloreverb.com/terms/"", - ""contact"": { - ""name"": ""Swagger API team"", - ""url"": ""http://swagger.io"", - ""email"": ""foo@example.com"" - }, - ""license"": { - ""name"": ""MIT"", - ""url"": ""http://opensource.org/licenses/MIT"" - }, - ""version"": ""1.0.0"" - }, - ""host"": ""petstore.swagger.io"", - ""basePath"": ""/api"", - ""schemes"": [ - ""http"" - ], - ""paths"": { - ""/pets"": { - ""get"": { - ""description"": ""Returns all pets from the system that the user has access to"", - ""operationId"": ""findPets"", - ""produces"": [ - ""application/json"", - ""application/xml"", - ""text/html"" - ], - ""parameters"": [ - { - ""in"": ""query"", - ""name"": ""tags"", - ""description"": ""tags to filter by"", - ""type"": ""array"", - ""items"": { - ""type"": ""string"" - } - }, - { - ""in"": ""query"", - ""name"": ""limit"", - ""description"": ""maximum number of results to return"", - ""type"": ""integer"", - ""format"": ""int32"" - } - ], - ""responses"": { - ""200"": { - ""description"": ""pet response"", - ""schema"": { - ""type"": ""array"", - ""items"": { - ""$ref"": ""#/definitions/pet"" - } - } - }, - ""4XX"": { - ""description"": ""unexpected client error"", - ""schema"": { - ""$ref"": ""#/definitions/errorModel"" - } - }, - ""5XX"": { - ""description"": ""unexpected server error"", - ""schema"": { - ""$ref"": ""#/definitions/errorModel"" - } - } - } - }, - ""post"": { - ""description"": ""Creates a new pet in the store. Duplicates are allowed"", - ""operationId"": ""addPet"", - ""consumes"": [ - ""application/json"" - ], - ""produces"": [ - ""application/json"", - ""text/html"" - ], - ""parameters"": [ - { - ""in"": ""body"", - ""name"": ""body"", - ""description"": ""Pet to add to the store"", - ""required"": true, - ""schema"": { - ""$ref"": ""#/definitions/newPet"" - } - } - ], - ""responses"": { - ""200"": { - ""description"": ""pet response"", - ""schema"": { - ""$ref"": ""#/definitions/pet"" - } - }, - ""4XX"": { - ""description"": ""unexpected client error"", - ""schema"": { - ""$ref"": ""#/definitions/errorModel"" - } - }, - ""5XX"": { - ""description"": ""unexpected server error"", - ""schema"": { - ""$ref"": ""#/definitions/errorModel"" - } - } - } - } - }, - ""/pets/{id}"": { - ""get"": { - ""description"": ""Returns a user based on a single ID, if the user does not have access to the pet"", - ""operationId"": ""findPetById"", - ""produces"": [ - ""application/json"", - ""application/xml"", - ""text/html"" - ], - ""parameters"": [ - { - ""in"": ""path"", - ""name"": ""id"", - ""description"": ""ID of pet to fetch"", - ""required"": true, - ""type"": ""integer"", - ""format"": ""int64"" - } - ], - ""responses"": { - ""200"": { - ""description"": ""pet response"", - ""schema"": { - ""$ref"": ""#/definitions/pet"" - } - }, - ""4XX"": { - ""description"": ""unexpected client error"", - ""schema"": { - ""$ref"": ""#/definitions/errorModel"" - } - }, - ""5XX"": { - ""description"": ""unexpected server error"", - ""schema"": { - ""$ref"": ""#/definitions/errorModel"" - } - } - } - }, - ""delete"": { - ""description"": ""deletes a single pet based on the ID supplied"", - ""operationId"": ""deletePet"", - ""produces"": [ - ""text/html"" - ], - ""parameters"": [ - { - ""in"": ""path"", - ""name"": ""id"", - ""description"": ""ID of pet to delete"", - ""required"": true, - ""type"": ""integer"", - ""format"": ""int64"" - } - ], - ""responses"": { - ""204"": { - ""description"": ""pet deleted"" - }, - ""4XX"": { - ""description"": ""unexpected client error"", - ""schema"": { - ""$ref"": ""#/definitions/errorModel"" - } - }, - ""5XX"": { - ""description"": ""unexpected server error"", - ""schema"": { - ""$ref"": ""#/definitions/errorModel"" - } - } - } - } - } - }, - ""definitions"": { - ""pet"": { - ""required"": [ - ""id"", - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""format"": ""int64"", - ""type"": ""integer"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - }, - ""newPet"": { - ""required"": [ - ""name"" - ], - ""type"": ""object"", - ""properties"": { - ""id"": { - ""format"": ""int64"", - ""type"": ""integer"" - }, - ""name"": { - ""type"": ""string"" - }, - ""tag"": { - ""type"": ""string"" - } - } - }, - ""errorModel"": { - ""required"": [ - ""code"", - ""message"" - ], - ""type"": ""object"", - ""properties"": { - ""code"": { - ""format"": ""int32"", - ""type"": ""integer"" - }, - ""message"": { - ""type"": ""string"" - } - } - } - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedDocumentWithReference.SerializeAsV2(writer); @@ -2687,9 +1090,7 @@ public void SerializeAdvancedDocumentWithReferenceAsV2JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } [Fact] From 86b4cee30570ac04aca3f395291567a7d921dc4d Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 31 Oct 2021 14:50:40 +0100 Subject: [PATCH 086/288] Ensure OpenApiExampleTests cover terse output --- ...orks_produceTerseOutput=False.verified.txt | 28 +++++ ...Works_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 26 +++++ ...Works_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 3 + ...Works_produceTerseOutput=True.verified.txt | 1 + .../Models/OpenApiExampleTests.cs | 100 ++++-------------- 7 files changed, 81 insertions(+), 79 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorks_produceTerseOutput=True.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..44d48dd73 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,28 @@ +{ + "value": { + "versions": [ + { + "status": "Status1", + "id": "v1", + "links": [ + { + "href": "http://example.com/1", + "rel": "sampleRel1", + "bytes": "AQID", + "binary": "Ñ😻😑♮Í☛oƞ♑😲☇éNjžŁ♻😟¥a´Ī♃ƠąøƩ" + } + ] + }, + { + "status": "Status2", + "id": "v2", + "links": [ + { + "href": "http://example.com/2", + "rel": "sampleRel2" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..c42b2a5ac --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeAdvancedExampleAsV3JsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"value":{"versions":[{"status":"Status1","id":"v1","links":[{"href":"http://example.com/1","rel":"sampleRel1","bytes":"AQID","binary":"Ñ😻😑♮Í☛oƞ♑😲☇éNjžŁ♻😟¥a´Ī♃ƠąøƩ"}]},{"status":"Status2","id":"v2","links":[{"href":"http://example.com/2","rel":"sampleRel2"}]}]}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..45f085f73 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,26 @@ +{ + "value": { + "versions": [ + { + "status": "Status1", + "id": "v1", + "links": [ + { + "href": "http://example.com/1", + "rel": "sampleRel1" + } + ] + }, + { + "status": "Status2", + "id": "v2", + "links": [ + { + "href": "http://example.com/2", + "rel": "sampleRel2" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..b503d318e --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"value":{"versions":[{"status":"Status1","id":"v1","links":[{"href":"http://example.com/1","rel":"sampleRel1"}]},{"status":"Status2","id":"v2","links":[{"href":"http://example.com/2","rel":"sampleRel2"}]}]}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..74aae72ef --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,3 @@ +{ + "$ref": "#/components/examples/example1" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..12898c9c5 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.SerializeReferencedExampleAsV3JsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"$ref":"#/components/examples/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs index 896b96215..6108c3c26 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs @@ -4,16 +4,18 @@ using System.Globalization; using System.IO; using System.Text; -using FluentAssertions; +using System.Threading.Tasks; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; +using VerifyXunit; using Xunit; using Xunit.Abstractions; namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] + [UsesVerify] public class OpenApiExampleTests { public static OpenApiExample AdvancedExample = new OpenApiExample @@ -104,41 +106,14 @@ public OpenApiExampleTests(ITestOutputHelper output) _output = output; } - [Fact] - public void SerializeAdvancedExampleAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeAdvancedExampleAsV3JsonWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""value"": { - ""versions"": [ - { - ""status"": ""Status1"", - ""id"": ""v1"", - ""links"": [ - { - ""href"": ""http://example.com/1"", - ""rel"": ""sampleRel1"", - ""bytes"": ""AQID"", - ""binary"": ""Ñ😻😑♮Í☛oƞ♑😲☇éNjžŁ♻😟¥a´Ī♃ƠąøƩ"" - } - ] - }, - { - ""status"": ""Status2"", - ""id"": ""v2"", - ""links"": [ - { - ""href"": ""http://example.com/2"", - ""rel"": ""sampleRel2"" - } - ] - } - ] - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedExample.SerializeAsV3(writer); @@ -146,21 +121,17 @@ public void SerializeAdvancedExampleAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedExampleAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedExampleAsV3JsonWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""$ref"": ""#/components/examples/example1"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedExample.SerializeAsV3(writer); @@ -168,44 +139,17 @@ public void SerializeReferencedExampleAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedExampleAsV3JsonWithoutReferenceWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedExampleAsV3JsonWithoutReferenceWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""value"": { - ""versions"": [ - { - ""status"": ""Status1"", - ""id"": ""v1"", - ""links"": [ - { - ""href"": ""http://example.com/1"", - ""rel"": ""sampleRel1"" - } - ] - }, - { - ""status"": ""Status2"", - ""id"": ""v2"", - ""links"": [ - { - ""href"": ""http://example.com/2"", - ""rel"": ""sampleRel2"" - } - ] - } - ] - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedExample.SerializeAsV3WithoutReference(writer); @@ -213,9 +157,7 @@ public void SerializeReferencedExampleAsV3JsonWithoutReferenceWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } } } From 632d6556a8903c7fbd3ca8e469aa0ffdb75b2d01 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 31 Oct 2021 14:52:00 +0100 Subject: [PATCH 087/288] Ensure OpenApiHeaderTests cover terse output --- ...orks_produceTerseOutput=False.verified.txt | 5 + ...Works_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 7 ++ ...Works_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 5 + ...Works_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 3 + ...Works_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 7 ++ ...Works_produceTerseOutput=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 3 + ...Works_produceTerseOutput=True.verified.txt | 1 + .../Models/OpenApiHeaderTests.cs | 112 ++++++------------ 13 files changed, 75 insertions(+), 73 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorks_produceTerseOutput=True.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5b0eb86be --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,5 @@ +{ + "description": "sampleHeader", + "type": "integer", + "format": "int32" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..8feb99289 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV2JsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"description":"sampleHeader","type":"integer","format":"int32"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..8234610e0 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,7 @@ +{ + "description": "sampleHeader", + "schema": { + "type": "integer", + "format": "int32" + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..37ebf2515 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeAdvancedHeaderAsV3JsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"description":"sampleHeader","schema":{"type":"integer","format":"int32"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5b0eb86be --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,5 @@ +{ + "description": "sampleHeader", + "type": "integer", + "format": "int32" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..8feb99289 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"description":"sampleHeader","type":"integer","format":"int32"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..9791d3c4a --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,3 @@ +{ + "$ref": "#/headers/example1" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..58060ead9 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV2JsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"$ref":"#/headers/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..8234610e0 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,7 @@ +{ + "description": "sampleHeader", + "schema": { + "type": "integer", + "format": "int32" + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..37ebf2515 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"description":"sampleHeader","schema":{"type":"integer","format":"int32"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..18045b9d2 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,3 @@ +{ + "$ref": "#/components/headers/example1" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..8c4124b8d --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.SerializeReferencedHeaderAsV3JsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"$ref":"#/components/headers/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs index 5c2671e54..846d470ba 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs @@ -3,15 +3,17 @@ using System.Globalization; using System.IO; -using FluentAssertions; +using System.Threading.Tasks; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; +using VerifyXunit; using Xunit; using Xunit.Abstractions; namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] + [UsesVerify] public class OpenApiHeaderTests { public static OpenApiHeader AdvancedHeader = new OpenApiHeader @@ -46,20 +48,14 @@ public OpenApiHeaderTests(ITestOutputHelper output) _output = output; } - [Fact] - public void SerializeAdvancedHeaderAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeAdvancedHeaderAsV3JsonWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""description"": ""sampleHeader"", - ""schema"": { - ""type"": ""integer"", - ""format"": ""int32"" - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedHeader.SerializeAsV3(writer); @@ -67,21 +63,17 @@ public void SerializeAdvancedHeaderAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedHeaderAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedHeaderAsV3JsonWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""$ref"": ""#/components/headers/example1"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedHeader.SerializeAsV3(writer); @@ -89,25 +81,17 @@ public void SerializeReferencedHeaderAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""description"": ""sampleHeader"", - ""schema"": { - ""type"": ""integer"", - ""format"": ""int32"" - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedHeader.SerializeAsV3WithoutReference(writer); @@ -115,23 +99,17 @@ public void SerializeReferencedHeaderAsV3JsonWithoutReferenceWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeAdvancedHeaderAsV2JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeAdvancedHeaderAsV2JsonWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""description"": ""sampleHeader"", - ""type"": ""integer"", - ""format"": ""int32"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedHeader.SerializeAsV2(writer); @@ -139,21 +117,17 @@ public void SerializeAdvancedHeaderAsV2JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedHeaderAsV2JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedHeaderAsV2JsonWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""$ref"": ""#/headers/example1"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedHeader.SerializeAsV2(writer); @@ -161,23 +135,17 @@ public void SerializeReferencedHeaderAsV2JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""description"": ""sampleHeader"", - ""type"": ""integer"", - ""format"": ""int32"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedHeader.SerializeAsV2WithoutReference(writer); @@ -185,9 +153,7 @@ public void SerializeReferencedHeaderAsV2JsonWithoutReferenceWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } } } From 83fc148e38dae3803ba05216cb8d5317c8e898bc Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 31 Oct 2021 15:30:43 +0100 Subject: [PATCH 088/288] Ensure OpenApiLinkTests cover terse output --- ...sync_produceTerseOutput=False.verified.txt | 13 ++++ ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 13 ++++ ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 3 + ...Async_produceTerseOutput=True.verified.txt | 1 + .../Models/OpenApiLinkTests.cs | 72 ++++++------------- 7 files changed, 53 insertions(+), 51 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeAdvancedLinkAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeAdvancedLinkAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeAdvancedLinkAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeAdvancedLinkAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..2629e0b1c --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeAdvancedLinkAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,13 @@ +{ + "operationId": "operationId1", + "parameters": { + "parameter1": "$request.path.id" + }, + "requestBody": { + "property1": true + }, + "description": "description1", + "server": { + "description": "serverDescription1" + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeAdvancedLinkAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeAdvancedLinkAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..c9c1701b5 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeAdvancedLinkAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"operationId":"operationId1","parameters":{"parameter1":"$request.path.id"},"requestBody":{"property1":true},"description":"description1","server":{"description":"serverDescription1"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..2629e0b1c --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,13 @@ +{ + "operationId": "operationId1", + "parameters": { + "parameter1": "$request.path.id" + }, + "requestBody": { + "property1": true + }, + "description": "description1", + "server": { + "description": "serverDescription1" + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..c9c1701b5 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"operationId":"operationId1","parameters":{"parameter1":"$request.path.id"},"requestBody":{"property1":true},"description":"description1","server":{"description":"serverDescription1"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..26fe6229d --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,3 @@ +{ + "$ref": "#/components/links/example1" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..2200957a3 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.SerializeReferencedLinkAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"$ref":"#/components/links/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs index ffcaa8804..4e439a2a8 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiLinkTests.cs @@ -3,17 +3,19 @@ using System.Globalization; using System.IO; -using FluentAssertions; +using System.Threading.Tasks; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Expressions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; +using VerifyXunit; using Xunit; using Xunit.Abstractions; namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] + [UsesVerify] public class OpenApiLinkTests { public static OpenApiLink AdvancedLink = new OpenApiLink @@ -76,26 +78,14 @@ public OpenApiLinkTests(ITestOutputHelper output) _output = output; } - [Fact] - public void SerializeAdvancedLinkAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeAdvancedLinkAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""operationId"": ""operationId1"", - ""parameters"": { - ""parameter1"": ""$request.path.id"" - }, - ""requestBody"": { - ""property1"": true - }, - ""description"": ""description1"", - ""server"": { - ""description"": ""serverDescription1"" - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedLink.SerializeAsV3(writer); @@ -103,21 +93,17 @@ public void SerializeAdvancedLinkAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedLinkAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedLinkAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""$ref"": ""#/components/links/example1"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedLink.SerializeAsV3(writer); @@ -125,31 +111,17 @@ public void SerializeReferencedLinkAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedLinkAsV3JsonWithoutReferenceWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedLinkAsV3JsonWithoutReferenceWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""operationId"": ""operationId1"", - ""parameters"": { - ""parameter1"": ""$request.path.id"" - }, - ""requestBody"": { - ""property1"": true - }, - ""description"": ""description1"", - ""server"": { - ""description"": ""serverDescription1"" - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedLink.SerializeAsV3WithoutReference(writer); @@ -157,9 +129,7 @@ public void SerializeReferencedLinkAsV3JsonWithoutReferenceWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } } } From 8395a47820727638e99d01596d123c8edd4b78b2 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 31 Oct 2021 14:52:37 +0100 Subject: [PATCH 089/288] Ensure OpenApiWriterAnyExtensionsTests cover terse output --- ...orks_produceTerseOutput=False.verified.txt | 11 + ...Works_produceTerseOutput=True.verified.txt | 1 + ...iArrayAsJsonWorks_terse=False.verified.txt | 11 + ...piArrayAsJsonWorks_terse=True.verified.txt | 1 + ...orks_produceTerseOutput=False.verified.txt | 7 + ...Works_produceTerseOutput=True.verified.txt | 1 + .../OpenApiWriterAnyExtensionsTests.cs | 201 ++++++++++++------ 7 files changed, 165 insertions(+), 68 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_terse=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_terse=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorks_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorks_produceTerseOutput=True.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..1a91b1047 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,11 @@ +[ + false, + { + "stringProp": "stringValue1", + "objProp": { }, + "arrayProp": [ + false + ] + }, + "stringValue2" +] \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..75f913cf2 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +[false,{"stringProp":"stringValue1","objProp":{},"arrayProp":[false]},"stringValue2"] \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_terse=False.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_terse=False.verified.txt new file mode 100644 index 000000000..1a91b1047 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_terse=False.verified.txt @@ -0,0 +1,11 @@ +[ + false, + { + "stringProp": "stringValue1", + "objProp": { }, + "arrayProp": [ + false + ] + }, + "stringValue2" +] \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_terse=True.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_terse=True.verified.txt new file mode 100644 index 000000000..75f913cf2 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiArrayAsJsonWorks_terse=True.verified.txt @@ -0,0 +1 @@ +[false,{"stringProp":"stringValue1","objProp":{},"arrayProp":[false]},"stringValue2"] \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorks_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorks_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..1b6b4d799 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorks_produceTerseOutput=False.verified.txt @@ -0,0 +1,7 @@ +{ + "stringProp": "stringValue1", + "objProp": { }, + "arrayProp": [ + false + ] +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorks_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorks_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..c2132cb78 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.WriteOpenApiObjectAsJsonWorks_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"stringProp":"stringValue1","objProp":{},"arrayProp":[false]} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs index 2ecf93f42..c9ef96efd 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterAnyExtensionsTests.cs @@ -2,124 +2,210 @@ // Licensed under the MIT license. using System; +using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Linq; +using System.Threading.Tasks; using FluentAssertions; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Writers; +using VerifyXunit; using Xunit; namespace Microsoft.OpenApi.Tests.Writers { [Collection("DefaultSettings")] + [UsesVerify] public class OpenApiWriterAnyExtensionsTests { - [Fact] - public void WriteOpenApiNullAsJsonWorks() + static bool[] shouldProduceTerseOutputValues = new[] { true, false }; + + [Theory] + [InlineData(true)] + [InlineData(false)] + public void WriteOpenApiNullAsJsonWorks(bool produceTerseOutput) { // Arrange var nullValue = new OpenApiNull(); - var json = WriteAsJson(nullValue); + var json = WriteAsJson(nullValue, produceTerseOutput); // Assert json.Should().Be("null"); } + public static IEnumerable IntInputs + { + get + { + return + from input in new int[] { + int.MinValue, + 42, + int.MaxValue, + } + from shouldBeTerse in shouldProduceTerseOutputValues + select new object[] { input, shouldBeTerse }; + } + } + [Theory] - [InlineData(int.MinValue)] - [InlineData(42)] - [InlineData(int.MaxValue)] - public void WriteOpenApiIntegerAsJsonWorks(int input) + [MemberData(nameof(IntInputs))] + public void WriteOpenApiIntegerAsJsonWorks(int input, bool produceTerseOutput) { // Arrange var intValue = new OpenApiInteger(input); - var json = WriteAsJson(intValue); + var json = WriteAsJson(intValue, produceTerseOutput); // Assert json.Should().Be(input.ToString()); } + public static IEnumerable LongInputs + { + get + { + return + from input in new long[] { + long.MinValue, + 42, + long.MaxValue, + } + from shouldBeTerse in shouldProduceTerseOutputValues + select new object[] { input, shouldBeTerse }; + } + } + [Theory] - [InlineData(long.MinValue)] - [InlineData(42)] - [InlineData(long.MaxValue)] - public void WriteOpenApiLongAsJsonWorks(long input) + [MemberData(nameof(LongInputs))] + public void WriteOpenApiLongAsJsonWorks(long input, bool produceTerseOutput) { // Arrange var longValue = new OpenApiLong(input); - var json = WriteAsJson(longValue); + var json = WriteAsJson(longValue, produceTerseOutput); // Assert json.Should().Be(input.ToString()); } + public static IEnumerable FloatInputs + { + get + { + return + from input in new float[] { + float.MinValue, + 42.42f, + float.MaxValue, + } + from shouldBeTerse in shouldProduceTerseOutputValues + select new object[] { input, shouldBeTerse }; + } + } + [Theory] - [InlineData(float.MinValue)] - [InlineData(42.42)] - [InlineData(float.MaxValue)] - public void WriteOpenApiFloatAsJsonWorks(float input) + [MemberData(nameof(FloatInputs))] + public void WriteOpenApiFloatAsJsonWorks(float input, bool produceTerseOutput) { // Arrange var floatValue = new OpenApiFloat(input); - var json = WriteAsJson(floatValue); + var json = WriteAsJson(floatValue, produceTerseOutput); // Assert json.Should().Be(input.ToString()); } + public static IEnumerable DoubleInputs + { + get + { + return + from input in new double[] { + double.MinValue, + 42.42d, + double.MaxValue, + } + from shouldBeTerse in shouldProduceTerseOutputValues + select new object[] { input, shouldBeTerse }; + } + } + [Theory] - [InlineData(double.MinValue)] - [InlineData(42.42)] - [InlineData(double.MaxValue)] - public void WriteOpenApiDoubleAsJsonWorks(double input) + [MemberData(nameof(DoubleInputs))] + public void WriteOpenApiDoubleAsJsonWorks(double input, bool produceTerseOutput) { // Arrange var doubleValue = new OpenApiDouble(input); - var json = WriteAsJson(doubleValue); + var json = WriteAsJson(doubleValue, produceTerseOutput); // Assert json.Should().Be(input.ToString()); } + public static IEnumerable StringifiedDateTimes + { + get + { + return + from input in new [] { + "2017-1-2", + "1999-01-02T12:10:22", + "1999-01-03", + "10:30:12" + } + from shouldBeTerse in shouldProduceTerseOutputValues + select new object[] { input, shouldBeTerse }; + } + } + [Theory] - [InlineData("2017-1-2")] - [InlineData("1999-01-02T12:10:22")] - [InlineData("1999-01-03")] - [InlineData("10:30:12")] - public void WriteOpenApiDateTimeAsJsonWorks(string inputString) + [MemberData(nameof(StringifiedDateTimes))] + public void WriteOpenApiDateTimeAsJsonWorks(string inputString, bool produceTerseOutput) { // Arrange var input = DateTimeOffset.Parse(inputString, CultureInfo.InvariantCulture); var dateTimeValue = new OpenApiDateTime(input); - var json = WriteAsJson(dateTimeValue); + var json = WriteAsJson(dateTimeValue, produceTerseOutput); var expectedJson = "\"" + input.ToString("o") + "\""; // Assert json.Should().Be(expectedJson); } + public static IEnumerable BooleanInputs + { + get + { + return + from input in new [] { true, false } + from shouldBeTerse in shouldProduceTerseOutputValues + select new object[] { input, shouldBeTerse }; + } + } + [Theory] - [InlineData(true)] - [InlineData(false)] - public void WriteOpenApiBooleanAsJsonWorks(bool input) + [MemberData(nameof(BooleanInputs))] + public void WriteOpenApiBooleanAsJsonWorks(bool input, bool produceTerseOutput) { // Arrange var boolValue = new OpenApiBoolean(input); - var json = WriteAsJson(boolValue); + var json = WriteAsJson(boolValue, produceTerseOutput); // Assert json.Should().Be(input.ToString().ToLower()); } - [Fact] - public void WriteOpenApiObjectAsJsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task WriteOpenApiObjectAsJsonWorks(bool produceTerseOutput) { // Arrange var openApiObject = new OpenApiObject @@ -135,24 +221,16 @@ public void WriteOpenApiObjectAsJsonWorks() } }; - var actualJson = WriteAsJson(openApiObject); + var actualJson = WriteAsJson(openApiObject, produceTerseOutput); // Assert - - var expectedJson = @"{ - ""stringProp"": ""stringValue1"", - ""objProp"": { }, - ""arrayProp"": [ - false - ] -}"; - expectedJson = expectedJson.MakeLineBreaksEnvironmentNeutral(); - - actualJson.Should().Be(expectedJson); + await Verifier.Verify(actualJson).UseParameters(produceTerseOutput); } - [Fact] - public void WriteOpenApiArrayAsJsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task WriteOpenApiArrayAsJsonWorks(bool produceTerseOutput) { // Arrange var openApiObject = new OpenApiObject @@ -175,32 +253,19 @@ public void WriteOpenApiArrayAsJsonWorks() new OpenApiString("stringValue2") }; - var actualJson = WriteAsJson(array); + var actualJson = WriteAsJson(array, produceTerseOutput); // Assert - - var expectedJson = @"[ - false, - { - ""stringProp"": ""stringValue1"", - ""objProp"": { }, - ""arrayProp"": [ - false - ] - }, - ""stringValue2"" -]"; - - expectedJson = expectedJson.MakeLineBreaksEnvironmentNeutral(); - - actualJson.Should().Be(expectedJson); + await Verifier.Verify(actualJson).UseParameters(produceTerseOutput); } - private static string WriteAsJson(IOpenApiAny any) + private static string WriteAsJson(IOpenApiAny any, bool produceTerseOutput = false) { // Arrange (continued) var stream = new MemoryStream(); - IOpenApiWriter writer = new OpenApiJsonWriter(new StreamWriter(stream)); + IOpenApiWriter writer = new OpenApiJsonWriter( + new StreamWriter(stream), + new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); writer.WriteAny(any); writer.Flush(); From b60ca9291aacd5ad77bd42eaf3dc6ac01e7b62ec Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 31 Oct 2021 14:53:57 +0100 Subject: [PATCH 090/288] Ensure OpenApiWriterSpecialCharacterTests cover terse output --- .../OpenApiWriterSpecialCharacterTests.cs | 41 +++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs index 78a2c6678..a81e9fc85 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiWriterSpecialCharacterTests.cs @@ -1,8 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Linq; using FluentAssertions; using Microsoft.OpenApi.Writers; using Xunit; @@ -20,20 +22,35 @@ public OpenApiWriterSpecialCharacterTests(ITestOutputHelper output) _output = output; } + static bool[] shouldProduceTerseOutputValues = new[] { true, false }; + + public static IEnumerable StringWithSpecialCharacters + { + get + { + return + from inputExpected in new[] { + new[]{ "Test\bTest", "\"Test\\bTest\"" }, + new[]{ "Test\fTest", "\"Test\\fTest\""}, + new[]{ "Test\nTest", "\"Test\\nTest\""}, + new[]{ "Test\rTest", "\"Test\\rTest\""}, + new[]{ "Test\tTest", "\"Test\\tTest\""}, + new[]{ "Test\\Test", "\"Test\\\\Test\""}, + new[]{ "Test\"Test", "\"Test\\\"Test\""}, + new[]{ "StringsWith\"Quotes\"", "\"StringsWith\\\"Quotes\\\"\""}, + } + from shouldBeTerse in shouldProduceTerseOutputValues + select new object[] { inputExpected[0], inputExpected[1], shouldBeTerse }; + } + } + [Theory] - [InlineData("Test\bTest", "\"Test\\bTest\"")] - [InlineData("Test\fTest", "\"Test\\fTest\"")] - [InlineData("Test\nTest", "\"Test\\nTest\"")] - [InlineData("Test\rTest", "\"Test\\rTest\"")] - [InlineData("Test\tTest", "\"Test\\tTest\"")] - [InlineData("Test\\Test", "\"Test\\\\Test\"")] - [InlineData("Test\"Test", "\"Test\\\"Test\"")] - [InlineData("StringsWith\"Quotes\"", "\"StringsWith\\\"Quotes\\\"\"")] - public void WriteStringWithSpecialCharactersAsJsonWorks(string input, string expected) + [MemberData(nameof(StringWithSpecialCharacters))] + public void WriteStringWithSpecialCharactersAsJsonWorks(string input, string expected, bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act writer.WriteValue(input); @@ -75,7 +92,7 @@ public void WriteStringWithSpecialCharactersAsYamlWorks(string input, string exp // Assert actual.Should().Be(expected); } - + [Theory] [InlineData("multiline\r\nstring", "test: |-\n multiline\n string")] [InlineData("ends with\r\nline break\r\n", "test: |\n ends with\n line break")] @@ -103,7 +120,7 @@ public void WriteStringWithNewlineCharactersInObjectAsYamlWorks(string input, st // Assert actual.Should().Be(expected); } - + [Theory] [InlineData("multiline\r\nstring", "- |-\n multiline\n string")] [InlineData("ends with\r\nline break\r\n", "- |\n ends with\n line break")] From 14478e3ab514dbcef7245b2cdb57bb31ce5325ff Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 31 Oct 2021 15:11:53 +0100 Subject: [PATCH 091/288] Ensure OpenApiParameterTests cover terse output --- ...sync_produceTerseOutput=False.verified.txt | 16 ++ ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 15 ++ ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 7 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 7 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 4 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 3 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 4 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 3 + ...Async_produceTerseOutput=True.verified.txt | 1 + .../Models/OpenApiParameterTests.cs | 166 ++++++------------ 17 files changed, 118 insertions(+), 115 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeFalseWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeFalseWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeTrueWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeTrueWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeFalseWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeFalseWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..1c8e22a01 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeFalseWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,16 @@ +{ + "name": "name1", + "in": "query", + "description": "description1", + "style": "form", + "explode": false, + "schema": { + "type": "array", + "items": { + "enum": [ + "value1", + "value2" + ] + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeFalseWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeFalseWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..73c77d79f --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeFalseWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"name":"name1","in":"query","description":"description1","style":"form","explode":false,"schema":{"type":"array","items":{"enum":["value1","value2"]}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeTrueWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeTrueWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..651da1cce --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeTrueWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,15 @@ +{ + "name": "name1", + "in": "query", + "description": "description1", + "style": "form", + "schema": { + "type": "array", + "items": { + "enum": [ + "value1", + "value2" + ] + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeTrueWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeTrueWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..579671130 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithFormStyleAndExplodeTrueWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"name":"name1","in":"query","description":"description1","style":"form","schema":{"type":"array","items":{"enum":["value1","value2"]}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..0542c58ce --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,7 @@ +{ + "in": "header", + "name": "name1", + "description": "description1", + "required": true, + "type": "string" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..b80b263d3 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"in":"header","name":"name1","description":"description1","required":true,"type":"string"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..0542c58ce --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,7 @@ +{ + "in": "header", + "name": "name1", + "description": "description1", + "required": true, + "type": "string" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..b80b263d3 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"in":"header","name":"name1","description":"description1","required":true,"type":"string"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..4127038e5 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,4 @@ +{ + "in": "path", + "name": "name1" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..8677f0fad --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"in":"path","name":"name1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..a9154d617 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,3 @@ +{ + "$ref": "#/parameters/example1" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..712d7ee78 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"$ref":"#/parameters/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..5275532e8 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,4 @@ +{ + "name": "name1", + "in": "path" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..ec654beb0 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"name":"name1","in":"path"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..654239535 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,3 @@ +{ + "$ref": "#/components/parameters/example1" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..3d61cb3f8 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.SerializeReferencedParameterAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"$ref":"#/components/parameters/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs index b630f3126..5dffea57c 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiParameterTests.cs @@ -4,17 +4,20 @@ using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Threading.Tasks; using FluentAssertions; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; +using VerifyXunit; using Xunit; using Xunit.Abstractions; namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] + [UsesVerify] public class OpenApiParameterTests { public static OpenApiParameter BasicParameter = new OpenApiParameter @@ -231,16 +234,14 @@ public void SerializeAdvancedParameterAsV3JsonWorks() actual.Should().Be(expected); } - [Fact] - public void SerializeReferencedParameterAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedParameterAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""$ref"": ""#/components/parameters/example1"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedParameter.SerializeAsV3(writer); @@ -248,22 +249,17 @@ public void SerializeReferencedParameterAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedParameterAsV3JsonWithoutReferenceWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedParameterAsV3JsonWithoutReferenceWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""name"": ""name1"", - ""in"": ""path"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedParameter.SerializeAsV3WithoutReference(writer); @@ -271,21 +267,17 @@ public void SerializeReferencedParameterAsV3JsonWithoutReferenceWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedParameterAsV2JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedParameterAsV2JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""$ref"": ""#/parameters/example1"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedParameter.SerializeAsV2(writer); @@ -293,22 +285,17 @@ public void SerializeReferencedParameterAsV2JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedParameterAsV2JsonWithoutReferenceWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedParameterAsV2JsonWithoutReferenceWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""in"": ""path"", - ""name"": ""name1"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedParameter.SerializeAsV2WithoutReference(writer); @@ -316,25 +303,17 @@ public void SerializeReferencedParameterAsV2JsonWithoutReferenceWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeParameterWithSchemaReferenceAsV2JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeParameterWithSchemaReferenceAsV2JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""in"": ""header"", - ""name"": ""name1"", - ""description"": ""description1"", - ""required"": true, - ""type"": ""string"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedHeaderParameterWithSchemaReference.SerializeAsV2(writer); @@ -342,25 +321,17 @@ public void SerializeParameterWithSchemaReferenceAsV2JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeParameterWithSchemaTypeObjectAsV2JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeParameterWithSchemaTypeObjectAsV2JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""in"": ""header"", - ""name"": ""name1"", - ""description"": ""description1"", - ""required"": true, - ""type"": ""string"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedHeaderParameterWithSchemaTypeObject.SerializeAsV2(writer); @@ -368,34 +339,17 @@ public void SerializeParameterWithSchemaTypeObjectAsV2JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeParameterWithFormStyleAndExplodeFalseWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeParameterWithFormStyleAndExplodeFalseWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""name"": ""name1"", - ""in"": ""query"", - ""description"": ""description1"", - ""style"": ""form"", - ""explode"": false, - ""schema"": { - ""type"": ""array"", - ""items"": { - ""enum"": [ - ""value1"", - ""value2"" - ] - } - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ParameterWithFormStyleAndExplodeFalse.SerializeAsV3WithoutReference(writer); @@ -403,33 +357,17 @@ public void SerializeParameterWithFormStyleAndExplodeFalseWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeParameterWithFormStyleAndExplodeTrueWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeParameterWithFormStyleAndExplodeTrueWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""name"": ""name1"", - ""in"": ""query"", - ""description"": ""description1"", - ""style"": ""form"", - ""schema"": { - ""type"": ""array"", - ""items"": { - ""enum"": [ - ""value1"", - ""value2"" - ] - } - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ParameterWithFormStyleAndExplodeTrue.SerializeAsV3WithoutReference(writer); @@ -437,9 +375,7 @@ public void SerializeParameterWithFormStyleAndExplodeTrueWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } } } From 821e6b731b13336c040227ad0bf01178461dc8bd Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 31 Oct 2021 15:21:42 +0100 Subject: [PATCH 092/288] Ensure OpenApiRequestBodyTests cover terse output --- ...sync_produceTerseOutput=False.verified.txt | 11 +++ ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 11 +++ ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 3 + ...Async_produceTerseOutput=True.verified.txt | 1 + .../Models/OpenApiRequestBodyTests.cs | 68 ++++++------------- 7 files changed, 49 insertions(+), 47 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeAdvancedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeAdvancedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeAdvancedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeAdvancedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..ccc8d3725 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeAdvancedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,11 @@ +{ + "description": "description", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "required": true +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeAdvancedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeAdvancedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..31161c2f5 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeAdvancedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"description":"description","content":{"application/json":{"schema":{"type":"string"}}},"required":true} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..ccc8d3725 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,11 @@ +{ + "description": "description", + "content": { + "application/json": { + "schema": { + "type": "string" + } + } + }, + "required": true +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..31161c2f5 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"description":"description","content":{"application/json":{"schema":{"type":"string"}}},"required":true} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..ca9bb966e --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,3 @@ +{ + "$ref": "#/components/requestBodies/example1" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..443812023 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.SerializeReferencedRequestBodyAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"$ref":"#/components/requestBodies/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs index b225417fc..d8bdacae4 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiRequestBodyTests.cs @@ -3,15 +3,17 @@ using System.Globalization; using System.IO; -using FluentAssertions; +using System.Threading.Tasks; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; +using VerifyXunit; using Xunit; using Xunit.Abstractions; namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] + [UsesVerify] public class OpenApiRequestBodyTests { public static OpenApiRequestBody AdvancedRequestBody = new OpenApiRequestBody @@ -58,24 +60,14 @@ public OpenApiRequestBodyTests(ITestOutputHelper output) _output = output; } - [Fact] - public void SerializeAdvancedRequestBodyAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeAdvancedRequestBodyAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""description"": ""description"", - ""content"": { - ""application/json"": { - ""schema"": { - ""type"": ""string"" - } - } - }, - ""required"": true -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedRequestBody.SerializeAsV3(writer); @@ -83,21 +75,17 @@ public void SerializeAdvancedRequestBodyAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedRequestBodyAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedRequestBodyAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""$ref"": ""#/components/requestBodies/example1"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedRequestBody.SerializeAsV3(writer); @@ -105,29 +93,17 @@ public void SerializeReferencedRequestBodyAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""description"": ""description"", - ""content"": { - ""application/json"": { - ""schema"": { - ""type"": ""string"" - } - } - }, - ""required"": true -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedRequestBody.SerializeAsV3WithoutReference(writer); @@ -135,9 +111,7 @@ public void SerializeReferencedRequestBodyAsV3JsonWithoutReferenceWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } } } From 193098e080f41b3fe881164280eb7863d0bc5837 Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 31 Oct 2021 15:28:48 +0100 Subject: [PATCH 093/288] Ensure OpenApiResponseTests cover terse output --- ...sync_produceTerseOutput=False.verified.txt | 19 ++++ ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 3 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 27 +++++ ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 3 + ...Async_produceTerseOutput=True.verified.txt | 1 + .../Models/OpenApiResponseTests.cs | 107 +++++------------- 9 files changed, 83 insertions(+), 80 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..af5ce3ea5 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,19 @@ +{ + "description": "A complex object array response", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/customType" + } + }, + "headers": { + "X-Rate-Limit-Limit": { + "description": "The number of allowed requests in the current period", + "type": "integer" + }, + "X-Rate-Limit-Reset": { + "description": "The number of seconds left in the current period", + "type": "integer" + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..f9a3f9d5f --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"description":"A complex object array response","schema":{"type":"array","items":{"$ref":"#/definitions/customType"}},"headers":{"X-Rate-Limit-Limit":{"description":"The number of allowed requests in the current period","type":"integer"},"X-Rate-Limit-Reset":{"description":"The number of seconds left in the current period","type":"integer"}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..ea5aa0d40 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,3 @@ +{ + "$ref": "#/responses/example1" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..b2058cfd8 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"$ref":"#/responses/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..55bad289b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,27 @@ +{ + "description": "A complex object array response", + "headers": { + "X-Rate-Limit-Limit": { + "description": "The number of allowed requests in the current period", + "schema": { + "type": "integer" + } + }, + "X-Rate-Limit-Reset": { + "description": "The number of seconds left in the current period", + "schema": { + "type": "integer" + } + } + }, + "content": { + "text/plain": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/customType" + } + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..612fbe919 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"description":"A complex object array response","headers":{"X-Rate-Limit-Limit":{"description":"The number of allowed requests in the current period","schema":{"type":"integer"}},"X-Rate-Limit-Reset":{"description":"The number of seconds left in the current period","schema":{"type":"integer"}}},"content":{"text/plain":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/customType"}}}}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..115ec60a6 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,3 @@ +{ + "$ref": "#/components/responses/example1" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..e65264a36 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.SerializeReferencedResponseAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"$ref":"#/components/responses/example1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs index 9b86a6d51..a5555ddd9 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiResponseTests.cs @@ -4,18 +4,21 @@ using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Threading.Tasks; using FluentAssertions; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; +using VerifyXunit; using Xunit; using Xunit.Abstractions; namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] + [UsesVerify] public class OpenApiResponseTests { public static OpenApiResponse BasicResponse = new OpenApiResponse(); @@ -279,16 +282,14 @@ public void SerializeAdvancedResponseAsV2YamlWorks() actual.Should().Be(expected); } - [Fact] - public void SerializeReferencedResponseAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedResponseAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""$ref"": ""#/components/responses/example1"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedResponse.SerializeAsV3(writer); @@ -296,45 +297,17 @@ public void SerializeReferencedResponseAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedResponseAsV3JsonWithoutReferenceWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedResponseAsV3JsonWithoutReferenceWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""description"": ""A complex object array response"", - ""headers"": { - ""X-Rate-Limit-Limit"": { - ""description"": ""The number of allowed requests in the current period"", - ""schema"": { - ""type"": ""integer"" - } - }, - ""X-Rate-Limit-Reset"": { - ""description"": ""The number of seconds left in the current period"", - ""schema"": { - ""type"": ""integer"" - } - } - }, - ""content"": { - ""text/plain"": { - ""schema"": { - ""type"": ""array"", - ""items"": { - ""$ref"": ""#/components/schemas/customType"" - } - } - } - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedResponse.SerializeAsV3WithoutReference(writer); @@ -342,21 +315,17 @@ public void SerializeReferencedResponseAsV3JsonWithoutReferenceWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedResponseAsV2JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedResponseAsV2JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""$ref"": ""#/responses/example1"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedResponse.SerializeAsV2(writer); @@ -364,37 +333,17 @@ public void SerializeReferencedResponseAsV2JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedResponseAsV2JsonWithoutReferenceWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedResponseAsV2JsonWithoutReferenceWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""description"": ""A complex object array response"", - ""schema"": { - ""type"": ""array"", - ""items"": { - ""$ref"": ""#/definitions/customType"" - } - }, - ""headers"": { - ""X-Rate-Limit-Limit"": { - ""description"": ""The number of allowed requests in the current period"", - ""type"": ""integer"" - }, - ""X-Rate-Limit-Reset"": { - ""description"": ""The number of seconds left in the current period"", - ""type"": ""integer"" - } - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedResponse.SerializeAsV2WithoutReference(writer); @@ -402,9 +351,7 @@ public void SerializeReferencedResponseAsV2JsonWithoutReferenceWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } } } From b68a0a1e46c0a9df17cc808b78b8c8fd44675b7d Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 31 Oct 2021 15:43:34 +0100 Subject: [PATCH 094/288] Ensure OpenApiSchemaTests cover terse output --- ...sync_produceTerseOutput=False.verified.txt | 3 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 13 +++ ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 41 ++++++++ ...Async_produceTerseOutput=True.verified.txt | 1 + .../Models/OpenApiSchemaTests.cs | 97 ++++--------------- 7 files changed, 81 insertions(+), 76 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..19773c717 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,3 @@ +{ + "$ref": "#/components/schemas/schemaObject1" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..34a933101 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"$ref":"#/components/schemas/schemaObject1"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..7a3aa9ce8 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,13 @@ +{ + "title": "title1", + "multipleOf": 3, + "maximum": 42, + "minimum": 10, + "exclusiveMinimum": true, + "type": "integer", + "default": 15, + "nullable": true, + "externalDocs": { + "url": "http://example.com/externalDocs" + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..f3407133d --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"title":"title1","multipleOf":3,"maximum":42,"minimum":10,"exclusiveMinimum":true,"type":"integer","default":15,"nullable":true,"externalDocs":{"url":"http://example.com/externalDocs"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..49aece921 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,41 @@ +{ + "title": "title1", + "required": [ + "property1" + ], + "properties": { + "property1": { + "required": [ + "property3" + ], + "properties": { + "property2": { + "type": "integer" + }, + "property3": { + "maxLength": 15, + "type": "string" + } + } + }, + "property4": { + "properties": { + "property5": { + "properties": { + "property6": { + "type": "boolean" + } + } + }, + "property7": { + "minLength": 2, + "type": "string" + } + }, + "readOnly": true + } + }, + "externalDocs": { + "url": "http://example.com/externalDocs" + } +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..4777a425c --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"title":"title1","required":["property1"],"properties":{"property1":{"required":["property3"],"properties":{"property2":{"type":"integer"},"property3":{"maxLength":15,"type":"string"}}},"property4":{"properties":{"property5":{"properties":{"property6":{"type":"boolean"}}},"property7":{"minLength":2,"type":"string"}},"readOnly":true}},"externalDocs":{"url":"http://example.com/externalDocs"}} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index 4f9510132..ae13944e6 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -5,17 +5,20 @@ using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Threading.Tasks; using FluentAssertions; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; +using VerifyXunit; using Xunit; using Xunit.Abstractions; namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] + [UsesVerify] public class OpenApiSchemaTests { public static OpenApiSchema BasicSchema = new OpenApiSchema(); @@ -365,26 +368,15 @@ public void SerializeAdvancedSchemaWithAllOfAsV3JsonWorks() actual.Should().Be(expected); } - [Fact] - public void SerializeReferencedSchemaAsV3WithoutReferenceJsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedSchemaAsV3WithoutReferenceJsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); - var expected = @"{ - ""title"": ""title1"", - ""multipleOf"": 3, - ""maximum"": 42, - ""minimum"": 10, - ""exclusiveMinimum"": true, - ""type"": ""integer"", - ""default"": 15, - ""nullable"": true, - ""externalDocs"": { - ""url"": ""http://example.com/externalDocs"" - } -}"; // Act ReferencedSchema.SerializeAsV3WithoutReference(writer); @@ -392,21 +384,17 @@ public void SerializeReferencedSchemaAsV3WithoutReferenceJsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedSchemaAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedSchemaAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - - var expected = @"{ - ""$ref"": ""#/components/schemas/schemaObject1"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedSchema.SerializeAsV3(writer); @@ -414,58 +402,17 @@ public void SerializeReferencedSchemaAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeSchemaWRequiredPropertiesAsV2JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeSchemaWRequiredPropertiesAsV2JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = @"{ - ""title"": ""title1"", - ""required"": [ - ""property1"" - ], - ""properties"": { - ""property1"": { - ""required"": [ - ""property3"" - ], - ""properties"": { - ""property2"": { - ""type"": ""integer"" - }, - ""property3"": { - ""maxLength"": 15, - ""type"": ""string"" - } - } - }, - ""property4"": { - ""properties"": { - ""property5"": { - ""properties"": { - ""property6"": { - ""type"": ""boolean"" - } - } - }, - ""property7"": { - ""minLength"": 2, - ""type"": ""string"" - } - }, - ""readOnly"": true - } - }, - ""externalDocs"": { - ""url"": ""http://example.com/externalDocs"" - } -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedSchemaWithRequiredPropertiesObject.SerializeAsV2(writer); @@ -473,9 +420,7 @@ public void SerializeSchemaWRequiredPropertiesAsV2JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } } } From 505b735f42ad08dbe4ac0864e62c7f334c4a5dab Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 31 Oct 2021 15:48:45 +0100 Subject: [PATCH 095/288] Ensure OpenApiSecuritySchemeTests cover terse output --- ...sync_produceTerseOutput=False.verified.txt | 5 +++ ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 3 ++ ...Async_produceTerseOutput=True.verified.txt | 1 + .../Models/OpenApiSecuritySchemeTests.cs | 37 ++++++++----------- 5 files changed, 25 insertions(+), 22 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..1de104df5 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,5 @@ +{ + "type": "openIdConnect", + "description": "description1", + "openIdConnectUrl": "https://example.com/openIdConnect" +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..5e7183dc8 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"type":"openIdConnect","description":"description1","openIdConnectUrl":"https://example.com/openIdConnect"} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..e2f0188e6 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,3 @@ +{ + "sampleSecurityScheme": null +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..d74ff6ddf --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.SerializeReferencedSecuritySchemeAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"sampleSecurityScheme":null} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs index 5fb99cb95..b7871f51f 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs @@ -5,16 +5,19 @@ using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Threading.Tasks; using FluentAssertions; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; +using VerifyXunit; using Xunit; using Xunit.Abstractions; namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] + [UsesVerify] public class OpenApiSecuritySchemeTests { public static OpenApiSecurityScheme ApiKeySecurityScheme = new OpenApiSecurityScheme @@ -297,16 +300,14 @@ public void SerializeOpenIdConnectSecuritySchemeAsV3JsonWorks() actual.Should().Be(expected); } - [Fact] - public void SerializeReferencedSecuritySchemeAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedSecuritySchemeAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""sampleSecurityScheme"": null -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act // Add dummy start object, value, and end object to allow SerializeAsV3 to output security scheme @@ -319,23 +320,17 @@ public void SerializeReferencedSecuritySchemeAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""type"": ""openIdConnect"", - ""description"": ""description1"", - ""openIdConnectUrl"": ""https://example.com/openIdConnect"" -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedSecurityScheme.SerializeAsV3WithoutReference(writer); @@ -343,9 +338,7 @@ public void SerializeReferencedSecuritySchemeAsV3JsonWithoutReferenceWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } } } From c932f6f2b4cf313e72e10474ed43e259c21f093a Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 31 Oct 2021 18:09:50 +0100 Subject: [PATCH 096/288] Ensure OpenApiTagTests cover terse output --- ...sync_produceTerseOutput=False.verified.txt | 9 ++ ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 9 ++ ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + ...sync_produceTerseOutput=False.verified.txt | 1 + ...Async_produceTerseOutput=True.verified.txt | 1 + .../Models/OpenApiTagTests.cs | 129 +++++++----------- 17 files changed, 83 insertions(+), 78 deletions(-) create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt create mode 100644 test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..4e4df0f3b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,9 @@ +{ + "name": "pet", + "description": "Pets operations", + "externalDocs": { + "description": "Find more info here", + "url": "https://example.com" + }, + "x-tag-extension": null +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..269fd9e7f --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"name":"pet","description":"Pets operations","externalDocs":{"description":"Find more info here","url":"https://example.com"},"x-tag-extension":null} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..8c38cc78d --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ +"pet" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..8c38cc78d --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +"pet" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..4e4df0f3b --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1,9 @@ +{ + "name": "pet", + "description": "Pets operations", + "externalDocs": { + "description": "Find more info here", + "url": "https://example.com" + }, + "x-tag-extension": null +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..269fd9e7f --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{"name":"pet","description":"Pets operations","externalDocs":{"description":"Find more info here","url":"https://example.com"},"x-tag-extension":null} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..8c38cc78d --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ +"pet" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..8c38cc78d --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeAdvancedTagAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +"pet" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..6f31cf5a2 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ +{ } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..6f31cf5a2 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ +{ } \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..9e26dfeeb --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..8c38cc78d --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV2JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ +"pet" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..8c38cc78d --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV2JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +"pet" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt new file mode 100644 index 000000000..8c38cc78d --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV3JsonWorksAsync_produceTerseOutput=False.verified.txt @@ -0,0 +1 @@ +"pet" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt new file mode 100644 index 000000000..8c38cc78d --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.SerializeReferencedTagAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt @@ -0,0 +1 @@ +"pet" \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs index 4920e165d..7e837bd52 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs @@ -4,16 +4,19 @@ using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Threading.Tasks; using FluentAssertions; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; +using VerifyXunit; using Xunit; namespace Microsoft.OpenApi.Tests.Models { [Collection("DefaultSettings")] + [UsesVerify] public class OpenApiTagTests { public static OpenApiTag BasicTag = new OpenApiTag(); @@ -45,13 +48,14 @@ public class OpenApiTagTests } }; - [Fact] - public void SerializeBasicTagAsV3JsonWithoutReferenceWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeBasicTagAsV3JsonWithoutReferenceWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = "{ }"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act BasicTag.SerializeAsV3WithoutReference(writer); @@ -59,18 +63,17 @@ public void SerializeBasicTagAsV3JsonWithoutReferenceWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeBasicTagAsV2JsonWithoutReferenceWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeBasicTagAsV2JsonWithoutReferenceWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = "{ }"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act BasicTag.SerializeAsV2WithoutReference(writer); @@ -78,9 +81,7 @@ public void SerializeBasicTagAsV2JsonWithoutReferenceWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } [Fact] @@ -120,22 +121,14 @@ public void SerializeBasicTagAsV2YamlWithoutReferenceWorks() actual.Should().Be(expected); } - [Fact] - public void SerializeAdvancedTagAsV3JsonWithoutReferenceWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeAdvancedTagAsV3JsonWithoutReferenceWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""name"": ""pet"", - ""description"": ""Pets operations"", - ""externalDocs"": { - ""description"": ""Find more info here"", - ""url"": ""https://example.com"" - }, - ""x-tag-extension"": null -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedTag.SerializeAsV3WithoutReference(writer); @@ -143,27 +136,17 @@ public void SerializeAdvancedTagAsV3JsonWithoutReferenceWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeAdvancedTagAsV2JsonWithoutReferenceWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeAdvancedTagAsV2JsonWithoutReferenceWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - var expected = - @"{ - ""name"": ""pet"", - ""description"": ""Pets operations"", - ""externalDocs"": { - ""description"": ""Find more info here"", - ""url"": ""https://example.com"" - }, - ""x-tag-extension"": null -}"; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedTag.SerializeAsV2WithoutReference(writer); @@ -171,9 +154,7 @@ public void SerializeAdvancedTagAsV2JsonWithoutReferenceWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } [Fact] @@ -226,14 +207,14 @@ public void SerializeAdvancedTagAsV2YamlWithoutReferenceWorks() actual.Should().Be(expected); } - [Fact] - public void SerializeAdvancedTagAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeAdvancedTagAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - - var expected = @"""pet"""; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedTag.SerializeAsV3(writer); @@ -241,19 +222,17 @@ public void SerializeAdvancedTagAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeAdvancedTagAsV2JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeAdvancedTagAsV2JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - - var expected = @"""pet"""; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act AdvancedTag.SerializeAsV2(writer); @@ -261,9 +240,7 @@ public void SerializeAdvancedTagAsV2JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } [Fact] @@ -306,14 +283,14 @@ public void SerializeAdvancedTagAsV2YamlWorks() actual.Should().Be(expected); } - [Fact] - public void SerializeReferencedTagAsV3JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedTagAsV3JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - - var expected = @"""pet"""; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedTag.SerializeAsV3(writer); @@ -321,19 +298,17 @@ public void SerializeReferencedTagAsV3JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } - [Fact] - public void SerializeReferencedTagAsV2JsonWorks() + [Theory] + [InlineData(true)] + [InlineData(false)] + public async Task SerializeReferencedTagAsV2JsonWorksAsync(bool produceTerseOutput) { // Arrange var outputStringWriter = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputStringWriter); - - var expected = @"""pet"""; + var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act ReferencedTag.SerializeAsV2(writer); @@ -341,9 +316,7 @@ public void SerializeReferencedTagAsV2JsonWorks() var actual = outputStringWriter.GetStringBuilder().ToString(); // Assert - actual = actual.MakeLineBreaksEnvironmentNeutral(); - expected = expected.MakeLineBreaksEnvironmentNeutral(); - actual.Should().Be(expected); + await Verifier.Verify(actual).UseParameters(produceTerseOutput); } [Fact] From b800ae0fd00901a48d61b8eeed8b30d40d1073ba Mon Sep 17 00:00:00 2001 From: nulltoken Date: Sun, 31 Oct 2021 18:58:52 +0100 Subject: [PATCH 097/288] Ensure OpenApiJsonWriterTests cover terse output --- .../Writers/OpenApiJsonWriterTests.cs | 254 ++++++++---------- 1 file changed, 117 insertions(+), 137 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs index 06d95c9ad..44d1be55b 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiJsonWriterTests.cs @@ -6,6 +6,7 @@ using System.Collections.Generic; using System.Globalization; using System.IO; +using System.Linq; using FluentAssertions; using Microsoft.OpenApi.Writers; using Newtonsoft.Json; @@ -24,36 +25,36 @@ public OpenApiJsonWriterTests(ITestOutputHelper output) _output = output; } + static bool[] shouldProduceTerseOutputValues = new[] { true, false }; + public static IEnumerable WriteStringListAsJsonShouldMatchExpectedTestCases() { - yield return new object[] - { - new[] - { - "string1", - "string2", - "string3", - "string4", - "string5", - "string6", - "string7", - "string8" + return + from input in new string[][] { + new[] + { + "string1", + "string2", + "string3", + "string4", + "string5", + "string6", + "string7", + "string8" + }, + new[] {"string1", "string1", "string1", "string1"} } - }; - - yield return new object[] - { - new[] {"string1", "string1", "string1", "string1"} - }; + from shouldBeTerse in shouldProduceTerseOutputValues + select new object[] { input, shouldBeTerse }; } [Theory] [MemberData(nameof(WriteStringListAsJsonShouldMatchExpectedTestCases))] - public void WriteStringListAsJsonShouldMatchExpected(string[] stringValues) + public void WriteStringListAsJsonShouldMatchExpected(string[] stringValues, bool produceTerseOutput) { // Arrange var outputString = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputString); + var writer = new OpenApiJsonWriter(outputString, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act writer.WriteStartArray(); @@ -75,123 +76,112 @@ public void WriteStringListAsJsonShouldMatchExpected(string[] stringValues) public static IEnumerable WriteMapAsJsonShouldMatchExpectedTestCasesSimple() { - // Simple map - yield return new object[] - { - new Dictionary - { - ["property1"] = "value1", - ["property2"] = "value2", - ["property3"] = "value3", - ["property4"] = "value4" - } - }; + return + from input in new IDictionary[] { + // Simple map + new Dictionary + { + ["property1"] = "value1", + ["property2"] = "value2", + ["property3"] = "value3", + ["property4"] = "value4" + }, - // Simple map with duplicate values - yield return new object[] - { - new Dictionary - { - ["property1"] = "value1", - ["property2"] = "value1", - ["property3"] = "value1", - ["property4"] = "value1" + // Simple map with duplicate values + new Dictionary + { + ["property1"] = "value1", + ["property2"] = "value1", + ["property3"] = "value1", + ["property4"] = "value1" + }, } - }; + from shouldBeTerse in shouldProduceTerseOutputValues + select new object[] { input, shouldBeTerse }; } public static IEnumerable WriteMapAsJsonShouldMatchExpectedTestCasesComplex() { - // Empty map and empty list - yield return new object[] - { - new Dictionary - { - ["property1"] = new Dictionary(), - ["property2"] = new List(), - ["property3"] = new List + return + from input in new IDictionary[] { + // Empty map and empty list + new Dictionary { - new Dictionary(), + ["property1"] = new Dictionary(), + ["property2"] = new List(), + ["property3"] = new List + { + new Dictionary(), + }, + ["property4"] = "value4" }, - ["property4"] = "value4" - } - }; - // Number, boolean, and null handling - yield return new object[] - { - new Dictionary - { - ["property1"] = "10.0", - ["property2"] = "10", - ["property3"] = "-5", - ["property4"] = 10.0M, - ["property5"] = 10, - ["property6"] = -5, - ["property7"] = true, - ["property8"] = "true", - ["property9"] = null, - ["property10"] = "null", - ["property11"] = "", - } - }; - - // DateTime - yield return new object[] - { - new Dictionary - { - ["property1"] = new DateTime(1970, 01, 01), - ["property2"] = new DateTimeOffset(new DateTime(1970, 01, 01)), - ["property3"] = new DateTime(2018, 04, 03), - } - }; + // Number, boolean, and null handling + new Dictionary + { + ["property1"] = "10.0", + ["property2"] = "10", + ["property3"] = "-5", + ["property4"] = 10.0M, + ["property5"] = 10, + ["property6"] = -5, + ["property7"] = true, + ["property8"] = "true", + ["property9"] = null, + ["property10"] = "null", + ["property11"] = "", + }, - // Nested map - yield return new object[] - { - new Dictionary - { - ["property1"] = new Dictionary + // DateTime + new Dictionary { - ["innerProperty1"] = "innerValue1" + ["property1"] = new DateTime(1970, 01, 01), + ["property2"] = new DateTimeOffset(new DateTime(1970, 01, 01)), + ["property3"] = new DateTime(2018, 04, 03), }, - ["property2"] = "value2", - ["property3"] = new Dictionary + + // Nested map + new Dictionary { - ["innerProperty3"] = "innerValue3" + ["property1"] = new Dictionary + { + ["innerProperty1"] = "innerValue1" + }, + ["property2"] = "value2", + ["property3"] = new Dictionary + { + ["innerProperty3"] = "innerValue3" + }, + ["property4"] = "value4" }, - ["property4"] = "value4" - } - }; - // Nested map and list - yield return new object[] - { - new Dictionary - { - ["property1"] = new Dictionary(), - ["property2"] = new List(), - ["property3"] = new List + // Nested map and list + new Dictionary { - new Dictionary(), - "string1", - new Dictionary + ["property1"] = new Dictionary(), + ["property2"] = new List(), + ["property3"] = new List { - ["innerProperty1"] = new List(), - ["innerProperty2"] = "string2", - ["innerProperty3"] = new List + new Dictionary(), + "string1", + new Dictionary { - new List + ["innerProperty1"] = new List(), + ["innerProperty2"] = "string2", + ["innerProperty3"] = new List { - "string3" + new List + { + "string3" + } } } - } + }, + ["property4"] = "value4" }, - ["property4"] = "value4" } - }; + from shouldBeTerse in shouldProduceTerseOutputValues + select new object[] { input, shouldBeTerse }; } private void WriteValueRecursive(OpenApiJsonWriter writer, object value) @@ -233,11 +223,11 @@ private void WriteValueRecursive(OpenApiJsonWriter writer, object value) [Theory] [MemberData(nameof(WriteMapAsJsonShouldMatchExpectedTestCasesSimple))] [MemberData(nameof(WriteMapAsJsonShouldMatchExpectedTestCasesComplex))] - public void WriteMapAsJsonShouldMatchExpected(IDictionary inputMap) + public void WriteMapAsJsonShouldMatchExpected(IDictionary inputMap, bool produceTerseOutput) { // Arrange var outputString = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputString); + var writer = new OpenApiJsonWriter(outputString, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act WriteValueRecursive(writer, inputMap); @@ -251,34 +241,24 @@ public void WriteMapAsJsonShouldMatchExpected(IDictionary inputM public static IEnumerable WriteDateTimeAsJsonTestCases() { - yield return new object[] - { - new DateTimeOffset(2018, 1, 1, 10, 20, 30, TimeSpan.Zero), - }; - - yield return new object[] - { - new DateTimeOffset(2018, 1, 1, 10, 20, 30, 100, TimeSpan.FromHours(14)), - }; - - yield return new object[] - { - DateTimeOffset.UtcNow + TimeSpan.FromDays(4) - }; - - yield return new object[] - { - DateTime.UtcNow + TimeSpan.FromDays(4) - }; + return + from input in new DateTimeOffset[] { + new DateTimeOffset(2018, 1, 1, 10, 20, 30, TimeSpan.Zero), + new DateTimeOffset(2018, 1, 1, 10, 20, 30, 100, TimeSpan.FromHours(14)), + DateTimeOffset.UtcNow + TimeSpan.FromDays(4), + DateTime.UtcNow + TimeSpan.FromDays(4), + } + from shouldBeTerse in shouldProduceTerseOutputValues + select new object[] { input, shouldBeTerse }; } [Theory] [MemberData(nameof(WriteDateTimeAsJsonTestCases))] - public void WriteDateTimeAsJsonShouldMatchExpected(DateTimeOffset dateTimeOffset) + public void WriteDateTimeAsJsonShouldMatchExpected(DateTimeOffset dateTimeOffset, bool produceTerseOutput) { // Arrange var outputString = new StringWriter(CultureInfo.InvariantCulture); - var writer = new OpenApiJsonWriter(outputString); + var writer = new OpenApiJsonWriter(outputString, new OpenApiJsonWriterSettings { Terse = produceTerseOutput }); // Act writer.WriteValue(dateTimeOffset); From 66a032e48886225a1b578ffd9f76c03acc15a195 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 14 Dec 2021 12:37:26 +0300 Subject: [PATCH 098/288] Add extra params to predicate function --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 2 +- .../Services/OpenApiFilterService.cs | 19 ++++++++++++------- .../Services/OperationSearch.cs | 6 +++--- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index c08e0d84c..7ef622d0a 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -51,7 +51,7 @@ public static void ProcessOpenApiDocument( ).ReadAsync(stream).GetAwaiter().GetResult(); var document = result.OpenApiDocument; - Func predicate; + Func predicate; // Check if filter options are provided, then execute if (!string.IsNullOrEmpty(filterByOperationIds) && !string.IsNullOrEmpty(filterByTags)) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 749cd8bb8..e4bd69d92 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.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; @@ -21,10 +21,13 @@ public static class OpenApiFilterService /// /// Comma delimited list of operationIds or * for all operations. /// Comma delimited list of tags or a single regex. + /// A dictionary of requests from a postman collection. + /// The input OpenAPI document. /// A predicate. - public static Func CreatePredicate(string operationIds = null, string tags = null, Dictionary> urls = null, OpenApiDocument source = null) + public static Func CreatePredicate(string operationIds = null, string tags = null, Dictionary> urls = null, OpenApiDocument source = null) { - Func predicate; + Func predicate; + if (urls != null && (operationIds != null || tags != null)) { throw new InvalidOperationException("Cannot filter by postman collection and either operationIds and tags at the same time."); @@ -37,12 +40,12 @@ public static Func CreatePredicate(string operationIds = { if (operationIds == "*") { - predicate = (o) => true; // All operations + predicate = (url, operationType, o) => true; // All operations } else { var operationIdsArray = operationIds.Split(','); - predicate = (o) => operationIdsArray.Contains(o.OperationId); + predicate = (url, operationType, o) => operationIdsArray.Contains(o.OperationId); } } else if (tags != null) @@ -52,16 +55,18 @@ public static Func CreatePredicate(string operationIds = { var regex = new Regex(tagsArray[0]); - predicate = (o) => o.Tags.Any(tag => regex.IsMatch(tag.Name)); + predicate = (url, operationType, o) => o.Tags.Any(tag => regex.IsMatch(tag.Name)); } else { - predicate = (o) => o.Tags.Any(tag => tagsArray.Contains(tag.Name)); + predicate = (url, operationType, o) => o.Tags.Any(tag => tagsArray.Contains(tag.Name)); } } else if (urls != null) { List openApiOps = new List(); + List operationTypes = new List(); + List pathItems = new List(); var graphVersion = source.Info.Version; diff --git a/src/Microsoft.OpenApi/Services/OperationSearch.cs b/src/Microsoft.OpenApi/Services/OperationSearch.cs index 35d36b38f..95b3a6341 100644 --- a/src/Microsoft.OpenApi/Services/OperationSearch.cs +++ b/src/Microsoft.OpenApi/Services/OperationSearch.cs @@ -13,7 +13,7 @@ namespace Microsoft.OpenApi.Services /// public class OperationSearch : OpenApiVisitorBase { - private readonly Func _predicate; + private readonly Func _predicate; private readonly List _searchResults = new(); /// @@ -25,7 +25,7 @@ public class OperationSearch : OpenApiVisitorBase /// The OperationSearch constructor. /// /// A predicate function. - public OperationSearch(Func predicate) + public OperationSearch(Func predicate) { _predicate = predicate ?? throw new ArgumentNullException(nameof(predicate)); } @@ -36,7 +36,7 @@ public OperationSearch(Func predicate) /// The target . public override void Visit(OpenApiOperation operation) { - if (_predicate(operation)) + if (_predicate(CurrentKeys.Path, CurrentKeys.Operation, operation)) { _searchResults.Add(new SearchResult() { From ea8ef07ccd211b82cf6b628d2232009db9a7365c Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 14 Dec 2021 12:39:03 +0300 Subject: [PATCH 099/288] Add extra params to predicate --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index e4bd69d92..9e890b9ae 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -119,7 +119,7 @@ public static class OpenApiFilterService /// The target . /// A predicate function. /// A partial OpenAPI document. - public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Func predicate) + public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Func predicate) { // Fetch and copy title, graphVersion and server info from OpenApiDoc var subset = new OpenApiDocument @@ -303,11 +303,11 @@ private static IDictionary GetOpenApiOperations return operations; } - private static IList FindOperations(OpenApiDocument graphOpenApi, Func predicate) + private static IList FindOperations(OpenApiDocument sourceDocument, Func predicate) { var search = new OperationSearch(predicate); var walker = new OpenApiWalker(search); - walker.Walk(graphOpenApi); + walker.Walk(sourceDocument); return search.SearchResults; } From bc05c20268e783e1e69525a741c1363d65b037d0 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 14 Dec 2021 12:40:06 +0300 Subject: [PATCH 100/288] Fetch operationTypes and clean urls and pass them to our predicate function --- .../Services/OpenApiFilterService.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 9e890b9ae..1020d5684 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -89,20 +89,28 @@ public static class OpenApiFilterService var ops = openApiOperations .Where(x => x.Key.ToString().Equals(method, StringComparison.OrdinalIgnoreCase)) .Select(x => x.Value).ToList(); + var opTypes = openApiOperations + .Where(x => x.Key.ToString().Equals(method, StringComparison.OrdinalIgnoreCase)) + .Select(x => x.Key).ToList(); openApiOps.AddRange(ops); + operationTypes.AddRange(opTypes); } + + pathItems.Add(url); } - if (!(openApiOps?.Any() ?? false)) + if (!((bool) openApiOps?.Any())) { throw new ArgumentException("The urls in the postman collection supplied could not be found."); } - // Fetch the corresponding Operations Id(s) for the matched url + // Fetch the corresponding Operations Id(s) and operationTypes for the matched url var operationIdsArray = openApiOps.Select(x => x.OperationId).ToArray(); + var opTypesArray = operationTypes.Select(x => x.ToString()).ToArray(); - predicate = (o) => operationIdsArray.Contains(o.OperationId); + // predicate for matching operations, url and operationTypes + predicate = (path, operationType, o) => (pathItems.Contains(path) && opTypesArray.Contains(operationType.ToString())) || operationIdsArray.Contains(o.OperationId); } else From 718956f316ced087495274270c2237835e9f486d Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 14 Dec 2021 12:41:07 +0300 Subject: [PATCH 101/288] Use server url to format the incoming request urls from collection --- .../Services/OpenApiFilterService.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 1020d5684..ec337092f 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.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; @@ -76,7 +76,8 @@ public static class OpenApiFilterService //Iterate through urls dictionary and fetch each url foreach (var path in urls) { - var url = FormatUrlString(path.Key); + var serverList = source.Servers; + var url = FormatUrlString(path.Key, serverList); var openApiOperations = GetOpenApiOperations(rootNode, url, graphVersion); if (openApiOperations == null) @@ -365,18 +366,18 @@ private static bool AddReferences(OpenApiComponents newComponents, OpenApiCompon return moreStuff; } - private static string FormatUrlString(string url) + private static string FormatUrlString(string url, IList serverList) { - var graphVersions = new List() { "v1.0", "beta" }; var queryPath = string.Empty; - foreach (var version in graphVersions) + foreach (var server in serverList) { - if (!url.Contains(version)) + var serverUrl = server.Url; + if (!url.Contains(serverUrl)) { continue; } - var querySegments = url.Split(new[] { "v1.0", "beta" }, StringSplitOptions.None); + var querySegments = url.Split(new[]{ serverUrl }, StringSplitOptions.None); queryPath = querySegments[1]; } From 9570383315876b6c2f6db3c254e7571f2979a4e8 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 14 Dec 2021 13:34:14 +0300 Subject: [PATCH 102/288] Simplify and clean up code --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 4 +-- .../Services/OpenApiFilterService.cs | 25 ++++++++----------- 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 7ef622d0a..49636d80b 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -72,8 +72,8 @@ public static void ProcessOpenApiDocument( if (!string.IsNullOrEmpty(filterByCollection)) { var fileStream = GetStream(filterByCollection); - var urlDictionary = OpenApiFilterService.ParseJsonCollectionFile(fileStream); - predicate = OpenApiFilterService.CreatePredicate(urls: urlDictionary, source:document); + var requestUrls = OpenApiFilterService.ParseJsonCollectionFile(fileStream); + predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source:document); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index ec337092f..9ee26c6e2 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -24,11 +24,11 @@ public static class OpenApiFilterService /// A dictionary of requests from a postman collection. /// The input OpenAPI document. /// A predicate. - public static Func CreatePredicate(string operationIds = null, string tags = null, Dictionary> urls = null, OpenApiDocument source = null) + public static Func CreatePredicate(string operationIds = null, string tags = null, Dictionary> requestUrls = null, OpenApiDocument source = null) { Func predicate; - if (urls != null && (operationIds != null || tags != null)) + if (requestUrls != null && (operationIds != null || tags != null)) { throw new InvalidOperationException("Cannot filter by postman collection and either operationIds and tags at the same time."); } @@ -62,11 +62,13 @@ public static class OpenApiFilterService predicate = (url, operationType, o) => o.Tags.Any(tag => tagsArray.Contains(tag.Name)); } } - else if (urls != null) + else if (requestUrls != null) { List openApiOps = new List(); List operationTypes = new List(); List pathItems = new List(); + IDictionary openApiOperations = + new Dictionary(); var graphVersion = source.Info.Version; @@ -74,28 +76,21 @@ public static class OpenApiFilterService var rootNode = CreateOpenApiUrlTreeNode(sources); //Iterate through urls dictionary and fetch each url - foreach (var path in urls) + foreach (var path in requestUrls) { var serverList = source.Servers; var url = FormatUrlString(path.Key, serverList); - var openApiOperations = GetOpenApiOperations(rootNode, url, graphVersion); + openApiOperations = GetOpenApiOperations(rootNode, url, graphVersion); if (openApiOperations == null) { continue; } - foreach (var method in path.Value) + foreach (var ops in openApiOperations) { - var ops = openApiOperations - .Where(x => x.Key.ToString().Equals(method, StringComparison.OrdinalIgnoreCase)) - .Select(x => x.Value).ToList(); - var opTypes = openApiOperations - .Where(x => x.Key.ToString().Equals(method, StringComparison.OrdinalIgnoreCase)) - .Select(x => x.Key).ToList(); - - openApiOps.AddRange(ops); - operationTypes.AddRange(opTypes); + openApiOps.Add(ops.Value); + operationTypes.Add(ops.Key); } pathItems.Add(url); From d1ce642da602166c815753239860b0405cadae28 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 14 Dec 2021 13:39:47 +0300 Subject: [PATCH 103/288] Move declaration close to assignment; wrap line of code --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 9ee26c6e2..ab81237a3 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -67,8 +67,6 @@ public static class OpenApiFilterService List openApiOps = new List(); List operationTypes = new List(); List pathItems = new List(); - IDictionary openApiOperations = - new Dictionary(); var graphVersion = source.Info.Version; @@ -81,7 +79,7 @@ public static class OpenApiFilterService var serverList = source.Servers; var url = FormatUrlString(path.Key, serverList); - openApiOperations = GetOpenApiOperations(rootNode, url, graphVersion); + var openApiOperations = GetOpenApiOperations(rootNode, url, graphVersion); if (openApiOperations == null) { continue; @@ -106,7 +104,9 @@ public static class OpenApiFilterService var opTypesArray = operationTypes.Select(x => x.ToString()).ToArray(); // predicate for matching operations, url and operationTypes - predicate = (path, operationType, o) => (pathItems.Contains(path) && opTypesArray.Contains(operationType.ToString())) || operationIdsArray.Contains(o.OperationId); + predicate = (path, operationType, o) => + (pathItems.Contains(path) && opTypesArray.Contains(operationType.ToString())) || + operationIdsArray.Contains(o.OperationId); } else From fd6d8b0144e1bf062b3a85873042326fa67ba362 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 14 Dec 2021 13:43:18 +0300 Subject: [PATCH 104/288] Remove unnecessary parenthesis --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index ab81237a3..d4e7b481b 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -94,7 +94,7 @@ public static class OpenApiFilterService pathItems.Add(url); } - if (!((bool) openApiOps?.Any())) + if (!(bool) openApiOps?.Any()) { throw new ArgumentException("The urls in the postman collection supplied could not be found."); } From 1dc9bcc2f0cfde7b94db58b3fdb4c1989c8ceab5 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 14 Dec 2021 14:07:13 +0300 Subject: [PATCH 105/288] Clean up --- .../Services/OpenApiFilterService.cs | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index d4e7b481b..0b4e1f3e1 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -21,10 +21,11 @@ public static class OpenApiFilterService /// /// Comma delimited list of operationIds or * for all operations. /// Comma delimited list of tags or a single regex. - /// A dictionary of requests from a postman collection. + /// A dictionary of requests from a postman collection. /// The input OpenAPI document. /// A predicate. - public static Func CreatePredicate(string operationIds = null, string tags = null, Dictionary> requestUrls = null, OpenApiDocument source = null) + public static Func CreatePredicate(string operationIds = null, + string tags = null, Dictionary> requestUrls = null, OpenApiDocument source = null) { Func predicate; @@ -64,8 +65,7 @@ public static class OpenApiFilterService } else if (requestUrls != null) { - List openApiOps = new List(); - List operationTypes = new List(); + List operationTypes = new List(); List pathItems = new List(); var graphVersion = source.Info.Version; @@ -87,26 +87,20 @@ public static class OpenApiFilterService foreach (var ops in openApiOperations) { - openApiOps.Add(ops.Value); + //openApiOps.Add(ops.Value); operationTypes.Add(ops.Key); } pathItems.Add(url); } - if (!(bool) openApiOps?.Any()) + if (!(bool)operationTypes?.Any()) { throw new ArgumentException("The urls in the postman collection supplied could not be found."); } - // Fetch the corresponding Operations Id(s) and operationTypes for the matched url - var operationIdsArray = openApiOps.Select(x => x.OperationId).ToArray(); - var opTypesArray = operationTypes.Select(x => x.ToString()).ToArray(); - // predicate for matching operations, url and operationTypes - predicate = (path, operationType, o) => - (pathItems.Contains(path) && opTypesArray.Contains(operationType.ToString())) || - operationIdsArray.Contains(o.OperationId); + predicate = (path, operationType, o) => (pathItems.Contains(path) && operationTypes.Contains(operationType)); } else From c752fcb9fbbc2e8965dc7b3d54341a34453b5d36 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 14 Dec 2021 23:30:49 +0300 Subject: [PATCH 106/288] Concat operationType with url and use it for matching in our predicate --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 0b4e1f3e1..da0a91ea7 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -65,8 +65,7 @@ public static class OpenApiFilterService } else if (requestUrls != null) { - List operationTypes = new List(); - List pathItems = new List(); + List operationTypes = new List(); var graphVersion = source.Info.Version; @@ -87,11 +86,8 @@ public static class OpenApiFilterService foreach (var ops in openApiOperations) { - //openApiOps.Add(ops.Value); - operationTypes.Add(ops.Key); + operationTypes.Add(ops.Key + url); } - - pathItems.Add(url); } if (!(bool)operationTypes?.Any()) @@ -100,7 +96,7 @@ public static class OpenApiFilterService } // predicate for matching operations, url and operationTypes - predicate = (path, operationType, o) => (pathItems.Contains(path) && operationTypes.Contains(operationType)); + predicate = (path, operationType, o) => operationTypes.Contains(operationType + path); } else From e80e2860a7c462f10815df883a0dadba5e837f13 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 15 Dec 2021 00:42:01 +0300 Subject: [PATCH 107/288] Clean up comments --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index da0a91ea7..aefa5cd4f 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -72,7 +72,7 @@ public static class OpenApiFilterService var sources = new Dictionary {{graphVersion, source}}; var rootNode = CreateOpenApiUrlTreeNode(sources); - //Iterate through urls dictionary and fetch each url + //Iterate through urls dictionary and fetch operations for each url foreach (var path in requestUrls) { var serverList = source.Servers; @@ -95,7 +95,7 @@ public static class OpenApiFilterService throw new ArgumentException("The urls in the postman collection supplied could not be found."); } - // predicate for matching operations, url and operationTypes + // predicate for matching url and operationTypes predicate = (path, operationType, o) => operationTypes.Contains(operationType + path); } From c96bc16e91f957e497d6eba161530efde9770c6e Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 15 Dec 2021 00:42:37 +0300 Subject: [PATCH 108/288] Add sample postman collections for testing --- .../Microsoft.OpenApi.Tests.csproj | 6 + .../UtilityFiles/postmanCollection_ver1.json | 102 + .../UtilityFiles/postmanCollection_ver2.json | 23698 ++++++++++++++++ 3 files changed, 23806 insertions(+) create mode 100644 test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver1.json create mode 100644 test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver2.json diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 576e420cf..5c6c3946b 100755 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -34,5 +34,11 @@ + + Always + + + Always + \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver1.json b/test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver1.json new file mode 100644 index 000000000..151d184e1 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver1.json @@ -0,0 +1,102 @@ +{ + "info": { + "_postman_id": "0017059134807617005", + "name": "Graph-Collection", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "agreementAcceptances-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/agreementAcceptances", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "agreementAcceptances" + ] + } + } + }, + { + "name": "agreementAcceptances-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/agreementAcceptances", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "agreementAcceptances" + ] + } + } + }, + { + "name": "{agreementAcceptance-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/agreementAcceptances/{agreementAcceptance-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "agreementAcceptances", + "{agreementAcceptance-id}" + ] + } + } + }, + { + "name": "{agreementAcceptance-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/agreementAcceptances/{agreementAcceptance-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "agreementAcceptances", + "{agreementAcceptance-id}" + ] + } + } + }, + { + "name": "{agreementAcceptance-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/agreementAcceptances/{agreementAcceptance-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "agreementAcceptances", + "{agreementAcceptance-id}" + ] + } + } + } + ] +} \ No newline at end of file diff --git a/test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver2.json b/test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver2.json new file mode 100644 index 000000000..003577738 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver2.json @@ -0,0 +1,23698 @@ +{ + "info": { + "_postman_id": "43402ca3-f018-7c9b-2315-f176d9b171a3", + "name": "Graph-Collection", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "users-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users" + ] + } + } + }, + { + "name": "users-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users" + ] + } + } + }, + { + "name": "{user-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}" + ] + } + } + }, + { + "name": "{user-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}" + ] + } + } + }, + { + "name": "{user-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}" + ] + } + } + }, + { + "name": "activities-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/activities", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "activities" + ] + } + } + }, + { + "name": "activities-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/activities", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "activities" + ] + } + } + }, + { + "name": "{userActivity-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/activities/{userActivity-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "activities", + "{userActivity-id}" + ] + } + } + }, + { + "name": "{userActivity-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/activities/{userActivity-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "activities", + "{userActivity-id}" + ] + } + } + }, + { + "name": "{userActivity-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/activities/{userActivity-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "activities", + "{userActivity-id}" + ] + } + } + }, + { + "name": "historyItems-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/activities/{userActivity-id}/historyItems", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "activities", + "{userActivity-id}", + "historyItems" + ] + } + } + }, + { + "name": "historyItems-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/activities/{userActivity-id}/historyItems", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "activities", + "{userActivity-id}", + "historyItems" + ] + } + } + }, + { + "name": "{activityHistoryItem-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/activities/{userActivity-id}/historyItems/{activityHistoryItem-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "activities", + "{userActivity-id}", + "historyItems", + "{activityHistoryItem-id}" + ] + } + } + }, + { + "name": "{activityHistoryItem-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/activities/{userActivity-id}/historyItems/{activityHistoryItem-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "activities", + "{userActivity-id}", + "historyItems", + "{activityHistoryItem-id}" + ] + } + } + }, + { + "name": "{activityHistoryItem-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/activities/{userActivity-id}/historyItems/{activityHistoryItem-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "activities", + "{userActivity-id}", + "historyItems", + "{activityHistoryItem-id}" + ] + } + } + }, + { + "name": "activity-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/activities/{userActivity-id}/historyItems/{activityHistoryItem-id}/activity", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "activities", + "{userActivity-id}", + "historyItems", + "{activityHistoryItem-id}", + "activity" + ] + } + } + }, + { + "name": "$ref-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/activities/{userActivity-id}/historyItems/{activityHistoryItem-id}/activity/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "activities", + "{userActivity-id}", + "historyItems", + "{activityHistoryItem-id}", + "activity", + "$ref" + ] + } + } + }, + { + "name": "$ref-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/activities/{userActivity-id}/historyItems/{activityHistoryItem-id}/activity/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "activities", + "{userActivity-id}", + "historyItems", + "{activityHistoryItem-id}", + "activity", + "$ref" + ] + } + } + }, + { + "name": "$ref-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/activities/{userActivity-id}/historyItems/{activityHistoryItem-id}/activity/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "activities", + "{userActivity-id}", + "historyItems", + "{activityHistoryItem-id}", + "activity", + "$ref" + ] + } + } + }, + { + "name": "agreementAcceptances-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/agreementAcceptances", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "agreementAcceptances" + ] + } + } + }, + { + "name": "$ref-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/agreementAcceptances/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "agreementAcceptances", + "$ref" + ] + } + } + }, + { + "name": "$ref-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/agreementAcceptances/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "agreementAcceptances", + "$ref" + ] + } + } + }, + { + "name": "appRoleAssignments-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/appRoleAssignments", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "appRoleAssignments" + ] + } + } + }, + { + "name": "appRoleAssignments-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/appRoleAssignments", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "appRoleAssignments" + ] + } + } + }, + { + "name": "{appRoleAssignment-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/appRoleAssignments/{appRoleAssignment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "appRoleAssignments", + "{appRoleAssignment-id}" + ] + } + } + }, + { + "name": "{appRoleAssignment-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/appRoleAssignments/{appRoleAssignment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "appRoleAssignments", + "{appRoleAssignment-id}" + ] + } + } + }, + { + "name": "{appRoleAssignment-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/appRoleAssignments/{appRoleAssignment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "appRoleAssignments", + "{appRoleAssignment-id}" + ] + } + } + }, + { + "name": "authentication-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication" + ] + } + } + }, + { + "name": "authentication-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication" + ] + } + } + }, + { + "name": "authentication-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication" + ] + } + } + }, + { + "name": "fido2Methods-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/fido2Methods", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "fido2Methods" + ] + } + } + }, + { + "name": "fido2Methods-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/fido2Methods", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "fido2Methods" + ] + } + } + }, + { + "name": "{fido2AuthenticationMethod-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/fido2Methods/{fido2AuthenticationMethod-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "fido2Methods", + "{fido2AuthenticationMethod-id}" + ] + } + } + }, + { + "name": "{fido2AuthenticationMethod-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/fido2Methods/{fido2AuthenticationMethod-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "fido2Methods", + "{fido2AuthenticationMethod-id}" + ] + } + } + }, + { + "name": "{fido2AuthenticationMethod-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/fido2Methods/{fido2AuthenticationMethod-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "fido2Methods", + "{fido2AuthenticationMethod-id}" + ] + } + } + }, + { + "name": "methods-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/methods", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "methods" + ] + } + } + }, + { + "name": "methods-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/methods", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "methods" + ] + } + } + }, + { + "name": "{authenticationMethod-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/methods/{authenticationMethod-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "methods", + "{authenticationMethod-id}" + ] + } + } + }, + { + "name": "{authenticationMethod-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/methods/{authenticationMethod-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "methods", + "{authenticationMethod-id}" + ] + } + } + }, + { + "name": "{authenticationMethod-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/methods/{authenticationMethod-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "methods", + "{authenticationMethod-id}" + ] + } + } + }, + { + "name": "microsoftAuthenticatorMethods-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/microsoftAuthenticatorMethods", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "microsoftAuthenticatorMethods" + ] + } + } + }, + { + "name": "microsoftAuthenticatorMethods-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/microsoftAuthenticatorMethods", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "microsoftAuthenticatorMethods" + ] + } + } + }, + { + "name": "{microsoftAuthenticatorAuthenticationMethod-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/microsoftAuthenticatorMethods/{microsoftAuthenticatorAuthenticationMethod-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "microsoftAuthenticatorMethods", + "{microsoftAuthenticatorAuthenticationMethod-id}" + ] + } + } + }, + { + "name": "{microsoftAuthenticatorAuthenticationMethod-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/microsoftAuthenticatorMethods/{microsoftAuthenticatorAuthenticationMethod-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "microsoftAuthenticatorMethods", + "{microsoftAuthenticatorAuthenticationMethod-id}" + ] + } + } + }, + { + "name": "{microsoftAuthenticatorAuthenticationMethod-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/microsoftAuthenticatorMethods/{microsoftAuthenticatorAuthenticationMethod-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "microsoftAuthenticatorMethods", + "{microsoftAuthenticatorAuthenticationMethod-id}" + ] + } + } + }, + { + "name": "device-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/microsoftAuthenticatorMethods/{microsoftAuthenticatorAuthenticationMethod-id}/device", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "microsoftAuthenticatorMethods", + "{microsoftAuthenticatorAuthenticationMethod-id}", + "device" + ] + } + } + }, + { + "name": "device-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/microsoftAuthenticatorMethods/{microsoftAuthenticatorAuthenticationMethod-id}/device", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "microsoftAuthenticatorMethods", + "{microsoftAuthenticatorAuthenticationMethod-id}", + "device" + ] + } + } + }, + { + "name": "device-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/microsoftAuthenticatorMethods/{microsoftAuthenticatorAuthenticationMethod-id}/device", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "microsoftAuthenticatorMethods", + "{microsoftAuthenticatorAuthenticationMethod-id}", + "device" + ] + } + } + }, + { + "name": "windowsHelloForBusinessMethods-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/windowsHelloForBusinessMethods", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "windowsHelloForBusinessMethods" + ] + } + } + }, + { + "name": "windowsHelloForBusinessMethods-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/windowsHelloForBusinessMethods", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "windowsHelloForBusinessMethods" + ] + } + } + }, + { + "name": "{windowsHelloForBusinessAuthenticationMethod-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/windowsHelloForBusinessMethods/{windowsHelloForBusinessAuthenticationMethod-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "windowsHelloForBusinessMethods", + "{windowsHelloForBusinessAuthenticationMethod-id}" + ] + } + } + }, + { + "name": "{windowsHelloForBusinessAuthenticationMethod-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/windowsHelloForBusinessMethods/{windowsHelloForBusinessAuthenticationMethod-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "windowsHelloForBusinessMethods", + "{windowsHelloForBusinessAuthenticationMethod-id}" + ] + } + } + }, + { + "name": "{windowsHelloForBusinessAuthenticationMethod-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/windowsHelloForBusinessMethods/{windowsHelloForBusinessAuthenticationMethod-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "windowsHelloForBusinessMethods", + "{windowsHelloForBusinessAuthenticationMethod-id}" + ] + } + } + }, + { + "name": "device-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/windowsHelloForBusinessMethods/{windowsHelloForBusinessAuthenticationMethod-id}/device", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "windowsHelloForBusinessMethods", + "{windowsHelloForBusinessAuthenticationMethod-id}", + "device" + ] + } + } + }, + { + "name": "device-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/windowsHelloForBusinessMethods/{windowsHelloForBusinessAuthenticationMethod-id}/device", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "windowsHelloForBusinessMethods", + "{windowsHelloForBusinessAuthenticationMethod-id}", + "device" + ] + } + } + }, + { + "name": "device-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/authentication/windowsHelloForBusinessMethods/{windowsHelloForBusinessAuthenticationMethod-id}/device", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "authentication", + "windowsHelloForBusinessMethods", + "{windowsHelloForBusinessAuthenticationMethod-id}", + "device" + ] + } + } + }, + { + "name": "calendar-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar" + ] + } + } + }, + { + "name": "calendar-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar" + ] + } + } + }, + { + "name": "calendar-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar" + ] + } + } + }, + { + "name": "calendarPermissions-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarPermissions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarPermissions" + ] + } + } + }, + { + "name": "calendarPermissions-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarPermissions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarPermissions" + ] + } + } + }, + { + "name": "{calendarPermission-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarPermissions/{calendarPermission-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarPermissions", + "{calendarPermission-id}" + ] + } + } + }, + { + "name": "{calendarPermission-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarPermissions/{calendarPermission-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarPermissions", + "{calendarPermission-id}" + ] + } + } + }, + { + "name": "{calendarPermission-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarPermissions/{calendarPermission-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarPermissions", + "{calendarPermission-id}" + ] + } + } + }, + { + "name": "calendarView-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView" + ] + } + } + }, + { + "name": "calendarView-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView" + ] + } + } + }, + { + "name": "{event-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}" + ] + } + } + }, + { + "name": "{event-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}" + ] + } + } + }, + { + "name": "{event-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}" + ] + } + } + }, + { + "name": "attachments-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/attachments", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "attachments" + ] + } + } + }, + { + "name": "attachments-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/attachments", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "attachments" + ] + } + } + }, + { + "name": "{attachment-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/attachments/{attachment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "attachments", + "{attachment-id}" + ] + } + } + }, + { + "name": "{attachment-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/attachments/{attachment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "attachments", + "{attachment-id}" + ] + } + } + }, + { + "name": "{attachment-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/attachments/{attachment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "attachments", + "{attachment-id}" + ] + } + } + }, + { + "name": "calendar-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/calendar", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "calendar" + ] + } + } + }, + { + "name": "calendar-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/calendar", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "calendar" + ] + } + } + }, + { + "name": "calendar-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/calendar", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "calendar" + ] + } + } + }, + { + "name": "extensions-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "extensions" + ] + } + } + }, + { + "name": "extensions-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "extensions" + ] + } + } + }, + { + "name": "{extension-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "{extension-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "{extension-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "instances-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/instances", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "instances" + ] + } + } + }, + { + "name": "instances-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/instances", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "instances" + ] + } + } + }, + { + "name": "{event-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/instances/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "instances", + "{event-id1}" + ] + } + } + }, + { + "name": "{event-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/instances/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "instances", + "{event-id1}" + ] + } + } + }, + { + "name": "{event-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/instances/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "instances", + "{event-id1}" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "{multiValueLegacyExtendedProperty-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/multiValueExtendedProperties/{multiValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "multiValueExtendedProperties", + "{multiValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{multiValueLegacyExtendedProperty-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/multiValueExtendedProperties/{multiValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "multiValueExtendedProperties", + "{multiValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{multiValueLegacyExtendedProperty-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/multiValueExtendedProperties/{multiValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "multiValueExtendedProperties", + "{multiValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "{singleValueLegacyExtendedProperty-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/singleValueExtendedProperties/{singleValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "singleValueExtendedProperties", + "{singleValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{singleValueLegacyExtendedProperty-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/singleValueExtendedProperties/{singleValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "singleValueExtendedProperties", + "{singleValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{singleValueLegacyExtendedProperty-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/calendarView/{event-id}/singleValueExtendedProperties/{singleValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "calendarView", + "{event-id}", + "singleValueExtendedProperties", + "{singleValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "events-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/events", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "events" + ] + } + } + }, + { + "name": "events-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/events", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "events" + ] + } + } + }, + { + "name": "{event-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/events/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "events", + "{event-id}" + ] + } + } + }, + { + "name": "{event-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/events/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "events", + "{event-id}" + ] + } + } + }, + { + "name": "{event-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/events/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "events", + "{event-id}" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "{multiValueLegacyExtendedProperty-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/multiValueExtendedProperties/{multiValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "multiValueExtendedProperties", + "{multiValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{multiValueLegacyExtendedProperty-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/multiValueExtendedProperties/{multiValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "multiValueExtendedProperties", + "{multiValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{multiValueLegacyExtendedProperty-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/multiValueExtendedProperties/{multiValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "multiValueExtendedProperties", + "{multiValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "{singleValueLegacyExtendedProperty-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/singleValueExtendedProperties/{singleValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "singleValueExtendedProperties", + "{singleValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{singleValueLegacyExtendedProperty-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/singleValueExtendedProperties/{singleValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "singleValueExtendedProperties", + "{singleValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{singleValueLegacyExtendedProperty-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendar/singleValueExtendedProperties/{singleValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendar", + "singleValueExtendedProperties", + "{singleValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "calendarGroups-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups" + ] + } + } + }, + { + "name": "calendarGroups-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups" + ] + } + } + }, + { + "name": "{calendarGroup-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}" + ] + } + } + }, + { + "name": "{calendarGroup-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}" + ] + } + } + }, + { + "name": "{calendarGroup-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}" + ] + } + } + }, + { + "name": "calendars-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars" + ] + } + } + }, + { + "name": "calendars-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars" + ] + } + } + }, + { + "name": "{calendar-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}" + ] + } + } + }, + { + "name": "{calendar-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}" + ] + } + } + }, + { + "name": "{calendar-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}" + ] + } + } + }, + { + "name": "calendarPermissions-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarPermissions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarPermissions" + ] + } + } + }, + { + "name": "calendarPermissions-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarPermissions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarPermissions" + ] + } + } + }, + { + "name": "{calendarPermission-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarPermissions/{calendarPermission-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarPermissions", + "{calendarPermission-id}" + ] + } + } + }, + { + "name": "{calendarPermission-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarPermissions/{calendarPermission-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarPermissions", + "{calendarPermission-id}" + ] + } + } + }, + { + "name": "{calendarPermission-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarPermissions/{calendarPermission-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarPermissions", + "{calendarPermission-id}" + ] + } + } + }, + { + "name": "calendarView-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView" + ] + } + } + }, + { + "name": "calendarView-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView" + ] + } + } + }, + { + "name": "{event-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}" + ] + } + } + }, + { + "name": "{event-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}" + ] + } + } + }, + { + "name": "{event-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}" + ] + } + } + }, + { + "name": "attachments-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/attachments", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "attachments" + ] + } + } + }, + { + "name": "attachments-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/attachments", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "attachments" + ] + } + } + }, + { + "name": "{attachment-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/attachments/{attachment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "attachments", + "{attachment-id}" + ] + } + } + }, + { + "name": "{attachment-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/attachments/{attachment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "attachments", + "{attachment-id}" + ] + } + } + }, + { + "name": "{attachment-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/attachments/{attachment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "attachments", + "{attachment-id}" + ] + } + } + }, + { + "name": "calendar-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/calendar", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "calendar" + ] + } + } + }, + { + "name": "calendar-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/calendar", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "calendar" + ] + } + } + }, + { + "name": "calendar-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/calendar", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "calendar" + ] + } + } + }, + { + "name": "extensions-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "extensions" + ] + } + } + }, + { + "name": "extensions-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "extensions" + ] + } + } + }, + { + "name": "{extension-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "{extension-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "{extension-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "instances-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/instances", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "instances" + ] + } + } + }, + { + "name": "instances-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/instances", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "instances" + ] + } + } + }, + { + "name": "{event-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/instances/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "instances", + "{event-id1}" + ] + } + } + }, + { + "name": "{event-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/instances/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "instances", + "{event-id1}" + ] + } + } + }, + { + "name": "{event-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/instances/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "instances", + "{event-id1}" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "{multiValueLegacyExtendedProperty-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/multiValueExtendedProperties/{multiValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "multiValueExtendedProperties", + "{multiValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{multiValueLegacyExtendedProperty-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/multiValueExtendedProperties/{multiValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "multiValueExtendedProperties", + "{multiValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{multiValueLegacyExtendedProperty-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/multiValueExtendedProperties/{multiValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "multiValueExtendedProperties", + "{multiValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "{singleValueLegacyExtendedProperty-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/singleValueExtendedProperties/{singleValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "singleValueExtendedProperties", + "{singleValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{singleValueLegacyExtendedProperty-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/singleValueExtendedProperties/{singleValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "singleValueExtendedProperties", + "{singleValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{singleValueLegacyExtendedProperty-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/calendarView/{event-id}/singleValueExtendedProperties/{singleValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "singleValueExtendedProperties", + "{singleValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "events-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/events", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "events" + ] + } + } + }, + { + "name": "events-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/events", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "events" + ] + } + } + }, + { + "name": "{event-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/events/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "events", + "{event-id}" + ] + } + } + }, + { + "name": "{event-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/events/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "events", + "{event-id}" + ] + } + } + }, + { + "name": "{event-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/events/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "events", + "{event-id}" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "{multiValueLegacyExtendedProperty-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/multiValueExtendedProperties/{multiValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "multiValueExtendedProperties", + "{multiValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{multiValueLegacyExtendedProperty-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/multiValueExtendedProperties/{multiValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "multiValueExtendedProperties", + "{multiValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{multiValueLegacyExtendedProperty-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/multiValueExtendedProperties/{multiValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "multiValueExtendedProperties", + "{multiValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "{singleValueLegacyExtendedProperty-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/singleValueExtendedProperties/{singleValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "singleValueExtendedProperties", + "{singleValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{singleValueLegacyExtendedProperty-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/singleValueExtendedProperties/{singleValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "singleValueExtendedProperties", + "{singleValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{singleValueLegacyExtendedProperty-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarGroups/{calendarGroup-id}/calendars/{calendar-id}/singleValueExtendedProperties/{singleValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarGroups", + "{calendarGroup-id}", + "calendars", + "{calendar-id}", + "singleValueExtendedProperties", + "{singleValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "calendars-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars" + ] + } + } + }, + { + "name": "calendars-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars" + ] + } + } + }, + { + "name": "{calendar-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}" + ] + } + } + }, + { + "name": "{calendar-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}" + ] + } + } + }, + { + "name": "{calendar-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}" + ] + } + } + }, + { + "name": "calendarPermissions-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarPermissions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarPermissions" + ] + } + } + }, + { + "name": "calendarPermissions-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarPermissions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarPermissions" + ] + } + } + }, + { + "name": "{calendarPermission-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarPermissions/{calendarPermission-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarPermissions", + "{calendarPermission-id}" + ] + } + } + }, + { + "name": "{calendarPermission-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarPermissions/{calendarPermission-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarPermissions", + "{calendarPermission-id}" + ] + } + } + }, + { + "name": "{calendarPermission-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarPermissions/{calendarPermission-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarPermissions", + "{calendarPermission-id}" + ] + } + } + }, + { + "name": "calendarView-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView" + ] + } + } + }, + { + "name": "calendarView-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView" + ] + } + } + }, + { + "name": "{event-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}" + ] + } + } + }, + { + "name": "{event-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}" + ] + } + } + }, + { + "name": "{event-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}" + ] + } + } + }, + { + "name": "attachments-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/attachments", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "attachments" + ] + } + } + }, + { + "name": "attachments-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/attachments", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "attachments" + ] + } + } + }, + { + "name": "{attachment-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/attachments/{attachment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "attachments", + "{attachment-id}" + ] + } + } + }, + { + "name": "{attachment-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/attachments/{attachment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "attachments", + "{attachment-id}" + ] + } + } + }, + { + "name": "{attachment-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/attachments/{attachment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "attachments", + "{attachment-id}" + ] + } + } + }, + { + "name": "calendar-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/calendar", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "calendar" + ] + } + } + }, + { + "name": "calendar-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/calendar", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "calendar" + ] + } + } + }, + { + "name": "calendar-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/calendar", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "calendar" + ] + } + } + }, + { + "name": "extensions-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "extensions" + ] + } + } + }, + { + "name": "extensions-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "extensions" + ] + } + } + }, + { + "name": "{extension-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "{extension-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "{extension-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "instances-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/instances", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "instances" + ] + } + } + }, + { + "name": "instances-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/instances", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "instances" + ] + } + } + }, + { + "name": "{event-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/instances/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "instances", + "{event-id1}" + ] + } + } + }, + { + "name": "{event-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/instances/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "instances", + "{event-id1}" + ] + } + } + }, + { + "name": "{event-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/instances/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "instances", + "{event-id1}" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/calendarView/{event-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "calendarView", + "{event-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "events-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/events", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "events" + ] + } + } + }, + { + "name": "events-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/events", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "events" + ] + } + } + }, + { + "name": "{event-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/events/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "events", + "{event-id}" + ] + } + } + }, + { + "name": "{event-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/events/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "events", + "{event-id}" + ] + } + } + }, + { + "name": "{event-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/events/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "events", + "{event-id}" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "{multiValueLegacyExtendedProperty-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/multiValueExtendedProperties/{multiValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "multiValueExtendedProperties", + "{multiValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{multiValueLegacyExtendedProperty-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/multiValueExtendedProperties/{multiValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "multiValueExtendedProperties", + "{multiValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{multiValueLegacyExtendedProperty-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/multiValueExtendedProperties/{multiValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "multiValueExtendedProperties", + "{multiValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "{singleValueLegacyExtendedProperty-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/singleValueExtendedProperties/{singleValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "singleValueExtendedProperties", + "{singleValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{singleValueLegacyExtendedProperty-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/singleValueExtendedProperties/{singleValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "singleValueExtendedProperties", + "{singleValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "{singleValueLegacyExtendedProperty-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/singleValueExtendedProperties/{singleValueLegacyExtendedProperty-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendars", + "{calendar-id}", + "singleValueExtendedProperties", + "{singleValueLegacyExtendedProperty-id}" + ] + } + } + }, + { + "name": "calendarView-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView" + ] + } + } + }, + { + "name": "calendarView-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView" + ] + } + } + }, + { + "name": "{event-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}" + ] + } + } + }, + { + "name": "{event-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}" + ] + } + } + }, + { + "name": "{event-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}" + ] + } + } + }, + { + "name": "attachments-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/attachments", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "attachments" + ] + } + } + }, + { + "name": "attachments-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/attachments", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "attachments" + ] + } + } + }, + { + "name": "{attachment-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/attachments/{attachment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "attachments", + "{attachment-id}" + ] + } + } + }, + { + "name": "{attachment-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/attachments/{attachment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "attachments", + "{attachment-id}" + ] + } + } + }, + { + "name": "{attachment-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/attachments/{attachment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "attachments", + "{attachment-id}" + ] + } + } + }, + { + "name": "calendar-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar" + ] + } + } + }, + { + "name": "calendar-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar" + ] + } + } + }, + { + "name": "calendar-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar" + ] + } + } + }, + { + "name": "calendarPermissions-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/calendarPermissions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "calendarPermissions" + ] + } + } + }, + { + "name": "calendarPermissions-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/calendarPermissions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "calendarPermissions" + ] + } + } + }, + { + "name": "{calendarPermission-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/calendarPermissions/{calendarPermission-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "calendarPermissions", + "{calendarPermission-id}" + ] + } + } + }, + { + "name": "{calendarPermission-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/calendarPermissions/{calendarPermission-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "calendarPermissions", + "{calendarPermission-id}" + ] + } + } + }, + { + "name": "{calendarPermission-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/calendarPermissions/{calendarPermission-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "calendarPermissions", + "{calendarPermission-id}" + ] + } + } + }, + { + "name": "calendarView-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/calendarView", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "calendarView" + ] + } + } + }, + { + "name": "calendarView-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/calendarView", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "calendarView" + ] + } + } + }, + { + "name": "{event-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/calendarView/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "calendarView", + "{event-id1}" + ] + } + } + }, + { + "name": "{event-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/calendarView/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "calendarView", + "{event-id1}" + ] + } + } + }, + { + "name": "{event-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/calendarView/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "calendarView", + "{event-id1}" + ] + } + } + }, + { + "name": "events-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/events", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "events" + ] + } + } + }, + { + "name": "events-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/events", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "events" + ] + } + } + }, + { + "name": "{event-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/events/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "events", + "{event-id1}" + ] + } + } + }, + { + "name": "{event-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/events/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "events", + "{event-id1}" + ] + } + } + }, + { + "name": "{event-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/events/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "events", + "{event-id1}" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/calendar/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "calendar", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "extensions-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "extensions" + ] + } + } + }, + { + "name": "extensions-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "extensions" + ] + } + } + }, + { + "name": "{extension-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "{extension-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "{extension-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "instances-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/instances", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "instances" + ] + } + } + }, + { + "name": "instances-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/instances", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "instances" + ] + } + } + }, + { + "name": "{event-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/instances/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "instances", + "{event-id1}" + ] + } + } + }, + { + "name": "{event-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/instances/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "instances", + "{event-id1}" + ] + } + } + }, + { + "name": "{event-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/instances/{event-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "instances", + "{event-id1}" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/calendarView/{event-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "calendarView", + "{event-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "chats-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/chats", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "chats" + ] + } + } + }, + { + "name": "chats-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/chats", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "chats" + ] + } + } + }, + { + "name": "{chat-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/chats/{chat-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "chats", + "{chat-id}" + ] + } + } + }, + { + "name": "{chat-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/chats/{chat-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "chats", + "{chat-id}" + ] + } + } + }, + { + "name": "{chat-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/chats/{chat-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "chats", + "{chat-id}" + ] + } + } + }, + { + "name": "contactFolders-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders" + ] + } + } + }, + { + "name": "contactFolders-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders" + ] + } + } + }, + { + "name": "{contactFolder-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}" + ] + } + } + }, + { + "name": "{contactFolder-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}" + ] + } + } + }, + { + "name": "{contactFolder-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}" + ] + } + } + }, + { + "name": "childFolders-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/childFolders", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "childFolders" + ] + } + } + }, + { + "name": "childFolders-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/childFolders", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "childFolders" + ] + } + } + }, + { + "name": "{contactFolder-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/childFolders/{contactFolder-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "childFolders", + "{contactFolder-id1}" + ] + } + } + }, + { + "name": "{contactFolder-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/childFolders/{contactFolder-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "childFolders", + "{contactFolder-id1}" + ] + } + } + }, + { + "name": "{contactFolder-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/childFolders/{contactFolder-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "childFolders", + "{contactFolder-id1}" + ] + } + } + }, + { + "name": "contacts-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/contacts", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "contacts" + ] + } + } + }, + { + "name": "contacts-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/contacts", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "contacts" + ] + } + } + }, + { + "name": "{contact-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/contacts/{contact-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "contacts", + "{contact-id}" + ] + } + } + }, + { + "name": "{contact-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/contacts/{contact-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "contacts", + "{contact-id}" + ] + } + } + }, + { + "name": "{contact-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/contacts/{contact-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "contacts", + "{contact-id}" + ] + } + } + }, + { + "name": "extensions-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/contacts/{contact-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "contacts", + "{contact-id}", + "extensions" + ] + } + } + }, + { + "name": "extensions-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/contacts/{contact-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "contacts", + "{contact-id}", + "extensions" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/contacts/{contact-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "contacts", + "{contact-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/contacts/{contact-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "contacts", + "{contact-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "photo-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/contacts/{contact-id}/photo", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "contacts", + "{contact-id}", + "photo" + ] + } + } + }, + { + "name": "photo-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/contacts/{contact-id}/photo", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "contacts", + "{contact-id}", + "photo" + ] + } + } + }, + { + "name": "photo-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/contacts/{contact-id}/photo", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "contacts", + "{contact-id}", + "photo" + ] + } + } + }, + { + "name": "$value-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/contacts/{contact-id}/photo/$value", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "contacts", + "{contact-id}", + "photo", + "$value" + ] + } + } + }, + { + "name": "$value-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/contacts/{contact-id}/photo/$value", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "contacts", + "{contact-id}", + "photo", + "$value" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/contacts/{contact-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "contacts", + "{contact-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/contacts/{contact-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "contacts", + "{contact-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contactFolders/{contactFolder-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contactFolders", + "{contactFolder-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "contacts-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contacts", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contacts" + ] + } + } + }, + { + "name": "contacts-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contacts", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contacts" + ] + } + } + }, + { + "name": "{contact-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contacts/{contact-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contacts", + "{contact-id}" + ] + } + } + }, + { + "name": "{contact-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contacts/{contact-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contacts", + "{contact-id}" + ] + } + } + }, + { + "name": "{contact-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contacts/{contact-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contacts", + "{contact-id}" + ] + } + } + }, + { + "name": "extensions-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contacts/{contact-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contacts", + "{contact-id}", + "extensions" + ] + } + } + }, + { + "name": "extensions-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contacts/{contact-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contacts", + "{contact-id}", + "extensions" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contacts/{contact-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contacts", + "{contact-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contacts/{contact-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contacts", + "{contact-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "photo-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contacts/{contact-id}/photo", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contacts", + "{contact-id}", + "photo" + ] + } + } + }, + { + "name": "photo-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contacts/{contact-id}/photo", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contacts", + "{contact-id}", + "photo" + ] + } + } + }, + { + "name": "photo-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contacts/{contact-id}/photo", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contacts", + "{contact-id}", + "photo" + ] + } + } + }, + { + "name": "$value-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contacts/{contact-id}/photo/$value", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contacts", + "{contact-id}", + "photo", + "$value" + ] + } + } + }, + { + "name": "$value-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contacts/{contact-id}/photo/$value", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contacts", + "{contact-id}", + "photo", + "$value" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contacts/{contact-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contacts", + "{contact-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/contacts/{contact-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "contacts", + "{contact-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "createdObjects-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/createdObjects", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "createdObjects" + ] + } + } + }, + { + "name": "$ref-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/createdObjects/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "createdObjects", + "$ref" + ] + } + } + }, + { + "name": "$ref-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/createdObjects/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "createdObjects", + "$ref" + ] + } + } + }, + { + "name": "deviceManagementTroubleshootingEvents-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/deviceManagementTroubleshootingEvents", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "deviceManagementTroubleshootingEvents" + ] + } + } + }, + { + "name": "deviceManagementTroubleshootingEvents-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/deviceManagementTroubleshootingEvents", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "deviceManagementTroubleshootingEvents" + ] + } + } + }, + { + "name": "{deviceManagementTroubleshootingEvent-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/deviceManagementTroubleshootingEvents/{deviceManagementTroubleshootingEvent-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "deviceManagementTroubleshootingEvents", + "{deviceManagementTroubleshootingEvent-id}" + ] + } + } + }, + { + "name": "{deviceManagementTroubleshootingEvent-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/deviceManagementTroubleshootingEvents/{deviceManagementTroubleshootingEvent-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "deviceManagementTroubleshootingEvents", + "{deviceManagementTroubleshootingEvent-id}" + ] + } + } + }, + { + "name": "{deviceManagementTroubleshootingEvent-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/deviceManagementTroubleshootingEvents/{deviceManagementTroubleshootingEvent-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "deviceManagementTroubleshootingEvents", + "{deviceManagementTroubleshootingEvent-id}" + ] + } + } + }, + { + "name": "directReports-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/directReports", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "directReports" + ] + } + } + }, + { + "name": "$ref-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/directReports/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "directReports", + "$ref" + ] + } + } + }, + { + "name": "$ref-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/directReports/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "directReports", + "$ref" + ] + } + } + }, + { + "name": "drive-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/drive", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "drive" + ] + } + } + }, + { + "name": "drive-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/drive", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "drive" + ] + } + } + }, + { + "name": "drive-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/drive", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "drive" + ] + } + } + }, + { + "name": "drives-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/drives", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "drives" + ] + } + } + }, + { + "name": "drives-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/drives", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "drives" + ] + } + } + }, + { + "name": "{drive-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/drives/{drive-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "drives", + "{drive-id}" + ] + } + } + }, + { + "name": "{drive-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/drives/{drive-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "drives", + "{drive-id}" + ] + } + } + }, + { + "name": "{drive-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/drives/{drive-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "drives", + "{drive-id}" + ] + } + } + }, + { + "name": "events-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/events", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "events" + ] + } + } + }, + { + "name": "events-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/events", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "events" + ] + } + } + }, + { + "name": "{event-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/events/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "events", + "{event-id}" + ] + } + } + }, + { + "name": "{event-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/events/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "events", + "{event-id}" + ] + } + } + }, + { + "name": "{event-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/events/{event-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "events", + "{event-id}" + ] + } + } + }, + { + "name": "extensions-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "extensions" + ] + } + } + }, + { + "name": "extensions-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "extensions" + ] + } + } + }, + { + "name": "{extension-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "{extension-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "{extension-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "followedSites-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/followedSites", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "followedSites" + ] + } + } + }, + { + "name": "$ref-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/followedSites/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "followedSites", + "$ref" + ] + } + } + }, + { + "name": "$ref-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/followedSites/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "followedSites", + "$ref" + ] + } + } + }, + { + "name": "inferenceClassification-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/inferenceClassification", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "inferenceClassification" + ] + } + } + }, + { + "name": "inferenceClassification-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/inferenceClassification", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "inferenceClassification" + ] + } + } + }, + { + "name": "inferenceClassification-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/inferenceClassification", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "inferenceClassification" + ] + } + } + }, + { + "name": "overrides-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/inferenceClassification/overrides", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "inferenceClassification", + "overrides" + ] + } + } + }, + { + "name": "overrides-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/inferenceClassification/overrides", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "inferenceClassification", + "overrides" + ] + } + } + }, + { + "name": "{inferenceClassificationOverride-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/inferenceClassification/overrides/{inferenceClassificationOverride-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "inferenceClassification", + "overrides", + "{inferenceClassificationOverride-id}" + ] + } + } + }, + { + "name": "{inferenceClassificationOverride-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/inferenceClassification/overrides/{inferenceClassificationOverride-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "inferenceClassification", + "overrides", + "{inferenceClassificationOverride-id}" + ] + } + } + }, + { + "name": "{inferenceClassificationOverride-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/inferenceClassification/overrides/{inferenceClassificationOverride-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "inferenceClassification", + "overrides", + "{inferenceClassificationOverride-id}" + ] + } + } + }, + { + "name": "insights-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights" + ] + } + } + }, + { + "name": "insights-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights" + ] + } + } + }, + { + "name": "insights-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights" + ] + } + } + }, + { + "name": "shared-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/shared", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "shared" + ] + } + } + }, + { + "name": "shared-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/shared", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "shared" + ] + } + } + }, + { + "name": "{sharedInsight-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/shared/{sharedInsight-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "shared", + "{sharedInsight-id}" + ] + } + } + }, + { + "name": "{sharedInsight-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/shared/{sharedInsight-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "shared", + "{sharedInsight-id}" + ] + } + } + }, + { + "name": "{sharedInsight-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/shared/{sharedInsight-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "shared", + "{sharedInsight-id}" + ] + } + } + }, + { + "name": "lastSharedMethod-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/shared/{sharedInsight-id}/lastSharedMethod", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "shared", + "{sharedInsight-id}", + "lastSharedMethod" + ] + } + } + }, + { + "name": "$ref-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/shared/{sharedInsight-id}/lastSharedMethod/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "shared", + "{sharedInsight-id}", + "lastSharedMethod", + "$ref" + ] + } + } + }, + { + "name": "$ref-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/shared/{sharedInsight-id}/lastSharedMethod/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "shared", + "{sharedInsight-id}", + "lastSharedMethod", + "$ref" + ] + } + } + }, + { + "name": "$ref-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/shared/{sharedInsight-id}/lastSharedMethod/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "shared", + "{sharedInsight-id}", + "lastSharedMethod", + "$ref" + ] + } + } + }, + { + "name": "resource-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/shared/{sharedInsight-id}/resource", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "shared", + "{sharedInsight-id}", + "resource" + ] + } + } + }, + { + "name": "$ref-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/shared/{sharedInsight-id}/resource/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "shared", + "{sharedInsight-id}", + "resource", + "$ref" + ] + } + } + }, + { + "name": "$ref-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/shared/{sharedInsight-id}/resource/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "shared", + "{sharedInsight-id}", + "resource", + "$ref" + ] + } + } + }, + { + "name": "$ref-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/shared/{sharedInsight-id}/resource/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "shared", + "{sharedInsight-id}", + "resource", + "$ref" + ] + } + } + }, + { + "name": "trending-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/trending", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "trending" + ] + } + } + }, + { + "name": "trending-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/trending", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "trending" + ] + } + } + }, + { + "name": "{trending-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/trending/{trending-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "trending", + "{trending-id}" + ] + } + } + }, + { + "name": "{trending-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/trending/{trending-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "trending", + "{trending-id}" + ] + } + } + }, + { + "name": "{trending-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/trending/{trending-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "trending", + "{trending-id}" + ] + } + } + }, + { + "name": "resource-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/trending/{trending-id}/resource", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "trending", + "{trending-id}", + "resource" + ] + } + } + }, + { + "name": "used-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/used", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "used" + ] + } + } + }, + { + "name": "used-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/used", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "used" + ] + } + } + }, + { + "name": "{usedInsight-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/used/{usedInsight-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "used", + "{usedInsight-id}" + ] + } + } + }, + { + "name": "{usedInsight-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/used/{usedInsight-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "used", + "{usedInsight-id}" + ] + } + } + }, + { + "name": "{usedInsight-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/used/{usedInsight-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "used", + "{usedInsight-id}" + ] + } + } + }, + { + "name": "resource-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/insights/used/{usedInsight-id}/resource", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "insights", + "used", + "{usedInsight-id}", + "resource" + ] + } + } + }, + { + "name": "joinedTeams-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/joinedTeams", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "joinedTeams" + ] + } + } + }, + { + "name": "joinedTeams-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/joinedTeams", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "joinedTeams" + ] + } + } + }, + { + "name": "{team-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/joinedTeams/{team-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "joinedTeams", + "{team-id}" + ] + } + } + }, + { + "name": "{team-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/joinedTeams/{team-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "joinedTeams", + "{team-id}" + ] + } + } + }, + { + "name": "{team-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/joinedTeams/{team-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "joinedTeams", + "{team-id}" + ] + } + } + }, + { + "name": "licenseDetails-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/licenseDetails", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "licenseDetails" + ] + } + } + }, + { + "name": "licenseDetails-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/licenseDetails", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "licenseDetails" + ] + } + } + }, + { + "name": "{licenseDetails-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/licenseDetails/{licenseDetails-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "licenseDetails", + "{licenseDetails-id}" + ] + } + } + }, + { + "name": "{licenseDetails-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/licenseDetails/{licenseDetails-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "licenseDetails", + "{licenseDetails-id}" + ] + } + } + }, + { + "name": "{licenseDetails-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/licenseDetails/{licenseDetails-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "licenseDetails", + "{licenseDetails-id}" + ] + } + } + }, + { + "name": "mailFolders-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders" + ] + } + } + }, + { + "name": "mailFolders-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders" + ] + } + } + }, + { + "name": "{mailFolder-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}" + ] + } + } + }, + { + "name": "{mailFolder-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}" + ] + } + } + }, + { + "name": "{mailFolder-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}" + ] + } + } + }, + { + "name": "childFolders-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/childFolders", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "childFolders" + ] + } + } + }, + { + "name": "childFolders-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/childFolders", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "childFolders" + ] + } + } + }, + { + "name": "{mailFolder-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/childFolders/{mailFolder-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "childFolders", + "{mailFolder-id1}" + ] + } + } + }, + { + "name": "{mailFolder-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/childFolders/{mailFolder-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "childFolders", + "{mailFolder-id1}" + ] + } + } + }, + { + "name": "{mailFolder-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/childFolders/{mailFolder-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "childFolders", + "{mailFolder-id1}" + ] + } + } + }, + { + "name": "messageRules-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messageRules", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messageRules" + ] + } + } + }, + { + "name": "messageRules-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messageRules", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messageRules" + ] + } + } + }, + { + "name": "{messageRule-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messageRules/{messageRule-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messageRules", + "{messageRule-id}" + ] + } + } + }, + { + "name": "{messageRule-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messageRules/{messageRule-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messageRules", + "{messageRule-id}" + ] + } + } + }, + { + "name": "{messageRule-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messageRules/{messageRule-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messageRules", + "{messageRule-id}" + ] + } + } + }, + { + "name": "messages-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messages" + ] + } + } + }, + { + "name": "messages-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messages" + ] + } + } + }, + { + "name": "{message-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messages/{message-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messages", + "{message-id}" + ] + } + } + }, + { + "name": "{message-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messages/{message-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messages", + "{message-id}" + ] + } + } + }, + { + "name": "{message-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messages/{message-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messages", + "{message-id}" + ] + } + } + }, + { + "name": "$value-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messages/{message-id}/$value", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messages", + "{message-id}", + "$value" + ] + } + } + }, + { + "name": "$value-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messages/{message-id}/$value", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messages", + "{message-id}", + "$value" + ] + } + } + }, + { + "name": "attachments-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messages/{message-id}/attachments", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messages", + "{message-id}", + "attachments" + ] + } + } + }, + { + "name": "attachments-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messages/{message-id}/attachments", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messages", + "{message-id}", + "attachments" + ] + } + } + }, + { + "name": "extensions-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messages/{message-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messages", + "{message-id}", + "extensions" + ] + } + } + }, + { + "name": "extensions-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messages/{message-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messages", + "{message-id}", + "extensions" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messages/{message-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messages", + "{message-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messages/{message-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messages", + "{message-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messages/{message-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messages", + "{message-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/messages/{message-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "messages", + "{message-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/mailFolders/{mailFolder-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "mailFolders", + "{mailFolder-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "managedAppRegistrations-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedAppRegistrations", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedAppRegistrations" + ] + } + } + }, + { + "name": "$ref-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedAppRegistrations/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedAppRegistrations", + "$ref" + ] + } + } + }, + { + "name": "$ref-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedAppRegistrations/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedAppRegistrations", + "$ref" + ] + } + } + }, + { + "name": "managedDevices-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices" + ] + } + } + }, + { + "name": "managedDevices-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices" + ] + } + } + }, + { + "name": "{managedDevice-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices/{managedDevice-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices", + "{managedDevice-id}" + ] + } + } + }, + { + "name": "{managedDevice-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices/{managedDevice-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices", + "{managedDevice-id}" + ] + } + } + }, + { + "name": "{managedDevice-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices/{managedDevice-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices", + "{managedDevice-id}" + ] + } + } + }, + { + "name": "deviceCategory-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices/{managedDevice-id}/deviceCategory", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices", + "{managedDevice-id}", + "deviceCategory" + ] + } + } + }, + { + "name": "deviceCategory-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices/{managedDevice-id}/deviceCategory", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices", + "{managedDevice-id}", + "deviceCategory" + ] + } + } + }, + { + "name": "deviceCategory-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices/{managedDevice-id}/deviceCategory", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices", + "{managedDevice-id}", + "deviceCategory" + ] + } + } + }, + { + "name": "deviceCompliancePolicyStates-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices/{managedDevice-id}/deviceCompliancePolicyStates", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices", + "{managedDevice-id}", + "deviceCompliancePolicyStates" + ] + } + } + }, + { + "name": "deviceCompliancePolicyStates-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices/{managedDevice-id}/deviceCompliancePolicyStates", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices", + "{managedDevice-id}", + "deviceCompliancePolicyStates" + ] + } + } + }, + { + "name": "{deviceCompliancePolicyState-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices/{managedDevice-id}/deviceCompliancePolicyStates/{deviceCompliancePolicyState-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices", + "{managedDevice-id}", + "deviceCompliancePolicyStates", + "{deviceCompliancePolicyState-id}" + ] + } + } + }, + { + "name": "{deviceCompliancePolicyState-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices/{managedDevice-id}/deviceCompliancePolicyStates/{deviceCompliancePolicyState-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices", + "{managedDevice-id}", + "deviceCompliancePolicyStates", + "{deviceCompliancePolicyState-id}" + ] + } + } + }, + { + "name": "{deviceCompliancePolicyState-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices/{managedDevice-id}/deviceCompliancePolicyStates/{deviceCompliancePolicyState-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices", + "{managedDevice-id}", + "deviceCompliancePolicyStates", + "{deviceCompliancePolicyState-id}" + ] + } + } + }, + { + "name": "deviceConfigurationStates-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices/{managedDevice-id}/deviceConfigurationStates", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices", + "{managedDevice-id}", + "deviceConfigurationStates" + ] + } + } + }, + { + "name": "deviceConfigurationStates-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices/{managedDevice-id}/deviceConfigurationStates", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices", + "{managedDevice-id}", + "deviceConfigurationStates" + ] + } + } + }, + { + "name": "{deviceConfigurationState-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices/{managedDevice-id}/deviceConfigurationStates/{deviceConfigurationState-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices", + "{managedDevice-id}", + "deviceConfigurationStates", + "{deviceConfigurationState-id}" + ] + } + } + }, + { + "name": "{deviceConfigurationState-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices/{managedDevice-id}/deviceConfigurationStates/{deviceConfigurationState-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices", + "{managedDevice-id}", + "deviceConfigurationStates", + "{deviceConfigurationState-id}" + ] + } + } + }, + { + "name": "{deviceConfigurationState-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/managedDevices/{managedDevice-id}/deviceConfigurationStates/{deviceConfigurationState-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "managedDevices", + "{managedDevice-id}", + "deviceConfigurationStates", + "{deviceConfigurationState-id}" + ] + } + } + }, + { + "name": "manager-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/manager", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "manager" + ] + } + } + }, + { + "name": "$ref-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/manager/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "manager", + "$ref" + ] + } + } + }, + { + "name": "$ref-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/manager/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "manager", + "$ref" + ] + } + } + }, + { + "name": "$ref-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/manager/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "manager", + "$ref" + ] + } + } + }, + { + "name": "memberOf-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/memberOf", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "memberOf" + ] + } + } + }, + { + "name": "$ref-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/memberOf/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "memberOf", + "$ref" + ] + } + } + }, + { + "name": "$ref-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/memberOf/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "memberOf", + "$ref" + ] + } + } + }, + { + "name": "messages-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/messages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "messages" + ] + } + } + }, + { + "name": "messages-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/messages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "messages" + ] + } + } + }, + { + "name": "{message-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/messages/{message-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "messages", + "{message-id}" + ] + } + } + }, + { + "name": "{message-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/messages/{message-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "messages", + "{message-id}" + ] + } + } + }, + { + "name": "{message-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/messages/{message-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "messages", + "{message-id}" + ] + } + } + }, + { + "name": "$value-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/messages/{message-id}/$value", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "messages", + "{message-id}", + "$value" + ] + } + } + }, + { + "name": "$value-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/messages/{message-id}/$value", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "messages", + "{message-id}", + "$value" + ] + } + } + }, + { + "name": "attachments-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/messages/{message-id}/attachments", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "messages", + "{message-id}", + "attachments" + ] + } + } + }, + { + "name": "attachments-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/messages/{message-id}/attachments", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "messages", + "{message-id}", + "attachments" + ] + } + } + }, + { + "name": "extensions-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/messages/{message-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "messages", + "{message-id}", + "extensions" + ] + } + } + }, + { + "name": "extensions-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/messages/{message-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "messages", + "{message-id}", + "extensions" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/messages/{message-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "messages", + "{message-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "multiValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/messages/{message-id}/multiValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "messages", + "{message-id}", + "multiValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/messages/{message-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "messages", + "{message-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "singleValueExtendedProperties-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/messages/{message-id}/singleValueExtendedProperties", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "messages", + "{message-id}", + "singleValueExtendedProperties" + ] + } + } + }, + { + "name": "oauth2PermissionGrants-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/oauth2PermissionGrants", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "oauth2PermissionGrants" + ] + } + } + }, + { + "name": "$ref-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/oauth2PermissionGrants/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "oauth2PermissionGrants", + "$ref" + ] + } + } + }, + { + "name": "$ref-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/oauth2PermissionGrants/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "oauth2PermissionGrants", + "$ref" + ] + } + } + }, + { + "name": "onenote-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote" + ] + } + } + }, + { + "name": "onenote-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote" + ] + } + } + }, + { + "name": "onenote-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote" + ] + } + } + }, + { + "name": "notebooks-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks" + ] + } + } + }, + { + "name": "notebooks-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks" + ] + } + } + }, + { + "name": "{notebook-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}" + ] + } + } + }, + { + "name": "{notebook-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}" + ] + } + } + }, + { + "name": "{notebook-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}" + ] + } + } + }, + { + "name": "sectionGroups-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups" + ] + } + } + }, + { + "name": "sectionGroups-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups" + ] + } + } + }, + { + "name": "{sectionGroup-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "{sectionGroup-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "{sectionGroup-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentSectionGroup-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "sectionGroups-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups" + ] + } + } + }, + { + "name": "sectionGroups-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "sections-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections" + ] + } + } + }, + { + "name": "sections-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections" + ] + } + } + }, + { + "name": "{onenoteSection-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "{onenoteSection-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "{onenoteSection-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "pages-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages" + ] + } + } + }, + { + "name": "pages-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages" + ] + } + } + }, + { + "name": "{onenotePage-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}" + ] + } + } + }, + { + "name": "{onenotePage-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}" + ] + } + } + }, + { + "name": "{onenotePage-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}" + ] + } + } + }, + { + "name": "content-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "content" + ] + } + } + }, + { + "name": "content-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "content" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentSection-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentSection", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentSection" + ] + } + } + }, + { + "name": "parentSection-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentSection", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentSection" + ] + } + } + }, + { + "name": "parentSection-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentSection", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentSection" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentSectionGroup-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "sections-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections" + ] + } + } + }, + { + "name": "sections-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections" + ] + } + } + }, + { + "name": "{onenoteSection-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "{onenoteSection-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "{onenoteSection-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "pages-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/pages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "pages" + ] + } + } + }, + { + "name": "pages-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/pages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "pages" + ] + } + } + }, + { + "name": "{onenotePage-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}" + ] + } + } + }, + { + "name": "{onenotePage-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}" + ] + } + } + }, + { + "name": "{onenotePage-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}" + ] + } + } + }, + { + "name": "content-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "content" + ] + } + } + }, + { + "name": "content-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "content" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentSection-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentSection", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentSection" + ] + } + } + }, + { + "name": "parentSection-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentSection", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentSection" + ] + } + } + }, + { + "name": "parentSection-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentSection", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentSection" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentSectionGroup-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentNotebook" + ] + } + } + }, + { + "name": "parentSectionGroup-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentSectionGroup" + ] + } + } + }, + { + "name": "sectionGroups-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sectionGroups" + ] + } + } + }, + { + "name": "sectionGroups-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sectionGroups" + ] + } + } + }, + { + "name": "{sectionGroup-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "{sectionGroup-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "{sectionGroup-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "sections-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sections" + ] + } + } + }, + { + "name": "sections-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sections" + ] + } + } + }, + { + "name": "{onenoteSection-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup/sections/{onenoteSection-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sections", + "{onenoteSection-id1}" + ] + } + } + }, + { + "name": "{onenoteSection-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup/sections/{onenoteSection-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sections", + "{onenoteSection-id1}" + ] + } + } + }, + { + "name": "{onenoteSection-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/notebooks/{notebook-id}/sections/{onenoteSection-id}/parentSectionGroup/sections/{onenoteSection-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "notebooks", + "{notebook-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sections", + "{onenoteSection-id1}" + ] + } + } + }, + { + "name": "operations-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/operations", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "operations" + ] + } + } + }, + { + "name": "operations-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/operations", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "operations" + ] + } + } + }, + { + "name": "{onenoteOperation-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/operations/{onenoteOperation-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "operations", + "{onenoteOperation-id}" + ] + } + } + }, + { + "name": "{onenoteOperation-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/operations/{onenoteOperation-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "operations", + "{onenoteOperation-id}" + ] + } + } + }, + { + "name": "{onenoteOperation-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/operations/{onenoteOperation-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "operations", + "{onenoteOperation-id}" + ] + } + } + }, + { + "name": "pages-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages" + ] + } + } + }, + { + "name": "pages-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages" + ] + } + } + }, + { + "name": "{onenotePage-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}" + ] + } + } + }, + { + "name": "{onenotePage-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}" + ] + } + } + }, + { + "name": "{onenotePage-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}" + ] + } + } + }, + { + "name": "content-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "content" + ] + } + } + }, + { + "name": "content-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "content" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "sectionGroups-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups" + ] + } + } + }, + { + "name": "sectionGroups-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups" + ] + } + } + }, + { + "name": "{sectionGroup-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "{sectionGroup-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "{sectionGroup-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentSectionGroup-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "sectionGroups-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups" + ] + } + } + }, + { + "name": "sectionGroups-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "sections-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections" + ] + } + } + }, + { + "name": "sections-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections" + ] + } + } + }, + { + "name": "{onenoteSection-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "{onenoteSection-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "{onenoteSection-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "pages-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages" + ] + } + } + }, + { + "name": "pages-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages" + ] + } + } + }, + { + "name": "{onenotePage-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id1}" + ] + } + } + }, + { + "name": "{onenotePage-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id1}" + ] + } + } + }, + { + "name": "{onenotePage-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id1}" + ] + } + } + }, + { + "name": "content-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id1}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id1}", + "content" + ] + } + } + }, + { + "name": "content-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id1}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id1}", + "content" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentSectionGroup-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "sections-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections" + ] + } + } + }, + { + "name": "sections-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections" + ] + } + } + }, + { + "name": "{onenoteSection-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "{onenoteSection-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "{onenoteSection-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "pages-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/pages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages" + ] + } + } + }, + { + "name": "pages-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/pages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages" + ] + } + } + }, + { + "name": "{onenotePage-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/pages/{onenotePage-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id1}" + ] + } + } + }, + { + "name": "{onenotePage-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/pages/{onenotePage-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id1}" + ] + } + } + }, + { + "name": "{onenotePage-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/pages/{onenotePage-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id1}" + ] + } + } + }, + { + "name": "content-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/pages/{onenotePage-id1}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id1}", + "content" + ] + } + } + }, + { + "name": "content-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/pages/{onenotePage-id1}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id1}", + "content" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentSectionGroup-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentNotebook" + ] + } + } + }, + { + "name": "parentSectionGroup-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentSectionGroup" + ] + } + } + }, + { + "name": "sectionGroups-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sectionGroups" + ] + } + } + }, + { + "name": "sectionGroups-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sectionGroups" + ] + } + } + }, + { + "name": "{sectionGroup-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "{sectionGroup-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "{sectionGroup-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "sections-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sections" + ] + } + } + }, + { + "name": "sections-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sections" + ] + } + } + }, + { + "name": "{onenoteSection-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup/sections/{onenoteSection-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sections", + "{onenoteSection-id1}" + ] + } + } + }, + { + "name": "{onenoteSection-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup/sections/{onenoteSection-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sections", + "{onenoteSection-id1}" + ] + } + } + }, + { + "name": "{onenoteSection-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id}/parentSectionGroup/sections/{onenoteSection-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sections", + "{onenoteSection-id1}" + ] + } + } + }, + { + "name": "parentSection-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection" + ] + } + } + }, + { + "name": "parentSection-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection" + ] + } + } + }, + { + "name": "parentSection-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection" + ] + } + } + }, + { + "name": "pages-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/pages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "pages" + ] + } + } + }, + { + "name": "pages-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/pages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "pages" + ] + } + } + }, + { + "name": "{onenotePage-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/pages/{onenotePage-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "pages", + "{onenotePage-id1}" + ] + } + } + }, + { + "name": "{onenotePage-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/pages/{onenotePage-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "pages", + "{onenotePage-id1}" + ] + } + } + }, + { + "name": "{onenotePage-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/pages/{onenotePage-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "pages", + "{onenotePage-id1}" + ] + } + } + }, + { + "name": "content-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/pages/{onenotePage-id1}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "pages", + "{onenotePage-id1}", + "content" + ] + } + } + }, + { + "name": "content-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/pages/{onenotePage-id1}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "pages", + "{onenotePage-id1}", + "content" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook" + ] + } + } + }, + { + "name": "sectionGroups-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups" + ] + } + } + }, + { + "name": "sectionGroups-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups" + ] + } + } + }, + { + "name": "{sectionGroup-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "{sectionGroup-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "{sectionGroup-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentSectionGroup-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "sectionGroups-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups" + ] + } + } + }, + { + "name": "sectionGroups-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "sections-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections" + ] + } + } + }, + { + "name": "sections-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections" + ] + } + } + }, + { + "name": "{onenoteSection-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "{onenoteSection-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "{onenoteSection-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "sections-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sections" + ] + } + } + }, + { + "name": "sections-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentNotebook/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentNotebook", + "sections" + ] + } + } + }, + { + "name": "parentSectionGroup-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup", + "parentNotebook" + ] + } + } + }, + { + "name": "sectionGroups-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup/parentNotebook/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup", + "parentNotebook", + "sectionGroups" + ] + } + } + }, + { + "name": "sectionGroups-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup/parentNotebook/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup", + "parentNotebook", + "sectionGroups" + ] + } + } + }, + { + "name": "sections-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup/parentNotebook/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup", + "parentNotebook", + "sections" + ] + } + } + }, + { + "name": "sections-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup/parentNotebook/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup", + "parentNotebook", + "sections" + ] + } + } + }, + { + "name": "parentSectionGroup-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup", + "parentSectionGroup" + ] + } + } + }, + { + "name": "sectionGroups-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup", + "sectionGroups" + ] + } + } + }, + { + "name": "sectionGroups-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup", + "sectionGroups" + ] + } + } + }, + { + "name": "sections-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup", + "sections" + ] + } + } + }, + { + "name": "sections-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/pages/{onenotePage-id}/parentSection/parentSectionGroup/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "pages", + "{onenotePage-id}", + "parentSection", + "parentSectionGroup", + "sections" + ] + } + } + }, + { + "name": "resources-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/resources", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "resources" + ] + } + } + }, + { + "name": "resources-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/resources", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "resources" + ] + } + } + }, + { + "name": "{onenoteResource-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/resources/{onenoteResource-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "resources", + "{onenoteResource-id}" + ] + } + } + }, + { + "name": "{onenoteResource-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/resources/{onenoteResource-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "resources", + "{onenoteResource-id}" + ] + } + } + }, + { + "name": "{onenoteResource-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/resources/{onenoteResource-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "resources", + "{onenoteResource-id}" + ] + } + } + }, + { + "name": "content-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/resources/{onenoteResource-id}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "resources", + "{onenoteResource-id}", + "content" + ] + } + } + }, + { + "name": "content-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/resources/{onenoteResource-id}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "resources", + "{onenoteResource-id}", + "content" + ] + } + } + }, + { + "name": "sectionGroups-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups" + ] + } + } + }, + { + "name": "sectionGroups-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups" + ] + } + } + }, + { + "name": "{sectionGroup-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "{sectionGroup-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "{sectionGroup-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "{onenotePage-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook/sections/{onenoteSection-id}/pages/{onenotePage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}" + ] + } + } + }, + { + "name": "{onenotePage-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook/sections/{onenoteSection-id}/pages/{onenotePage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}" + ] + } + } + }, + { + "name": "{onenotePage-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook/sections/{onenoteSection-id}/pages/{onenotePage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}" + ] + } + } + }, + { + "name": "content-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook/sections/{onenoteSection-id}/pages/{onenotePage-id}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "content" + ] + } + } + }, + { + "name": "content-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook/sections/{onenoteSection-id}/pages/{onenotePage-id}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "content" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentSection-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentSection", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentSection" + ] + } + } + }, + { + "name": "parentSection-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentSection", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentSection" + ] + } + } + }, + { + "name": "parentSection-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentNotebook/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentSection", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentSection" + ] + } + } + }, + { + "name": "parentSectionGroup-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "sectionGroups-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups" + ] + } + } + }, + { + "name": "sectionGroups-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "sections-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sections" + ] + } + } + }, + { + "name": "sections-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sections" + ] + } + } + }, + { + "name": "sectionGroups-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups" + ] + } + } + }, + { + "name": "sectionGroups-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "{sectionGroup-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id1}" + ] + } + } + }, + { + "name": "sections-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections" + ] + } + } + }, + { + "name": "sections-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections" + ] + } + } + }, + { + "name": "{onenoteSection-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id1}" + ] + } + } + }, + { + "name": "{onenoteSection-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id1}" + ] + } + } + }, + { + "name": "{onenoteSection-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sectionGroups/{sectionGroup-id}/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sections/{onenoteSection-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sectionGroups", + "{sectionGroup-id}", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sections", + "{onenoteSection-id1}" + ] + } + } + }, + { + "name": "sections-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections" + ] + } + } + }, + { + "name": "sections-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections" + ] + } + } + }, + { + "name": "{onenoteSection-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "{onenoteSection-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "{onenoteSection-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}" + ] + } + } + }, + { + "name": "pages-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages" + ] + } + } + }, + { + "name": "pages-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages" + ] + } + } + }, + { + "name": "{onenotePage-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}" + ] + } + } + }, + { + "name": "{onenotePage-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}" + ] + } + } + }, + { + "name": "{onenotePage-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}" + ] + } + } + }, + { + "name": "content-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "content" + ] + } + } + }, + { + "name": "content-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "content" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentSectionGroup-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "sectionGroups-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups" + ] + } + } + }, + { + "name": "sectionGroups-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sectionGroups" + ] + } + } + }, + { + "name": "sections-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections" + ] + } + } + }, + { + "name": "sections-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentNotebook/sectionGroups/{sectionGroup-id}/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentNotebook", + "sectionGroups", + "{sectionGroup-id}", + "sections" + ] + } + } + }, + { + "name": "parentSection-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentSection", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentSection" + ] + } + } + }, + { + "name": "parentSection-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentSection", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentSection" + ] + } + } + }, + { + "name": "parentSection-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/pages/{onenotePage-id}/parentSection", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "pages", + "{onenotePage-id}", + "parentSection" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentNotebook" + ] + } + } + }, + { + "name": "{onenoteSection-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentNotebook/sections/{onenoteSection-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentNotebook", + "sections", + "{onenoteSection-id1}" + ] + } + } + }, + { + "name": "{onenoteSection-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentNotebook/sections/{onenoteSection-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentNotebook", + "sections", + "{onenoteSection-id1}" + ] + } + } + }, + { + "name": "{onenoteSection-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentNotebook/sections/{onenoteSection-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentNotebook", + "sections", + "{onenoteSection-id1}" + ] + } + } + }, + { + "name": "parentSectionGroup-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentNotebook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentSectionGroup/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentSectionGroup/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentNotebook" + ] + } + } + }, + { + "name": "parentNotebook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentSectionGroup/parentNotebook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentNotebook" + ] + } + } + }, + { + "name": "{onenoteSection-id1}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentSectionGroup/parentNotebook/sections/{onenoteSection-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentNotebook", + "sections", + "{onenoteSection-id1}" + ] + } + } + }, + { + "name": "{onenoteSection-id1}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentSectionGroup/parentNotebook/sections/{onenoteSection-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentNotebook", + "sections", + "{onenoteSection-id1}" + ] + } + } + }, + { + "name": "{onenoteSection-id1}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentSectionGroup/parentNotebook/sections/{onenoteSection-id1}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentNotebook", + "sections", + "{onenoteSection-id1}" + ] + } + } + }, + { + "name": "parentSectionGroup-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentSectionGroup/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentSectionGroup/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentSectionGroup" + ] + } + } + }, + { + "name": "parentSectionGroup-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentSectionGroup/parentSectionGroup", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "parentSectionGroup" + ] + } + } + }, + { + "name": "sectionGroups-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentSectionGroup/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sectionGroups" + ] + } + } + }, + { + "name": "sectionGroups-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentSectionGroup/sectionGroups", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sectionGroups" + ] + } + } + }, + { + "name": "sections-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentSectionGroup/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sections" + ] + } + } + }, + { + "name": "sections-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onenote/sections/{onenoteSection-id}/parentSectionGroup/sections", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onenote", + "sections", + "{onenoteSection-id}", + "parentSectionGroup", + "sections" + ] + } + } + }, + { + "name": "onlineMeetings-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onlineMeetings", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onlineMeetings" + ] + } + } + }, + { + "name": "onlineMeetings-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onlineMeetings", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onlineMeetings" + ] + } + } + }, + { + "name": "{onlineMeeting-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onlineMeetings/{onlineMeeting-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onlineMeetings", + "{onlineMeeting-id}" + ] + } + } + }, + { + "name": "{onlineMeeting-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onlineMeetings/{onlineMeeting-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onlineMeetings", + "{onlineMeeting-id}" + ] + } + } + }, + { + "name": "{onlineMeeting-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onlineMeetings/{onlineMeeting-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onlineMeetings", + "{onlineMeeting-id}" + ] + } + } + }, + { + "name": "attendeeReport-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onlineMeetings/{onlineMeeting-id}/attendeeReport", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onlineMeetings", + "{onlineMeeting-id}", + "attendeeReport" + ] + } + } + }, + { + "name": "attendeeReport-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/onlineMeetings/{onlineMeeting-id}/attendeeReport", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "onlineMeetings", + "{onlineMeeting-id}", + "attendeeReport" + ] + } + } + }, + { + "name": "outlook-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/outlook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "outlook" + ] + } + } + }, + { + "name": "outlook-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/outlook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "outlook" + ] + } + } + }, + { + "name": "outlook-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/outlook", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "outlook" + ] + } + } + }, + { + "name": "masterCategories-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/outlook/masterCategories", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "outlook", + "masterCategories" + ] + } + } + }, + { + "name": "masterCategories-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/outlook/masterCategories", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "outlook", + "masterCategories" + ] + } + } + }, + { + "name": "{outlookCategory-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/outlook/masterCategories/{outlookCategory-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "outlook", + "masterCategories", + "{outlookCategory-id}" + ] + } + } + }, + { + "name": "{outlookCategory-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/outlook/masterCategories/{outlookCategory-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "outlook", + "masterCategories", + "{outlookCategory-id}" + ] + } + } + }, + { + "name": "{outlookCategory-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/outlook/masterCategories/{outlookCategory-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "outlook", + "masterCategories", + "{outlookCategory-id}" + ] + } + } + }, + { + "name": "ownedDevices-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/ownedDevices", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "ownedDevices" + ] + } + } + }, + { + "name": "$ref-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/ownedDevices/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "ownedDevices", + "$ref" + ] + } + } + }, + { + "name": "$ref-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/ownedDevices/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "ownedDevices", + "$ref" + ] + } + } + }, + { + "name": "ownedObjects-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/ownedObjects", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "ownedObjects" + ] + } + } + }, + { + "name": "$ref-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/ownedObjects/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "ownedObjects", + "$ref" + ] + } + } + }, + { + "name": "$ref-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/ownedObjects/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "ownedObjects", + "$ref" + ] + } + } + }, + { + "name": "people-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/people", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "people" + ] + } + } + }, + { + "name": "people-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/people", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "people" + ] + } + } + }, + { + "name": "{person-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/people/{person-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "people", + "{person-id}" + ] + } + } + }, + { + "name": "{person-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/people/{person-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "people", + "{person-id}" + ] + } + } + }, + { + "name": "{person-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/people/{person-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "people", + "{person-id}" + ] + } + } + }, + { + "name": "photo-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/photo", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "photo" + ] + } + } + }, + { + "name": "photo-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/photo", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "photo" + ] + } + } + }, + { + "name": "photo-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/photo", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "photo" + ] + } + } + }, + { + "name": "$value-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/photo/$value", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "photo", + "$value" + ] + } + } + }, + { + "name": "$value-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/photo/$value", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "photo", + "$value" + ] + } + } + }, + { + "name": "photos-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/photos", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "photos" + ] + } + } + }, + { + "name": "photos-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/photos", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "photos" + ] + } + } + }, + { + "name": "{profilePhoto-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/photos/{profilePhoto-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "photos", + "{profilePhoto-id}" + ] + } + } + }, + { + "name": "{profilePhoto-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/photos/{profilePhoto-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "photos", + "{profilePhoto-id}" + ] + } + } + }, + { + "name": "{profilePhoto-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/photos/{profilePhoto-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "photos", + "{profilePhoto-id}" + ] + } + } + }, + { + "name": "$value-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/photos/{profilePhoto-id}/$value", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "photos", + "{profilePhoto-id}", + "$value" + ] + } + } + }, + { + "name": "$value-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/photos/{profilePhoto-id}/$value", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "photos", + "{profilePhoto-id}", + "$value" + ] + } + } + }, + { + "name": "planner-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner" + ] + } + } + }, + { + "name": "planner-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner" + ] + } + } + }, + { + "name": "planner-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner" + ] + } + } + }, + { + "name": "plans-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans" + ] + } + } + }, + { + "name": "plans-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans" + ] + } + } + }, + { + "name": "{plannerPlan-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}" + ] + } + } + }, + { + "name": "{plannerPlan-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}" + ] + } + } + }, + { + "name": "{plannerPlan-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}" + ] + } + } + }, + { + "name": "buckets-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets" + ] + } + } + }, + { + "name": "buckets-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets" + ] + } + } + }, + { + "name": "{plannerBucket-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}" + ] + } + } + }, + { + "name": "{plannerBucket-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}" + ] + } + } + }, + { + "name": "{plannerBucket-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}" + ] + } + } + }, + { + "name": "tasks-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks" + ] + } + } + }, + { + "name": "tasks-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks" + ] + } + } + }, + { + "name": "{plannerTask-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks/{plannerTask-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks", + "{plannerTask-id}" + ] + } + } + }, + { + "name": "{plannerTask-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks/{plannerTask-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks", + "{plannerTask-id}" + ] + } + } + }, + { + "name": "{plannerTask-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks/{plannerTask-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks", + "{plannerTask-id}" + ] + } + } + }, + { + "name": "assignedToTaskBoardFormat-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks/{plannerTask-id}/assignedToTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks", + "{plannerTask-id}", + "assignedToTaskBoardFormat" + ] + } + } + }, + { + "name": "assignedToTaskBoardFormat-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks/{plannerTask-id}/assignedToTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks", + "{plannerTask-id}", + "assignedToTaskBoardFormat" + ] + } + } + }, + { + "name": "assignedToTaskBoardFormat-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks/{plannerTask-id}/assignedToTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks", + "{plannerTask-id}", + "assignedToTaskBoardFormat" + ] + } + } + }, + { + "name": "bucketTaskBoardFormat-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks/{plannerTask-id}/bucketTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks", + "{plannerTask-id}", + "bucketTaskBoardFormat" + ] + } + } + }, + { + "name": "bucketTaskBoardFormat-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks/{plannerTask-id}/bucketTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks", + "{plannerTask-id}", + "bucketTaskBoardFormat" + ] + } + } + }, + { + "name": "bucketTaskBoardFormat-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks/{plannerTask-id}/bucketTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks", + "{plannerTask-id}", + "bucketTaskBoardFormat" + ] + } + } + }, + { + "name": "details-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks/{plannerTask-id}/details", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks", + "{plannerTask-id}", + "details" + ] + } + } + }, + { + "name": "details-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks/{plannerTask-id}/details", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks", + "{plannerTask-id}", + "details" + ] + } + } + }, + { + "name": "details-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks/{plannerTask-id}/details", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks", + "{plannerTask-id}", + "details" + ] + } + } + }, + { + "name": "progressTaskBoardFormat-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks/{plannerTask-id}/progressTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks", + "{plannerTask-id}", + "progressTaskBoardFormat" + ] + } + } + }, + { + "name": "progressTaskBoardFormat-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks/{plannerTask-id}/progressTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks", + "{plannerTask-id}", + "progressTaskBoardFormat" + ] + } + } + }, + { + "name": "progressTaskBoardFormat-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/buckets/{plannerBucket-id}/tasks/{plannerTask-id}/progressTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "buckets", + "{plannerBucket-id}", + "tasks", + "{plannerTask-id}", + "progressTaskBoardFormat" + ] + } + } + }, + { + "name": "details-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/details", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "details" + ] + } + } + }, + { + "name": "details-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/details", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "details" + ] + } + } + }, + { + "name": "details-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/details", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "details" + ] + } + } + }, + { + "name": "tasks-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks" + ] + } + } + }, + { + "name": "tasks-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks" + ] + } + } + }, + { + "name": "{plannerTask-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks/{plannerTask-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks", + "{plannerTask-id}" + ] + } + } + }, + { + "name": "{plannerTask-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks/{plannerTask-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks", + "{plannerTask-id}" + ] + } + } + }, + { + "name": "{plannerTask-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks/{plannerTask-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks", + "{plannerTask-id}" + ] + } + } + }, + { + "name": "assignedToTaskBoardFormat-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks/{plannerTask-id}/assignedToTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks", + "{plannerTask-id}", + "assignedToTaskBoardFormat" + ] + } + } + }, + { + "name": "assignedToTaskBoardFormat-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks/{plannerTask-id}/assignedToTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks", + "{plannerTask-id}", + "assignedToTaskBoardFormat" + ] + } + } + }, + { + "name": "assignedToTaskBoardFormat-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks/{plannerTask-id}/assignedToTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks", + "{plannerTask-id}", + "assignedToTaskBoardFormat" + ] + } + } + }, + { + "name": "bucketTaskBoardFormat-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks/{plannerTask-id}/bucketTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks", + "{plannerTask-id}", + "bucketTaskBoardFormat" + ] + } + } + }, + { + "name": "bucketTaskBoardFormat-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks/{plannerTask-id}/bucketTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks", + "{plannerTask-id}", + "bucketTaskBoardFormat" + ] + } + } + }, + { + "name": "bucketTaskBoardFormat-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks/{plannerTask-id}/bucketTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks", + "{plannerTask-id}", + "bucketTaskBoardFormat" + ] + } + } + }, + { + "name": "details-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks/{plannerTask-id}/details", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks", + "{plannerTask-id}", + "details" + ] + } + } + }, + { + "name": "details-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks/{plannerTask-id}/details", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks", + "{plannerTask-id}", + "details" + ] + } + } + }, + { + "name": "details-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks/{plannerTask-id}/details", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks", + "{plannerTask-id}", + "details" + ] + } + } + }, + { + "name": "progressTaskBoardFormat-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks/{plannerTask-id}/progressTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks", + "{plannerTask-id}", + "progressTaskBoardFormat" + ] + } + } + }, + { + "name": "progressTaskBoardFormat-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks/{plannerTask-id}/progressTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks", + "{plannerTask-id}", + "progressTaskBoardFormat" + ] + } + } + }, + { + "name": "progressTaskBoardFormat-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/plans/{plannerPlan-id}/tasks/{plannerTask-id}/progressTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "plans", + "{plannerPlan-id}", + "tasks", + "{plannerTask-id}", + "progressTaskBoardFormat" + ] + } + } + }, + { + "name": "tasks-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks" + ] + } + } + }, + { + "name": "tasks-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks" + ] + } + } + }, + { + "name": "{plannerTask-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks/{plannerTask-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks", + "{plannerTask-id}" + ] + } + } + }, + { + "name": "{plannerTask-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks/{plannerTask-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks", + "{plannerTask-id}" + ] + } + } + }, + { + "name": "{plannerTask-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks/{plannerTask-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks", + "{plannerTask-id}" + ] + } + } + }, + { + "name": "assignedToTaskBoardFormat-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks/{plannerTask-id}/assignedToTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks", + "{plannerTask-id}", + "assignedToTaskBoardFormat" + ] + } + } + }, + { + "name": "assignedToTaskBoardFormat-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks/{plannerTask-id}/assignedToTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks", + "{plannerTask-id}", + "assignedToTaskBoardFormat" + ] + } + } + }, + { + "name": "assignedToTaskBoardFormat-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks/{plannerTask-id}/assignedToTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks", + "{plannerTask-id}", + "assignedToTaskBoardFormat" + ] + } + } + }, + { + "name": "bucketTaskBoardFormat-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks/{plannerTask-id}/bucketTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks", + "{plannerTask-id}", + "bucketTaskBoardFormat" + ] + } + } + }, + { + "name": "bucketTaskBoardFormat-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks/{plannerTask-id}/bucketTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks", + "{plannerTask-id}", + "bucketTaskBoardFormat" + ] + } + } + }, + { + "name": "bucketTaskBoardFormat-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks/{plannerTask-id}/bucketTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks", + "{plannerTask-id}", + "bucketTaskBoardFormat" + ] + } + } + }, + { + "name": "details-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks/{plannerTask-id}/details", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks", + "{plannerTask-id}", + "details" + ] + } + } + }, + { + "name": "details-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks/{plannerTask-id}/details", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks", + "{plannerTask-id}", + "details" + ] + } + } + }, + { + "name": "details-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks/{plannerTask-id}/details", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks", + "{plannerTask-id}", + "details" + ] + } + } + }, + { + "name": "progressTaskBoardFormat-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks/{plannerTask-id}/progressTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks", + "{plannerTask-id}", + "progressTaskBoardFormat" + ] + } + } + }, + { + "name": "progressTaskBoardFormat-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks/{plannerTask-id}/progressTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks", + "{plannerTask-id}", + "progressTaskBoardFormat" + ] + } + } + }, + { + "name": "progressTaskBoardFormat-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/planner/tasks/{plannerTask-id}/progressTaskBoardFormat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "planner", + "tasks", + "{plannerTask-id}", + "progressTaskBoardFormat" + ] + } + } + }, + { + "name": "presence-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/presence", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "presence" + ] + } + } + }, + { + "name": "presence-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/presence", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "presence" + ] + } + } + }, + { + "name": "presence-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/presence", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "presence" + ] + } + } + }, + { + "name": "registeredDevices-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/registeredDevices", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "registeredDevices" + ] + } + } + }, + { + "name": "$ref-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/registeredDevices/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "registeredDevices", + "$ref" + ] + } + } + }, + { + "name": "$ref-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/registeredDevices/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "registeredDevices", + "$ref" + ] + } + } + }, + { + "name": "scopedRoleMemberOf-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/scopedRoleMemberOf", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "scopedRoleMemberOf" + ] + } + } + }, + { + "name": "scopedRoleMemberOf-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/scopedRoleMemberOf", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "scopedRoleMemberOf" + ] + } + } + }, + { + "name": "{scopedRoleMembership-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/scopedRoleMemberOf/{scopedRoleMembership-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "scopedRoleMemberOf", + "{scopedRoleMembership-id}" + ] + } + } + }, + { + "name": "{scopedRoleMembership-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/scopedRoleMemberOf/{scopedRoleMembership-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "scopedRoleMemberOf", + "{scopedRoleMembership-id}" + ] + } + } + }, + { + "name": "{scopedRoleMembership-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/scopedRoleMemberOf/{scopedRoleMembership-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "scopedRoleMemberOf", + "{scopedRoleMembership-id}" + ] + } + } + }, + { + "name": "settings-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/settings", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "settings" + ] + } + } + }, + { + "name": "settings-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/settings", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "settings" + ] + } + } + }, + { + "name": "settings-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/settings", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "settings" + ] + } + } + }, + { + "name": "shiftPreferences-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/settings/shiftPreferences", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "settings", + "shiftPreferences" + ] + } + } + }, + { + "name": "shiftPreferences-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/settings/shiftPreferences", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "settings", + "shiftPreferences" + ] + } + } + }, + { + "name": "shiftPreferences-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/settings/shiftPreferences", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "settings", + "shiftPreferences" + ] + } + } + }, + { + "name": "teamwork-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/teamwork", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "teamwork" + ] + } + } + }, + { + "name": "teamwork-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/teamwork", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "teamwork" + ] + } + } + }, + { + "name": "teamwork-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/teamwork", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "teamwork" + ] + } + } + }, + { + "name": "installedApps-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/teamwork/installedApps", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "teamwork", + "installedApps" + ] + } + } + }, + { + "name": "installedApps-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/teamwork/installedApps", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "teamwork", + "installedApps" + ] + } + } + }, + { + "name": "{userScopeTeamsAppInstallation-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/teamwork/installedApps/{userScopeTeamsAppInstallation-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "teamwork", + "installedApps", + "{userScopeTeamsAppInstallation-id}" + ] + } + } + }, + { + "name": "{userScopeTeamsAppInstallation-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/teamwork/installedApps/{userScopeTeamsAppInstallation-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "teamwork", + "installedApps", + "{userScopeTeamsAppInstallation-id}" + ] + } + } + }, + { + "name": "{userScopeTeamsAppInstallation-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/teamwork/installedApps/{userScopeTeamsAppInstallation-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "teamwork", + "installedApps", + "{userScopeTeamsAppInstallation-id}" + ] + } + } + }, + { + "name": "chat-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/teamwork/installedApps/{userScopeTeamsAppInstallation-id}/chat", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "teamwork", + "installedApps", + "{userScopeTeamsAppInstallation-id}", + "chat" + ] + } + } + }, + { + "name": "$ref-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/teamwork/installedApps/{userScopeTeamsAppInstallation-id}/chat/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "teamwork", + "installedApps", + "{userScopeTeamsAppInstallation-id}", + "chat", + "$ref" + ] + } + } + }, + { + "name": "$ref-PUT", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/teamwork/installedApps/{userScopeTeamsAppInstallation-id}/chat/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "teamwork", + "installedApps", + "{userScopeTeamsAppInstallation-id}", + "chat", + "$ref" + ] + } + } + }, + { + "name": "$ref-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/teamwork/installedApps/{userScopeTeamsAppInstallation-id}/chat/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "teamwork", + "installedApps", + "{userScopeTeamsAppInstallation-id}", + "chat", + "$ref" + ] + } + } + }, + { + "name": "todo-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo" + ] + } + } + }, + { + "name": "todo-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo" + ] + } + } + }, + { + "name": "todo-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo" + ] + } + } + }, + { + "name": "lists-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists" + ] + } + } + }, + { + "name": "lists-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists" + ] + } + } + }, + { + "name": "{todoTaskList-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}" + ] + } + } + }, + { + "name": "{todoTaskList-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}" + ] + } + } + }, + { + "name": "{todoTaskList-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}" + ] + } + } + }, + { + "name": "extensions-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "extensions" + ] + } + } + }, + { + "name": "extensions-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "extensions" + ] + } + } + }, + { + "name": "tasks-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/tasks", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "tasks" + ] + } + } + }, + { + "name": "tasks-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/tasks", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "tasks" + ] + } + } + }, + { + "name": "{todoTask-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "tasks", + "{todoTask-id}" + ] + } + } + }, + { + "name": "{todoTask-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "tasks", + "{todoTask-id}" + ] + } + } + }, + { + "name": "{todoTask-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "tasks", + "{todoTask-id}" + ] + } + } + }, + { + "name": "extensions-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "tasks", + "{todoTask-id}", + "extensions" + ] + } + } + }, + { + "name": "extensions-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}/extensions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "tasks", + "{todoTask-id}", + "extensions" + ] + } + } + }, + { + "name": "{extension-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "tasks", + "{todoTask-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "{extension-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "tasks", + "{todoTask-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "{extension-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}/extensions/{extension-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "tasks", + "{todoTask-id}", + "extensions", + "{extension-id}" + ] + } + } + }, + { + "name": "linkedResources-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}/linkedResources", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "tasks", + "{todoTask-id}", + "linkedResources" + ] + } + } + }, + { + "name": "linkedResources-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}/linkedResources", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "tasks", + "{todoTask-id}", + "linkedResources" + ] + } + } + }, + { + "name": "{linkedResource-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}/linkedResources/{linkedResource-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "tasks", + "{todoTask-id}", + "linkedResources", + "{linkedResource-id}" + ] + } + } + }, + { + "name": "{linkedResource-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}/linkedResources/{linkedResource-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "tasks", + "{todoTask-id}", + "linkedResources", + "{linkedResource-id}" + ] + } + } + }, + { + "name": "{linkedResource-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}/linkedResources/{linkedResource-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "todo", + "lists", + "{todoTaskList-id}", + "tasks", + "{todoTask-id}", + "linkedResources", + "{linkedResource-id}" + ] + } + } + }, + { + "name": "transitiveMemberOf-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/transitiveMemberOf", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "transitiveMemberOf" + ] + } + } + }, + { + "name": "$ref-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/transitiveMemberOf/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "transitiveMemberOf", + "$ref" + ] + } + } + }, + { + "name": "$ref-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}/transitiveMemberOf/$ref", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}", + "transitiveMemberOf", + "$ref" + ] + } + } + } + ] +} \ No newline at end of file From f0bfe017fc14e6cc08a1fd536782b52132e09af7 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 15 Dec 2021 00:49:08 +0300 Subject: [PATCH 109/288] Add server object --- .../OpenApiDocumentMock.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) rename test/Microsoft.OpenApi.Tests/{Documents => UtilityFiles}/OpenApiDocumentMock.cs (99%) diff --git a/test/Microsoft.OpenApi.Tests/Documents/OpenApiDocumentMock.cs b/test/Microsoft.OpenApi.Tests/UtilityFiles/OpenApiDocumentMock.cs similarity index 99% rename from test/Microsoft.OpenApi.Tests/Documents/OpenApiDocumentMock.cs rename to test/Microsoft.OpenApi.Tests/UtilityFiles/OpenApiDocumentMock.cs index 676bf8e65..d21fccb9a 100644 --- a/test/Microsoft.OpenApi.Tests/Documents/OpenApiDocumentMock.cs +++ b/test/Microsoft.OpenApi.Tests/UtilityFiles/OpenApiDocumentMock.cs @@ -1,12 +1,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System.Collections.Generic; +using System.Security.Policy; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; -using System.Collections.Generic; -namespace OpenAPIService.Test +namespace Microsoft.OpenApi.Tests.UtilityFiles { /// /// Mock class that creates a sample OpenAPI document. @@ -28,6 +29,13 @@ public static OpenApiDocument CreateOpenApiDocument() Title = "People", Version = "v1.0" }, + Servers = new List + { + new OpenApiServer + { + Url = "https://graph.microsoft.com/v1.0" + } + }, Paths = new OpenApiPaths() { ["/"] = new OpenApiPathItem() // root path @@ -723,7 +731,6 @@ public static OpenApiDocument CreateOpenApiDocument() } } }; - return document; } } From 3caa0bfc7253a8fc65da540daeb2d6886acafe3d Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 15 Dec 2021 00:50:16 +0300 Subject: [PATCH 110/288] Add unit tests for slicing based on postman collection --- .../Services/OpenApiFilterServiceTests.cs | 41 ++++++++++++++++++- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs index ab65ed744..4d6a25964 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs @@ -2,9 +2,10 @@ // Licensed under the MIT license. using System; +using System.IO; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Services; -using OpenAPIService.Test; +using Microsoft.OpenApi.Tests.UtilityFiles; using Xunit; namespace Microsoft.OpenApi.Tests.Services @@ -42,12 +43,48 @@ public void ReturnFilteredOpenApiDocumentBasedOnOperationIdsAndTags(string opera Assert.Equal(expectedPathCount, subsetOpenApiDocument.Paths.Count); } + [Fact] + public void ReturnFilteredOpenApiDocumentBasedOnPostmanCollection() + { + // Arrange + var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\postmanCollection_ver2.json"); + var fileInput = new FileInfo(filePath); + var stream = fileInput.OpenRead(); + + // Act + var requestUrls = OpenApiFilterService.ParseJsonCollectionFile(stream); + var predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source: _openApiDocumentMock); + var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(_openApiDocumentMock, predicate); + + // Assert + Assert.NotNull(subsetOpenApiDocument); + Assert.NotEmpty(subsetOpenApiDocument.Paths); + Assert.Equal(3, subsetOpenApiDocument.Paths.Count); + } + + [Fact] + public void ThrowsExceptionWhenUrlsInCollectionAreMissingFromSourceDocument() + { + // Arrange + var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\postmanCollection_ver1.json"); + var fileInput = new FileInfo(filePath); + var stream = fileInput.OpenRead(); + + // Act + var requestUrls = OpenApiFilterService.ParseJsonCollectionFile(stream); + + // Assert + var message = Assert.Throws(() => + OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source: _openApiDocumentMock)).Message; + Assert.Equal("The urls in the postman collection supplied could not be found.", message); + } + [Fact] public void ThrowsInvalidOperationExceptionInCreatePredicateWhenInvalidArgumentsArePassed() { // Act and Assert var message1 = Assert.Throws(() => OpenApiFilterService.CreatePredicate(null, null)).Message; - Assert.Equal("Either operationId(s) or tag(s) need to be specified.", message1); + Assert.Equal("Either operationId(s),tag(s) or postman collection need to be specified.", message1); var message2 = Assert.Throws(() => OpenApiFilterService.CreatePredicate("users.user.ListUser", "users.user")).Message; Assert.Equal("Cannot specify both operationIds and tags at the same time.", message2); From 62d0975d136f51e91564fe56850a7f22a6872957 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 15 Dec 2021 00:50:41 +0300 Subject: [PATCH 111/288] Update public Api text file --- .../PublicApi/PublicApi.approved.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 0b681a8ec..9971fb0f3 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -956,8 +956,10 @@ namespace Microsoft.OpenApi.Services } public static class OpenApiFilterService { - public static Microsoft.OpenApi.Models.OpenApiDocument CreateFilteredDocument(Microsoft.OpenApi.Models.OpenApiDocument source, System.Func predicate) { } - public static System.Func CreatePredicate(string operationIds = null, string tags = null) { } + public static Microsoft.OpenApi.Models.OpenApiDocument CreateFilteredDocument(Microsoft.OpenApi.Models.OpenApiDocument source, System.Func predicate) { } + public static Microsoft.OpenApi.Services.OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(System.Collections.Generic.Dictionary sources) { } + public static System.Func CreatePredicate(string operationIds = null, string tags = null, System.Collections.Generic.Dictionary> requestUrls = null, Microsoft.OpenApi.Models.OpenApiDocument source = null) { } + public static System.Collections.Generic.Dictionary> ParseJsonCollectionFile(System.IO.Stream stream) { } } public class OpenApiReferenceError : Microsoft.OpenApi.Models.OpenApiError { @@ -1051,7 +1053,7 @@ namespace Microsoft.OpenApi.Services } public class OperationSearch : Microsoft.OpenApi.Services.OpenApiVisitorBase { - public OperationSearch(System.Func predicate) { } + public OperationSearch(System.Func predicate) { } public System.Collections.Generic.IList SearchResults { get; } public override void Visit(Microsoft.OpenApi.Models.OpenApiOperation operation) { } public override void Visit(System.Collections.Generic.IList parameters) { } From 6657430303b2f35673b6f213321e931b9d82be53 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 15 Dec 2021 02:50:25 +0000 Subject: [PATCH 112/288] Bump mathieudutour/github-tag-action from 5.4 to 6.0 Bumps [mathieudutour/github-tag-action](https://github.com/mathieudutour/github-tag-action) from 5.4 to 6.0. - [Release notes](https://github.com/mathieudutour/github-tag-action/releases) - [Commits](https://github.com/mathieudutour/github-tag-action/compare/v5.4...v6.0) --- updated-dependencies: - dependency-name: mathieudutour/github-tag-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 7afeeebed..610134cd0 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -49,7 +49,7 @@ jobs: - if: steps.conditionals_handler.outputs.is_default_branch == 'true' name: Bump GH tag id: tag_generator - uses: mathieudutour/github-tag-action@v5.4 + uses: mathieudutour/github-tag-action@v6.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} default_bump: false From 640e7dc3462654e072ad0621b15fd37ff692457a Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 16 Dec 2021 18:37:59 +0300 Subject: [PATCH 113/288] Remove redundant () --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index aefa5cd4f..0c7f5601a 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.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; @@ -118,7 +118,7 @@ public static OpenApiDocument CreateFilteredDocument(OpenApiDocument source, Fun // Fetch and copy title, graphVersion and server info from OpenApiDoc var subset = new OpenApiDocument { - Info = new OpenApiInfo() + Info = new OpenApiInfo { Title = source.Info.Title + " - Subset", Description = source.Info.Description, @@ -209,7 +209,7 @@ public static Dictionary> ParseJsonCollectionFile(Stream st if (!requestUrls.ContainsKey(path)) { - requestUrls.Add(path, new List() { method }); + requestUrls.Add(path, new List { method }); } else { From e555680bbcf21dd61ac009dbbd8255213080cfdd Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 16 Dec 2021 18:41:13 +0300 Subject: [PATCH 114/288] Remove trailing backslash --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 0c7f5601a..063538d4f 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.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,7 +356,7 @@ private static string FormatUrlString(string url, IList serverLis var queryPath = string.Empty; foreach (var server in serverList) { - var serverUrl = server.Url; + var serverUrl = server.Url.TrimEnd('/'); if (!url.Contains(serverUrl)) { continue; From 619350ef19298693be45f9637e2c1ed384bf2037 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 16 Dec 2021 18:42:34 +0300 Subject: [PATCH 115/288] Use var for consistency --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 063538d4f..742ab5ec7 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -196,9 +196,9 @@ public static Dictionary> ParseJsonCollectionFile(Stream st var requestUrls = new Dictionary>(); // Convert file to JsonDocument - using JsonDocument document = JsonDocument.Parse(stream); - JsonElement root = document.RootElement; - JsonElement itemElement = root.GetProperty("item"); + using var document = JsonDocument.Parse(stream); + var root = document.RootElement; + var itemElement = root.GetProperty("item"); foreach(JsonElement item in itemElement.EnumerateArray()) { var requestObject = item.GetProperty("request"); From b3d040e3424ffa8f803b6e7dec46eba958eb8e8b Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 16 Dec 2021 18:53:28 +0300 Subject: [PATCH 116/288] Rename predicate args --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 742ab5ec7..8e6f20762 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -41,12 +41,12 @@ public static class OpenApiFilterService { if (operationIds == "*") { - predicate = (url, operationType, o) => true; // All operations + predicate = (url, operationType, operation) => true; // All operations } else { var operationIdsArray = operationIds.Split(','); - predicate = (url, operationType, o) => operationIdsArray.Contains(o.OperationId); + predicate = (url, operationType, operation) => operationIdsArray.Contains(operation.OperationId); } } else if (tags != null) @@ -56,11 +56,11 @@ public static class OpenApiFilterService { var regex = new Regex(tagsArray[0]); - predicate = (url, operationType, o) => o.Tags.Any(tag => regex.IsMatch(tag.Name)); + predicate = (url, operationType, operation) => operation.Tags.Any(tag => regex.IsMatch(tag.Name)); } else { - predicate = (url, operationType, o) => o.Tags.Any(tag => tagsArray.Contains(tag.Name)); + predicate = (url, operationType, operation) => operation.Tags.Any(tag => tagsArray.Contains(tag.Name)); } } else if (requestUrls != null) @@ -96,7 +96,7 @@ public static class OpenApiFilterService } // predicate for matching url and operationTypes - predicate = (path, operationType, o) => operationTypes.Contains(operationType + path); + predicate = (path, operationType, operation) => operationTypes.Contains(operationType + path); } else From 0cf947be15aae447bebc94bb010e93567200731a Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 17 Dec 2021 12:21:29 +0300 Subject: [PATCH 117/288] Address PR feedback --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 8e6f20762..ab7076111 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -65,11 +65,11 @@ public static class OpenApiFilterService } else if (requestUrls != null) { - List operationTypes = new List(); + var operationTypes = new List(); - var graphVersion = source.Info.Version; + var apiVersion = source.Info.Version; - var sources = new Dictionary {{graphVersion, source}}; + var sources = new Dictionary {{ apiVersion, source}}; var rootNode = CreateOpenApiUrlTreeNode(sources); //Iterate through urls dictionary and fetch operations for each url @@ -78,7 +78,7 @@ public static class OpenApiFilterService var serverList = source.Servers; var url = FormatUrlString(path.Key, serverList); - var openApiOperations = GetOpenApiOperations(rootNode, url, graphVersion); + var openApiOperations = GetOpenApiOperations(rootNode, url, apiVersion); if (openApiOperations == null) { continue; @@ -90,7 +90,7 @@ public static class OpenApiFilterService } } - if (!(bool)operationTypes?.Any()) + if (!operationTypes.Any()) { throw new ArgumentException("The urls in the postman collection supplied could not be found."); } From 71399f6141bf7da70b367c9a453550bdb48c9754 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 17 Dec 2021 17:59:38 +0300 Subject: [PATCH 118/288] Code cleanup --- .../Services/OpenApiFilterService.cs | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index ab7076111..030f7f5b5 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -67,26 +67,29 @@ public static class OpenApiFilterService { var operationTypes = new List(); - var apiVersion = source.Info.Version; - - var sources = new Dictionary {{ apiVersion, source}}; - var rootNode = CreateOpenApiUrlTreeNode(sources); - - //Iterate through urls dictionary and fetch operations for each url - foreach (var path in requestUrls) + if (source != null) { - var serverList = source.Servers; - var url = FormatUrlString(path.Key, serverList); + var apiVersion = source.Info.Version; - var openApiOperations = GetOpenApiOperations(rootNode, url, apiVersion); - if (openApiOperations == null) - { - continue; - } + var sources = new Dictionary {{ apiVersion, source}}; + var rootNode = CreateOpenApiUrlTreeNode(sources); - foreach (var ops in openApiOperations) + //Iterate through urls dictionary and fetch operations for each url + foreach (var path in requestUrls) { - operationTypes.Add(ops.Key + url); + var serverList = source.Servers; + var url = FormatUrlString(path.Key, serverList); + + var openApiOperations = GetOpenApiOperations(rootNode, url, apiVersion); + if (openApiOperations == null) + { + continue; + } + + foreach (var ops in openApiOperations) + { + operationTypes.Add(ops.Key + url); + } } } @@ -199,10 +202,8 @@ public static Dictionary> ParseJsonCollectionFile(Stream st using var document = JsonDocument.Parse(stream); var root = document.RootElement; var itemElement = root.GetProperty("item"); - foreach(JsonElement item in itemElement.EnumerateArray()) + foreach(var requestObject in itemElement.EnumerateArray().Select(item => item.GetProperty("request"))) { - var requestObject = item.GetProperty("request"); - // Fetch list of methods and urls from collection, store them in a dictionary var path = requestObject.GetProperty("url").GetProperty("raw").ToString(); var method = requestObject.GetProperty("method").ToString(); From df4078156c2259a7ad70392d2d230d22426ef0c8 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 11 Jan 2022 16:35:17 +0300 Subject: [PATCH 119/288] Update package version --- 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 506f082ef..b3722f338 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -37,7 +37,7 @@ - + From 29d207c6c04f46726fa316e493946d737ef05469 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 11 Jan 2022 16:43:16 +0300 Subject: [PATCH 120/288] Capitalize postman and add necessary usings --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 030f7f5b5..f94b8157d 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -1,11 +1,9 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. +// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. using System; using System.Collections.Generic; -using System.IO; using System.Linq; -using System.Text.Json; using System.Text.RegularExpressions; using Microsoft.OpenApi.Models; @@ -31,7 +29,7 @@ public static class OpenApiFilterService if (requestUrls != null && (operationIds != null || tags != null)) { - throw new InvalidOperationException("Cannot filter by postman collection and either operationIds and tags at the same time."); + throw new InvalidOperationException("Cannot filter by Postman collection and either operationIds and tags at the same time."); } if (!string.IsNullOrEmpty(operationIds) && !string.IsNullOrEmpty(tags)) { @@ -74,7 +72,7 @@ public static class OpenApiFilterService var sources = new Dictionary {{ apiVersion, source}}; var rootNode = CreateOpenApiUrlTreeNode(sources); - //Iterate through urls dictionary and fetch operations for each url + // Iterate through urls dictionary and fetch operations for each url foreach (var path in requestUrls) { var serverList = source.Servers; @@ -104,7 +102,7 @@ public static class OpenApiFilterService else { - throw new InvalidOperationException("Either operationId(s),tag(s) or postman collection need to be specified."); + throw new InvalidOperationException("Either operationId(s),tag(s) or Postman collection need to be specified."); } return predicate; From d0312accd1ea6e1c2c921771bb8c92c1705ab1ef Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 11 Jan 2022 16:44:28 +0300 Subject: [PATCH 121/288] Move the json document parsing logic to OpenApiService --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 36 ++++++++++++++++++- .../Services/OpenApiFilterService.cs | 34 +----------------- 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 49636d80b..c60d1acc2 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -2,11 +2,13 @@ // Licensed under the MIT license. using System; +using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Net.Http; using System.Text; +using System.Text.Json; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers; @@ -72,7 +74,7 @@ public static void ProcessOpenApiDocument( if (!string.IsNullOrEmpty(filterByCollection)) { var fileStream = GetStream(filterByCollection); - var requestUrls = OpenApiFilterService.ParseJsonCollectionFile(fileStream); + var requestUrls = ParseJsonCollectionFile(fileStream); predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source:document); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } @@ -133,6 +135,38 @@ private static Stream GetStream(string input) return stream; } + /// + /// Takes in a file stream, parses the stream into a JsonDocument and gets a list of paths and Http methods + /// + /// A file stream. + /// A dictionary of request urls and http methods from a collection. + private static Dictionary> ParseJsonCollectionFile(Stream stream) + { + var requestUrls = new Dictionary>(); + + // Convert file to JsonDocument + using var document = JsonDocument.Parse(stream); + var root = document.RootElement; + var itemElement = root.GetProperty("item"); + foreach (var requestObject in itemElement.EnumerateArray().Select(item => item.GetProperty("request"))) + { + // Fetch list of methods and urls from collection, store them in a dictionary + var path = requestObject.GetProperty("url").GetProperty("raw").ToString(); + var method = requestObject.GetProperty("method").ToString(); + + if (!requestUrls.ContainsKey(path)) + { + requestUrls.Add(path, new List { method }); + } + else + { + requestUrls[path].Add(method); + } + } + + return requestUrls; + } + internal static void ValidateOpenApiDocument(string input) { if (input == null) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index f94b8157d..e66eeee15 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -186,39 +186,7 @@ public static OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(Dictionary - /// Takes in a file stream, parses the stream into a JsonDocument and gets a list of paths and Http methods - /// - /// A file stream. - /// A dictionary of request urls and http methods from a collection. - public static Dictionary> ParseJsonCollectionFile(Stream stream) - { - var requestUrls = new Dictionary>(); - - // Convert file to JsonDocument - using var document = JsonDocument.Parse(stream); - var root = document.RootElement; - var itemElement = root.GetProperty("item"); - foreach(var requestObject in itemElement.EnumerateArray().Select(item => item.GetProperty("request"))) - { - // Fetch list of methods and urls from collection, store them in a dictionary - var path = requestObject.GetProperty("url").GetProperty("raw").ToString(); - var method = requestObject.GetProperty("method").ToString(); - - if (!requestUrls.ContainsKey(path)) - { - requestUrls.Add(path, new List { method }); - } - else - { - requestUrls[path].Add(method); - } - } - - return requestUrls; - } - + private static IDictionary GetOpenApiOperations(OpenApiUrlTreeNode rootNode, string relativeUrl, string label) { if (relativeUrl.Equals("/", StringComparison.Ordinal) && rootNode.HasOperations(label)) From bf2d0fe36a1c1eb65c63d2a2b703e4bf2300f5bd Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 11 Jan 2022 16:44:58 +0300 Subject: [PATCH 122/288] Only add the available operations types if they are present in the postman collection --- src/Microsoft.OpenApi/Services/OpenApiFilterService.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index e66eeee15..7b9111e4d 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.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; @@ -84,16 +84,20 @@ public static class OpenApiFilterService continue; } + // Add the available ops if they are in the postman collection. See path.Value foreach (var ops in openApiOperations) { - operationTypes.Add(ops.Key + url); + if (path.Value.Contains(ops.Key.ToString().ToUpper())) + { + operationTypes.Add(ops.Key + url); + } } } } if (!operationTypes.Any()) { - throw new ArgumentException("The urls in the postman collection supplied could not be found."); + throw new ArgumentException("The urls in the Postman collection supplied could not be found."); } // predicate for matching url and operationTypes From 422cdb2134180518dbf53f1d3aa32115fe84a3c5 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 14 Jan 2022 09:20:11 +0300 Subject: [PATCH 123/288] Add public class access modifier --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index c60d1acc2..8cf5bb60e 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -18,7 +18,7 @@ namespace Microsoft.OpenApi.Hidi { - static class OpenApiService + public static class OpenApiService { public static void ProcessOpenApiDocument( string input, @@ -140,7 +140,7 @@ private static Stream GetStream(string input) /// /// A file stream. /// A dictionary of request urls and http methods from a collection. - private static Dictionary> ParseJsonCollectionFile(Stream stream) + public static Dictionary> ParseJsonCollectionFile(Stream stream) { var requestUrls = new Dictionary>(); From 7cc3e86ebeae5386da5923de9b2475aaf2e50477 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 14 Jan 2022 09:21:38 +0300 Subject: [PATCH 124/288] Add project reference and update framework to .net 50 --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 570d98b9c..8c08122d7 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -1,6 +1,6 @@  - net48;net50 + net50 false Microsoft @@ -29,8 +29,9 @@ - + + From 63b7373ac3ef42638bd2941159072bcd0e5e3987 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Fri, 14 Jan 2022 09:22:27 +0300 Subject: [PATCH 125/288] Refactor tests --- .../Services/OpenApiFilterServiceTests.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs index 4d6a25964..f470b8577 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs @@ -3,6 +3,7 @@ using System; using System.IO; +using Microsoft.OpenApi.Hidi; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Tests.UtilityFiles; @@ -52,7 +53,7 @@ public void ReturnFilteredOpenApiDocumentBasedOnPostmanCollection() var stream = fileInput.OpenRead(); // Act - var requestUrls = OpenApiFilterService.ParseJsonCollectionFile(stream); + var requestUrls = OpenApiService.ParseJsonCollectionFile(stream); var predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source: _openApiDocumentMock); var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(_openApiDocumentMock, predicate); @@ -71,12 +72,12 @@ public void ThrowsExceptionWhenUrlsInCollectionAreMissingFromSourceDocument() var stream = fileInput.OpenRead(); // Act - var requestUrls = OpenApiFilterService.ParseJsonCollectionFile(stream); + var requestUrls = OpenApiService.ParseJsonCollectionFile(stream); // Assert var message = Assert.Throws(() => OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source: _openApiDocumentMock)).Message; - Assert.Equal("The urls in the postman collection supplied could not be found.", message); + Assert.Equal("The urls in the Postman collection supplied could not be found.", message); } [Fact] @@ -84,7 +85,7 @@ public void ThrowsInvalidOperationExceptionInCreatePredicateWhenInvalidArguments { // Act and Assert var message1 = Assert.Throws(() => OpenApiFilterService.CreatePredicate(null, null)).Message; - Assert.Equal("Either operationId(s),tag(s) or postman collection need to be specified.", message1); + Assert.Equal("Either operationId(s),tag(s) or Postman collection need to be specified.", message1); var message2 = Assert.Throws(() => OpenApiFilterService.CreatePredicate("users.user.ListUser", "users.user")).Message; Assert.Equal("Cannot specify both operationIds and tags at the same time.", message2); From fdbee8ffda661bec742bac157aac6dc4e0eb4384 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 19 Jan 2022 07:11:00 +0300 Subject: [PATCH 126/288] 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 127/288] 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 128/288] 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 129/288] 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 f266f19ce5f1044dedf16b1d65b9c801aae23723 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Jan 2022 14:21:53 +0000 Subject: [PATCH 130/288] Bump FluentAssertions from 6.2.0 to 6.3.0 Bumps [FluentAssertions](https://github.com/fluentassertions/fluentassertions) from 6.2.0 to 6.3.0. - [Release notes](https://github.com/fluentassertions/fluentassertions/releases) - [Changelog](https://github.com/fluentassertions/fluentassertions/blob/master/AcceptApiChanges.ps1) - [Commits](https://github.com/fluentassertions/fluentassertions/compare/6.2.0...6.3.0) --- updated-dependencies: - dependency-name: FluentAssertions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 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 300fd511d..13feb0bc9 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 8c08122d7..f6cf40a21 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 9a33f4751b686ba971c0a9294f7c121bb5fdf3f0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 19 Jan 2022 14:21:58 +0000 Subject: [PATCH 131/288] Bump Verify from 13.3.1 to 14.14.1 Bumps [Verify](https://github.com/VerifyTests/Verify) from 13.3.1 to 14.14.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/13.3.1...14.14.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 8c08122d7..a1808a970 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -19,7 +19,7 @@ - + From 4e0639f02e8f8d3261ef1ae8364de4d689247ac2 Mon Sep 17 00:00:00 2001 From: Daniel Mbaluka Date: Mon, 6 Dec 2021 12:36:15 +0300 Subject: [PATCH 132/288] Use input file OpenApi format as the default output format --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 23 ++++++++++++++++---- src/Microsoft.OpenApi.Hidi/Program.cs | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 8cf5bb60e..b426b1ae1 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -23,8 +23,8 @@ public static class OpenApiService public static void ProcessOpenApiDocument( string input, FileInfo output, - OpenApiSpecVersion version, - OpenApiFormat format, + OpenApiSpecVersion? version, + OpenApiFormat? format, string filterByOperationIds, string filterByTags, string filterByCollection, @@ -101,13 +101,16 @@ public static void ProcessOpenApiDocument( { ReferenceInline = inline ? ReferenceInlineSetting.InlineLocalReferences : ReferenceInlineSetting.DoNotInlineReferences }; - IOpenApiWriter writer = format switch + + var openApiFormat = format ?? GetOpenApiFormat(input); + 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, version); + document.Serialize(writer, openApiVersion); textWriter.Flush(); } @@ -198,5 +201,17 @@ internal static void ValidateOpenApiDocument(string input) Console.WriteLine(statsVisitor.GetStatisticsReport()); } + + private static OpenApiFormat GetOpenApiFormat(string input) + { + if (!input.StartsWith("http") && Path.GetExtension(input) == ".json") + { + return OpenApiFormat.Json; + } + else + { + return OpenApiFormat.Yaml; + } + } } } diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 099eb70df..b3752ef97 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -33,7 +33,7 @@ static async Task Main(string[] args) new Option("--filterByTags", "Filters OpenApiDocument by Tag(s) provided", typeof(string)), new Option("--filterByCollection", "Filters OpenApiDocument by Postman collection provided", typeof(string)) }; - transformCommand.Handler = CommandHandler.Create( + transformCommand.Handler = CommandHandler.Create( OpenApiService.ProcessOpenApiDocument); rootCommand.Add(transformCommand); From 07169a4dac80ed7f6bc0f78a7089bcba38d552c2 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 20 Jan 2022 18:45:57 +0300 Subject: [PATCH 133/288] 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 a06ab0c19b70450692cd0ee40105d492bc9bc736 Mon Sep 17 00:00:00 2001 From: Daniel Mbaluka Date: Sat, 22 Jan 2022 04:52:15 +0300 Subject: [PATCH 134/288] replace verbose if statement with ternary operator --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index b426b1ae1..abef3617f 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -204,14 +204,7 @@ internal static void ValidateOpenApiDocument(string input) private static OpenApiFormat GetOpenApiFormat(string input) { - if (!input.StartsWith("http") && Path.GetExtension(input) == ".json") - { - return OpenApiFormat.Json; - } - else - { - return OpenApiFormat.Yaml; - } + return !input.StartsWith("http") && Path.GetExtension(input) == ".json" ? OpenApiFormat.Json : OpenApiFormat.Yaml; } } } From ee1c4c6bd8a5d3b95a7b2c61384b06f7b3b70d9b Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sat, 22 Jan 2022 13:19:49 -0500 Subject: [PATCH 135/288] Updated PublicApi file to no longer include ParseJsonCollectionFile --- test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index cb2a133cf..f700fee15 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -959,7 +959,6 @@ namespace Microsoft.OpenApi.Services public static Microsoft.OpenApi.Models.OpenApiDocument CreateFilteredDocument(Microsoft.OpenApi.Models.OpenApiDocument source, System.Func predicate) { } public static Microsoft.OpenApi.Services.OpenApiUrlTreeNode CreateOpenApiUrlTreeNode(System.Collections.Generic.Dictionary sources) { } public static System.Func CreatePredicate(string operationIds = null, string tags = null, System.Collections.Generic.Dictionary> requestUrls = null, Microsoft.OpenApi.Models.OpenApiDocument source = null) { } - public static System.Collections.Generic.Dictionary> ParseJsonCollectionFile(System.IO.Stream stream) { } } public class OpenApiReferenceError : Microsoft.OpenApi.Models.OpenApiError { From 0afb4977d1b03db62435c4a94db7b3ca09885eea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 22 Jan 2022 19:34:13 +0000 Subject: [PATCH 136/288] Bump Verify.Xunit from 13.3.1 to 14.14.1 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 13.3.1 to 14.14.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/13.3.1...14.14.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 94c98a143..56bdd0983 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -20,7 +20,7 @@ - + all From 41cf6ad276047437936882e03b5d5e0cd41562f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 22 Jan 2022 19:34:14 +0000 Subject: [PATCH 137/288] Bump System.Text.Json from 6.0.0 to 6.0.1 Bumps [System.Text.Json](https://github.com/dotnet/runtime) from 6.0.0 to 6.0.1. - [Release notes](https://github.com/dotnet/runtime/releases) - [Commits](https://github.com/dotnet/runtime/compare/v6.0.0...v6.0.1) --- 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 b3722f338..f9c9a770c 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -38,7 +38,7 @@ - + From 482787f0ef636762a6ab53713ed5db00e4c06f2d Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sat, 22 Jan 2022 21:30:18 -0500 Subject: [PATCH 138/288] Updated version to release new preview --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index b13c9dc18..4db249c8f 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -6,7 +6,7 @@ true hidi ./../../artifacts - 0.5.0-preview + 0.5.0-preview2 diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index ecfa9d2c5..a594df10d 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -10,7 +10,7 @@ Microsoft Microsoft.OpenApi.Readers Microsoft.OpenApi.Readers - 1.3.1-preview + 1.3.1-preview2 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 efe46713c..d2839edc7 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-preview + 1.3.1-preview2 .NET models with JSON and YAML writers for OpenAPI specification © Microsoft Corporation. All rights reserved. OpenAPI .NET From e27c0e7c7fe645bb93aa96373097b310bc80c453 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sat, 22 Jan 2022 22:18:51 -0500 Subject: [PATCH 139/288] Fixed parsing of encoding style --- .../V3/OpenApiEncodingDeserializer.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiEncodingDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiEncodingDeserializer.cs index b3bda4b61..fc2f990e7 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiEncodingDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiEncodingDeserializer.cs @@ -31,15 +31,7 @@ internal static partial class OpenApiV3Deserializer { "style", (o, n) => { - ParameterStyle style; - if (Enum.TryParse(n.GetScalarValue(), out style)) - { - o.Style = style; - } - else - { - o.Style = null; - } + o.Style = n.GetScalarValue().GetEnumFromDisplayName(); } }, { From 666a94e79a03b9b9530012b9fe69ef009ae59e9a Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sun, 23 Jan 2022 09:58:35 -0500 Subject: [PATCH 140/288] Allow empty objects to be considered valid media type objects --- .../V3/OpenApiMediaTypeDeserializer.cs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiMediaTypeDeserializer.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiMediaTypeDeserializer.cs index 695f1cc1b..c8bd3d240 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiMediaTypeDeserializer.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiMediaTypeDeserializer.cs @@ -81,11 +81,6 @@ public static OpenApiMediaType LoadMediaType(ParseNode node) { var mapNode = node.CheckMapNode(OpenApiConstants.Content); - if (!mapNode.Any()) - { - return null; - } - var mediaType = new OpenApiMediaType(); ParseMap(mapNode, mediaType, _mediaTypeFixedFields, _mediaTypePatternFields); From 4cc1db290d838c86cef0a2ed0951dbf2558a4db4 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 24 Jan 2022 09:38:53 +0300 Subject: [PATCH 141/288] Align the input and output params with kiota --- src/Microsoft.OpenApi.Hidi/Program.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index b3752ef97..ed4daa4e7 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -21,10 +21,16 @@ static async Task Main(string[] args) }; validateCommand.Handler = CommandHandler.Create(OpenApiService.ValidateOpenApiDocument); + var descriptionOption = new Option("--openapi", "Input OpenAPI description file path or URL", typeof(string)); + descriptionOption.AddAlias("-d"); + + var outputOption = new Option("--output", "The output directory path for the generated file.", typeof(FileInfo), () => "./output", arity: ArgumentArity.ZeroOrOne); + outputOption.AddAlias("o"); + var transformCommand = new Command("transform") { - new Option("--input", "Input OpenAPI description file path or URL", typeof(string) ), - new Option("--output","Output OpenAPI description file", typeof(FileInfo), arity: ArgumentArity.ZeroOrOne), + descriptionOption, + outputOption, new Option("--version", "OpenAPI specification version", typeof(OpenApiSpecVersion)), new Option("--format", "File format",typeof(OpenApiFormat) ), new Option("--inline", "Inline $ref instances", typeof(bool) ), From fa4403e4f35fe4f4a30707ec8f8b5a1665ffeff5 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 24 Jan 2022 10:02:09 +0300 Subject: [PATCH 142/288] Add aliases --- src/Microsoft.OpenApi.Hidi/Program.cs | 38 +++++++++++++++++++++------ 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index ed4daa4e7..35a8cda22 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -21,23 +21,45 @@ static async Task Main(string[] args) }; validateCommand.Handler = CommandHandler.Create(OpenApiService.ValidateOpenApiDocument); + // transform command options var descriptionOption = new Option("--openapi", "Input OpenAPI description file path or URL", typeof(string)); descriptionOption.AddAlias("-d"); var outputOption = new Option("--output", "The output directory path for the generated file.", typeof(FileInfo), () => "./output", arity: ArgumentArity.ZeroOrOne); - outputOption.AddAlias("o"); + outputOption.AddAlias("-o"); + + var versionOption = new Option("--version", "OpenAPI specification version", typeof(OpenApiSpecVersion)); + versionOption.AddAlias("-v"); + + var formatOption = new Option("--format", "File format", typeof(OpenApiFormat)); + formatOption.AddAlias("-f"); +; + var inlineOption = new Option("--inline", "Inline $ref instances", typeof(bool)); + inlineOption.AddAlias("-i"); +; + var resolveExternalOption = new Option("--resolveExternal", "Resolve external $refs", typeof(bool)); + resolveExternalOption.AddAlias("-ex"); +; + var filterByOperationIdsOption = new Option("--filterByOperationIds", "Filters OpenApiDocument by OperationId(s) provided", typeof(string)); + filterByOperationIdsOption.AddAlias("-op"); +; + var filterByTagsOption = new Option("--filterByTags", "Filters OpenApiDocument by Tag(s) provided", typeof(string)); + filterByTagsOption.AddAlias("-t"); +; + var filterByCollectionOption = new Option("--filterByCollection", "Filters OpenApiDocument by Postman collection provided", typeof(string)); + filterByCollectionOption.AddAlias("-c"); var transformCommand = new Command("transform") { descriptionOption, outputOption, - new Option("--version", "OpenAPI specification version", typeof(OpenApiSpecVersion)), - new Option("--format", "File format",typeof(OpenApiFormat) ), - new Option("--inline", "Inline $ref instances", typeof(bool) ), - new Option("--resolveExternal","Resolve external $refs", typeof(bool)), - new Option("--filterByOperationIds", "Filters OpenApiDocument by OperationId(s) provided", typeof(string)), - new Option("--filterByTags", "Filters OpenApiDocument by Tag(s) provided", typeof(string)), - new Option("--filterByCollection", "Filters OpenApiDocument by Postman collection provided", typeof(string)) + versionOption, + formatOption, + inlineOption, + resolveExternalOption, + filterByOperationIdsOption, + filterByTagsOption, + filterByCollectionOption }; transformCommand.Handler = CommandHandler.Create( OpenApiService.ProcessOpenApiDocument); From 57312fab212e4cb266567d601bbee33ddc1ec207 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 24 Jan 2022 10:41:57 +0300 Subject: [PATCH 143/288] Update the input command option for validate --- src/Microsoft.OpenApi.Hidi/Program.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 35a8cda22..c4e27e29b 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -14,14 +14,8 @@ static async Task Main(string[] args) { var rootCommand = new RootCommand() { }; - - var validateCommand = new Command("validate") - { - new Option("--input", "Input OpenAPI description file path or URL", typeof(string) ) - }; - validateCommand.Handler = CommandHandler.Create(OpenApiService.ValidateOpenApiDocument); - - // transform command options + + // command option parameters and aliases var descriptionOption = new Option("--openapi", "Input OpenAPI description file path or URL", typeof(string)); descriptionOption.AddAlias("-d"); @@ -49,6 +43,12 @@ static async Task Main(string[] args) var filterByCollectionOption = new Option("--filterByCollection", "Filters OpenApiDocument by Postman collection provided", typeof(string)); filterByCollectionOption.AddAlias("-c"); + var validateCommand = new Command("validate") + { + descriptionOption + }; + validateCommand.Handler = CommandHandler.Create(OpenApiService.ValidateOpenApiDocument); + var transformCommand = new Command("transform") { descriptionOption, From c1f37eee66574c69827aaef24626ea417f719c68 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 24 Jan 2022 10:53:27 +0300 Subject: [PATCH 144/288] Clean up 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 abef3617f..3ce75ee17 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -21,7 +21,7 @@ namespace Microsoft.OpenApi.Hidi public static class OpenApiService { public static void ProcessOpenApiDocument( - string input, + string openapi, FileInfo output, OpenApiSpecVersion? version, OpenApiFormat? format, @@ -31,9 +31,9 @@ public static void ProcessOpenApiDocument( bool inline, bool resolveExternal) { - if (string.IsNullOrEmpty(input)) + if (string.IsNullOrEmpty(openapi)) { - throw new ArgumentNullException(nameof(input)); + throw new ArgumentNullException(nameof(openapi)); } if(output == null) { @@ -44,7 +44,7 @@ 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); + var stream = GetStream(openapi); var result = new OpenApiStreamReader(new OpenApiReaderSettings { ReferenceResolution = resolveExternal ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, @@ -102,7 +102,7 @@ public static void ProcessOpenApiDocument( ReferenceInline = inline ? ReferenceInlineSetting.InlineLocalReferences : ReferenceInlineSetting.DoNotInlineReferences }; - var openApiFormat = format ?? GetOpenApiFormat(input); + var openApiFormat = format ?? GetOpenApiFormat(openapi); var openApiVersion = version ?? result.OpenApiDiagnostic.SpecificationVersion; IOpenApiWriter writer = openApiFormat switch { @@ -115,10 +115,10 @@ public static void ProcessOpenApiDocument( textWriter.Flush(); } - private static Stream GetStream(string input) + private static Stream GetStream(string openapi) { Stream stream; - if (input.StartsWith("http")) + if (openapi.StartsWith("http")) { var httpClient = new HttpClient(new HttpClientHandler() { @@ -127,11 +127,11 @@ private static Stream GetStream(string input) { DefaultRequestVersion = HttpVersion.Version20 }; - stream = httpClient.GetStreamAsync(input).Result; + stream = httpClient.GetStreamAsync(openapi).Result; } else { - var fileInput = new FileInfo(input); + var fileInput = new FileInfo(openapi); stream = fileInput.OpenRead(); } @@ -170,14 +170,14 @@ public static Dictionary> ParseJsonCollectionFile(Stream st return requestUrls; } - internal static void ValidateOpenApiDocument(string input) + internal static void ValidateOpenApiDocument(string openapi) { - if (input == null) + if (openapi == null) { - throw new ArgumentNullException("input"); + throw new ArgumentNullException("openapi"); } - var stream = GetStream(input); + var stream = GetStream(openapi); OpenApiDocument document; @@ -202,9 +202,9 @@ internal static void ValidateOpenApiDocument(string input) Console.WriteLine(statsVisitor.GetStatisticsReport()); } - private static OpenApiFormat GetOpenApiFormat(string input) + private static OpenApiFormat GetOpenApiFormat(string openapi) { - return !input.StartsWith("http") && Path.GetExtension(input) == ".json" ? OpenApiFormat.Json : OpenApiFormat.Yaml; + return !openapi.StartsWith("http") && Path.GetExtension(openapi) == ".json" ? OpenApiFormat.Json : OpenApiFormat.Yaml; } } } From 08d9b24384918de7dcfa7ff5080abb0534ffde4b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Jan 2022 21:11:29 +0000 Subject: [PATCH 145/288] Bump FluentAssertions from 6.3.0 to 6.4.0 Bumps [FluentAssertions](https://github.com/fluentassertions/fluentassertions) from 6.3.0 to 6.4.0. - [Release notes](https://github.com/fluentassertions/fluentassertions/releases) - [Changelog](https://github.com/fluentassertions/fluentassertions/blob/master/AcceptApiChanges.ps1) - [Commits](https://github.com/fluentassertions/fluentassertions/compare/6.3.0...6.4.0) --- updated-dependencies: - dependency-name: FluentAssertions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 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 13feb0bc9..7ed607fd3 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 56bdd0983..8b40a3128 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From 581023c6d991ee12ffffe93f31cb9a16e623eeca Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 25 Jan 2022 09:57:38 +0300 Subject: [PATCH 146/288] 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 147/288] 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 148/288] 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 149/288] 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 150/288] 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 151/288] 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 f81167e5c2fd31feb9269f2b69412bc2e1f04372 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 27 Jan 2022 12:57:08 +0300 Subject: [PATCH 152/288] Use kebab case for multi-name params --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 24 ++++++++++---------- src/Microsoft.OpenApi.Hidi/Program.cs | 8 +++---- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 3ce75ee17..cad202fd9 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -25,11 +25,11 @@ public static void ProcessOpenApiDocument( FileInfo output, OpenApiSpecVersion? version, OpenApiFormat? format, - string filterByOperationIds, - string filterByTags, - string filterByCollection, + string filterbyoperationids, + string filterbytags, + string filterbycollection, bool inline, - bool resolveExternal) + bool resolveexternal) { if (string.IsNullOrEmpty(openapi)) { @@ -47,7 +47,7 @@ public static void ProcessOpenApiDocument( var 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(); @@ -56,24 +56,24 @@ public static void ProcessOpenApiDocument( Func predicate; // Check if filter options are provided, then execute - if (!string.IsNullOrEmpty(filterByOperationIds) && !string.IsNullOrEmpty(filterByTags)) + if (!string.IsNullOrEmpty(filterbyoperationids) && !string.IsNullOrEmpty(filterbytags)) { throw new InvalidOperationException("Cannot filter by operationIds and tags at the same time."); } - if (!string.IsNullOrEmpty(filterByOperationIds)) + if (!string.IsNullOrEmpty(filterbyoperationids)) { - predicate = OpenApiFilterService.CreatePredicate(operationIds: filterByOperationIds); + predicate = OpenApiFilterService.CreatePredicate(operationIds: filterbyoperationids); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } - if (!string.IsNullOrEmpty(filterByTags)) + if (!string.IsNullOrEmpty(filterbytags)) { - predicate = OpenApiFilterService.CreatePredicate(tags: filterByTags); + predicate = OpenApiFilterService.CreatePredicate(tags: filterbytags); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } - if (!string.IsNullOrEmpty(filterByCollection)) + if (!string.IsNullOrEmpty(filterbycollection)) { - var fileStream = GetStream(filterByCollection); + var fileStream = GetStream(filterbycollection); var requestUrls = ParseJsonCollectionFile(fileStream); predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source:document); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index c4e27e29b..e5865d464 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -31,16 +31,16 @@ static async Task Main(string[] args) var inlineOption = new Option("--inline", "Inline $ref instances", typeof(bool)); inlineOption.AddAlias("-i"); ; - var resolveExternalOption = new Option("--resolveExternal", "Resolve external $refs", typeof(bool)); + var resolveExternalOption = new Option("--resolve-external", "Resolve external $refs", typeof(bool)); resolveExternalOption.AddAlias("-ex"); ; - var filterByOperationIdsOption = new Option("--filterByOperationIds", "Filters OpenApiDocument by OperationId(s) provided", typeof(string)); + var filterByOperationIdsOption = new Option("--filter-by-operationids", "Filters OpenApiDocument by OperationId(s) provided", typeof(string)); filterByOperationIdsOption.AddAlias("-op"); ; - var filterByTagsOption = new Option("--filterByTags", "Filters OpenApiDocument by Tag(s) provided", typeof(string)); + var filterByTagsOption = new Option("--filter-by-tags", "Filters OpenApiDocument by Tag(s) provided", typeof(string)); filterByTagsOption.AddAlias("-t"); ; - var filterByCollectionOption = new Option("--filterByCollection", "Filters OpenApiDocument by Postman collection provided", typeof(string)); + var filterByCollectionOption = new Option("--filter-by-collection", "Filters OpenApiDocument by Postman collection provided", typeof(string)); filterByCollectionOption.AddAlias("-c"); var validateCommand = new Command("validate") From 66c06b6d4c4061629eb06751a4b5b184e9d7e9b9 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 27 Jan 2022 19:14:09 +0300 Subject: [PATCH 153/288] 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 154/288] 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 155/288] 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 156/288] 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 2f6e323d69fb8c1e944ac4299750e636ce571076 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 27 Jan 2022 19:33:36 +0300 Subject: [PATCH 157/288] Clean up code --- src/Microsoft.OpenApi.Hidi/Program.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index e5865d464..5dc4e3961 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -27,19 +27,19 @@ static async Task Main(string[] args) var formatOption = new Option("--format", "File format", typeof(OpenApiFormat)); formatOption.AddAlias("-f"); -; + var inlineOption = new Option("--inline", "Inline $ref instances", typeof(bool)); inlineOption.AddAlias("-i"); -; + var resolveExternalOption = new Option("--resolve-external", "Resolve external $refs", typeof(bool)); resolveExternalOption.AddAlias("-ex"); -; + var filterByOperationIdsOption = new Option("--filter-by-operationids", "Filters OpenApiDocument by OperationId(s) provided", typeof(string)); filterByOperationIdsOption.AddAlias("-op"); -; + var filterByTagsOption = new Option("--filter-by-tags", "Filters OpenApiDocument by Tag(s) provided", typeof(string)); filterByTagsOption.AddAlias("-t"); -; + var filterByCollectionOption = new Option("--filter-by-collection", "Filters OpenApiDocument by Postman collection provided", typeof(string)); filterByCollectionOption.AddAlias("-c"); From 526aa2928b6929632d27f81b1ca83fe73df62110 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 27 Jan 2022 19:33:57 +0300 Subject: [PATCH 158/288] Refactor param to be 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 cad202fd9..a1fd8135d 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -115,10 +115,10 @@ public static void ProcessOpenApiDocument( textWriter.Flush(); } - 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() { @@ -127,11 +127,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 a4519b4627c3d056e7f062740ab57e08437cd192 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sat, 29 Jan 2022 17:12:59 -0500 Subject: [PATCH 159/288] Updated hidi parameters to control both local and remote inlining independently --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 12 +++++++----- src/Microsoft.OpenApi.Hidi/Program.cs | 6 +++--- .../OpenApiReaderSettings.cs | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index e381dd64f..05b44c9c6 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -26,11 +26,12 @@ public static void ProcessOpenApiDocument( FileInfo output, OpenApiSpecVersion? version, OpenApiFormat? format, + bool inlineExternal, + bool inlineLocal, string filterByOperationIds, string filterByTags, - string filterByCollection, - bool inline, - bool resolveExternal) + string filterByCollection + ) { if (string.IsNullOrEmpty(input)) { @@ -52,7 +53,7 @@ public static void ProcessOpenApiDocument( var result = new OpenApiStreamReader(new OpenApiReaderSettings { - ReferenceResolution = resolveExternal == true ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, + ReferenceResolution = inlineExternal == true ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, RuleSet = ValidationRuleSet.GetDefaultRuleSet(), BaseUrl = new Uri(inputUrl.AbsoluteUri) } @@ -105,7 +106,8 @@ public static void ProcessOpenApiDocument( var settings = new OpenApiWriterSettings() { - ReferenceInline = inline ? ReferenceInlineSetting.InlineLocalReferences : ReferenceInlineSetting.DoNotInlineReferences + InlineLocalReferences = inlineLocal, + InlineExternalReferences = inlineExternal }; var openApiFormat = format ?? GetOpenApiFormat(input); diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 8bc54e2fc..c6f7eff44 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -28,13 +28,13 @@ static async Task Main(string[] args) 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) ), - new Option("--inline", "Inline $ref instances", typeof(bool) ), - new Option("--resolveExternal","Resolve external $refs", typeof(bool)), + new Option("--inlineExternal", "Inline external $ref instances", typeof(bool) ), + new Option("--inlineLocal", "Inline local $ref instances", typeof(bool) ), new Option("--filterByOperationIds", "Filters OpenApiDocument by OperationId(s) provided", typeof(string)), new Option("--filterByTags", "Filters OpenApiDocument by Tag(s) provided", typeof(string)), new Option("--filterByCollection", "Filters OpenApiDocument by Postman collection provided", typeof(string)) }; - transformCommand.Handler = CommandHandler.Create( + transformCommand.Handler = CommandHandler.Create( OpenApiService.ProcessOpenApiDocument); rootCommand.Add(transformCommand); diff --git a/src/Microsoft.OpenApi.Readers/OpenApiReaderSettings.cs b/src/Microsoft.OpenApi.Readers/OpenApiReaderSettings.cs index 732708459..2e8d50adb 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiReaderSettings.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiReaderSettings.cs @@ -30,7 +30,7 @@ public enum ReferenceResolutionSetting /// ResolveLocalReferences, /// - /// Convert all references to references of valid domain objects. + /// Not used anymore. Will be removed in v2. Convert all references to references of valid domain objects. /// ResolveAllReferences } From 1ea0f5b782e5e909af84c8835485d38e6bd5cf05 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 1 Feb 2022 12:58:28 +0300 Subject: [PATCH 160/288] Add logging configurations --- src/Microsoft.OpenApi.Hidi/appsettings.json | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/Microsoft.OpenApi.Hidi/appsettings.json diff --git a/src/Microsoft.OpenApi.Hidi/appsettings.json b/src/Microsoft.OpenApi.Hidi/appsettings.json new file mode 100644 index 000000000..882248cf8 --- /dev/null +++ b/src/Microsoft.OpenApi.Hidi/appsettings.json @@ -0,0 +1,7 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Debug" + } + } +} \ No newline at end of file From f2ee8d58ef5d35ec3b9b4573beb1a00c8c3ebf97 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 1 Feb 2022 12:59:15 +0300 Subject: [PATCH 161/288] Install packages --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 4 ++++ test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 1 + 2 files changed, 5 insertions(+) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 4db249c8f..c832225fd 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -10,6 +10,10 @@ + + + + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 56bdd0983..1d7c6b1f9 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -17,6 +17,7 @@ + From 58700121ddeb7d89195a5f5a8c0f903853602d16 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 1 Feb 2022 13:00:29 +0300 Subject: [PATCH 162/288] Add a loglevel command option for additional logging --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 203 ++++++++++++++----- src/Microsoft.OpenApi.Hidi/Program.cs | 16 +- 2 files changed, 164 insertions(+), 55 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index a1fd8135d..b85f68fcc 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -3,12 +3,15 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Net; using System.Net.Http; +using System.Security; using System.Text; using System.Text.Json; +using Microsoft.Extensions.Logging; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers; @@ -18,91 +21,135 @@ namespace Microsoft.OpenApi.Hidi { - public static class OpenApiService + public class OpenApiService { public static void ProcessOpenApiDocument( string openapi, FileInfo output, OpenApiSpecVersion? version, OpenApiFormat? format, + LogLevel loglevel, string filterbyoperationids, string filterbytags, string filterbycollection, bool inline, bool resolveexternal) { - if (string.IsNullOrEmpty(openapi)) + var logger = ConfigureLoggerInstance(loglevel); + + try { - throw new ArgumentNullException(nameof(openapi)); + if (string.IsNullOrEmpty(openapi)) + { + throw new ArgumentNullException(nameof(openapi)); + } + } + catch (ArgumentNullException ex) + { + logger.LogError(ex.Message); + return; + } + try + { + if(output == null) + { + throw new ArgumentException(nameof(output)); + } } - if(output == null) + catch (ArgumentException ex) { - throw new ArgumentException(nameof(output)); + logger.LogError(ex.Message); + return; } - if (output.Exists) + try { - throw new IOException("The file you're writing to already exists. Please input a new output path."); + if (output.Exists) + { + throw new IOException("The file you're writing to already exists. Please input a new file path."); + } } + catch (IOException ex) + { + logger.LogError(ex.Message); + return; + } + + var stream = GetStream(openapi, logger); - var stream = GetStream(openapi); + // Parsing OpenAPI file + var stopwatch = new Stopwatch(); + stopwatch.Start(); + logger.LogTrace("Parsing OpenApi file"); var result = new OpenApiStreamReader(new OpenApiReaderSettings { ReferenceResolution = resolveexternal ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, RuleSet = ValidationRuleSet.GetDefaultRuleSet() } ).ReadAsync(stream).GetAwaiter().GetResult(); - var document = result.OpenApiDocument; + stopwatch.Stop(); + + var context = result.OpenApiDiagnostic; + if (context.Errors.Count > 0) + { + var errorReport = new StringBuilder(); + + foreach (var error in context.Errors) + { + errorReport.AppendLine(error.ToString()); + } + logger.LogError($"{stopwatch.ElapsedMilliseconds}ms: OpenApi Parsing errors {string.Join(Environment.NewLine, context.Errors.Select(e => e.Message).ToArray())}"); + } + else + { + logger.LogTrace("{timestamp}ms: Parsed OpenApi successfully. {count} paths found.", stopwatch.ElapsedMilliseconds, document.Paths.Count); + } + Func predicate; - // Check if filter options are provided, then execute + // Check if filter options are provided, then slice the OpenAPI document if (!string.IsNullOrEmpty(filterbyoperationids) && !string.IsNullOrEmpty(filterbytags)) { throw new InvalidOperationException("Cannot filter by operationIds and tags at the same time."); } if (!string.IsNullOrEmpty(filterbyoperationids)) { + logger.LogTrace("Creating predicate based on the operationIds supplied."); predicate = OpenApiFilterService.CreatePredicate(operationIds: filterbyoperationids); + + logger.LogTrace("Creating subset OpenApi document."); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } if (!string.IsNullOrEmpty(filterbytags)) { + logger.LogTrace("Creating predicate based on the tags supplied."); predicate = OpenApiFilterService.CreatePredicate(tags: filterbytags); - document = OpenApiFilterService.CreateFilteredDocument(document, predicate); - } - if (!string.IsNullOrEmpty(filterbycollection)) - { - var fileStream = GetStream(filterbycollection); - var requestUrls = ParseJsonCollectionFile(fileStream); - predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source:document); + logger.LogTrace("Creating subset OpenApi document."); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } - - var context = result.OpenApiDiagnostic; - - if (context.Errors.Count > 0) + if (!string.IsNullOrEmpty(filterbycollection)) { - var errorReport = new StringBuilder(); + var fileStream = GetStream(filterbycollection, logger); + var requestUrls = ParseJsonCollectionFile(fileStream, logger); - foreach (var error in context.Errors) - { - errorReport.AppendLine(error.ToString()); - } + logger.LogTrace("Creating predicate based on the paths and Http methods defined in the Postman collection."); + predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source:document); - throw new ArgumentException(string.Join(Environment.NewLine, context.Errors.Select(e => e.Message).ToArray())); + logger.LogTrace("Creating subset OpenApi document."); + document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } - + + logger.LogTrace("Creating a new file"); using var outputStream = output?.Create(); - - var textWriter = outputStream != null ? new StreamWriter(outputStream) : Console.Out; + var textWriter = outputStream != null ? new StreamWriter(outputStream) : Console.Out; var settings = new OpenApiWriterSettings() { ReferenceInline = inline ? ReferenceInlineSetting.InlineLocalReferences : ReferenceInlineSetting.DoNotInlineReferences }; - var openApiFormat = format ?? GetOpenApiFormat(openapi); + var openApiFormat = format ?? GetOpenApiFormat(openapi, logger); var openApiVersion = version ?? result.OpenApiDiagnostic.SpecificationVersion; IOpenApiWriter writer = openApiFormat switch { @@ -110,31 +157,64 @@ public static void ProcessOpenApiDocument( OpenApiFormat.Yaml => new OpenApiYamlWriter(textWriter, settings), _ => throw new ArgumentException("Unknown format"), }; + + logger.LogTrace("Serializing to OpenApi document using the provided spec version and writer"); + + stopwatch.Start(); document.Serialize(writer, openApiVersion); + stopwatch.Stop(); + + logger.LogTrace($"Finished serializing in {stopwatch.ElapsedMilliseconds}ms"); textWriter.Flush(); } - private static Stream GetStream(string input) + private static Stream GetStream(string input, ILogger logger) { + var stopwatch = new Stopwatch(); + stopwatch.Start(); + Stream stream; if (input.StartsWith("http")) { - var httpClient = new HttpClient(new HttpClientHandler() + try { - SslProtocols = System.Security.Authentication.SslProtocols.Tls12, - }) + var httpClient = new HttpClient(new HttpClientHandler() + { + SslProtocols = System.Security.Authentication.SslProtocols.Tls12, + }) + { + DefaultRequestVersion = HttpVersion.Version20 + }; + stream = httpClient.GetStreamAsync(input).Result; + } + catch (HttpRequestException ex) { - DefaultRequestVersion = HttpVersion.Version20 - }; - stream = httpClient.GetStreamAsync(input).Result; + logger.LogError($"Could not download the file at {input}, reason{ex}"); + return null; + } } else { - var fileInput = new FileInfo(input); - stream = fileInput.OpenRead(); + try + { + var fileInput = new FileInfo(input); + stream = fileInput.OpenRead(); + } + catch (Exception ex) when (ex is FileNotFoundException || + ex is PathTooLongException || + ex is DirectoryNotFoundException || + ex is IOException || + ex is UnauthorizedAccessException || + ex is SecurityException || + ex is NotSupportedException) + { + logger.LogError($"Could not open the file at {input}, reason: {ex.Message}"); + return null; + } } - + stopwatch.Stop(); + logger.LogTrace("{timestamp}ms: Read file {input}", stopwatch.ElapsedMilliseconds, input); return stream; } @@ -143,11 +223,11 @@ private static Stream GetStream(string input) /// /// A file stream. /// A dictionary of request urls and http methods from a collection. - public static Dictionary> ParseJsonCollectionFile(Stream stream) + public static Dictionary> ParseJsonCollectionFile(Stream stream, ILogger logger) { var requestUrls = new Dictionary>(); - // Convert file to JsonDocument + logger.LogTrace("Parsing the json collection file into a JsonDocument"); using var document = JsonDocument.Parse(stream); var root = document.RootElement; var itemElement = root.GetProperty("item"); @@ -166,21 +246,21 @@ public static Dictionary> ParseJsonCollectionFile(Stream st requestUrls[path].Add(method); } } - + logger.LogTrace("Finished fetching the list of paths and Http methods defined in the Postman collection."); return requestUrls; } - internal static void ValidateOpenApiDocument(string openapi) + internal static void ValidateOpenApiDocument(string openapi, LogLevel loglevel) { - if (openapi == null) + if (string.IsNullOrEmpty(openapi)) { - throw new ArgumentNullException("openapi"); + throw new ArgumentNullException(nameof(openapi)); } - - var stream = GetStream(openapi); + var logger = ConfigureLoggerInstance(loglevel); + var stream = GetStream(openapi, logger); OpenApiDocument document; - + logger.LogTrace("Parsing the OpenApi file"); document = new OpenApiStreamReader(new OpenApiReaderSettings { RuleSet = ValidationRuleSet.GetDefaultRuleSet() @@ -199,12 +279,33 @@ internal static void ValidateOpenApiDocument(string openapi) var walker = new OpenApiWalker(statsVisitor); walker.Walk(document); + logger.LogTrace("Finished walking through the OpenApi document. Generating a statistics report.."); Console.WriteLine(statsVisitor.GetStatisticsReport()); } - private static OpenApiFormat GetOpenApiFormat(string openapi) + private static OpenApiFormat GetOpenApiFormat(string openapi, ILogger logger) { + logger.LogTrace("Getting the OpenApi format"); return !openapi.StartsWith("http") && Path.GetExtension(openapi) == ".json" ? OpenApiFormat.Json : OpenApiFormat.Yaml; } + + private static ILogger ConfigureLoggerInstance(LogLevel loglevel) + { + // Configure logger options + #if DEBUG + loglevel = loglevel > LogLevel.Debug ? LogLevel.Debug : loglevel; + #endif + + var logger = LoggerFactory.Create((builder) => { + builder + .AddConsole() + #if DEBUG + .AddDebug() + #endif + .SetMinimumLevel(loglevel); + }).CreateLogger(); + + return logger; + } } } diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 5dc4e3961..2f6f8f272 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -5,6 +5,7 @@ using System.CommandLine.Invocation; using System.IO; using System.Threading.Tasks; +using Microsoft.Extensions.Logging; namespace Microsoft.OpenApi.Hidi { @@ -27,7 +28,10 @@ static async Task Main(string[] args) var formatOption = new Option("--format", "File format", typeof(OpenApiFormat)); formatOption.AddAlias("-f"); - + + var logLevelOption = new Option("--loglevel", "The log level to use when logging messages to the main output.", typeof(LogLevel), () => LogLevel.Warning); + logLevelOption.AddAlias("-ll"); + var inlineOption = new Option("--inline", "Inline $ref instances", typeof(bool)); inlineOption.AddAlias("-i"); @@ -45,9 +49,11 @@ static async Task Main(string[] args) var validateCommand = new Command("validate") { - descriptionOption + descriptionOption, + logLevelOption }; - validateCommand.Handler = CommandHandler.Create(OpenApiService.ValidateOpenApiDocument); + + validateCommand.Handler = CommandHandler.Create(OpenApiService.ValidateOpenApiDocument); var transformCommand = new Command("transform") { @@ -55,13 +61,15 @@ static async Task Main(string[] args) outputOption, versionOption, formatOption, + logLevelOption, inlineOption, resolveExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption }; - transformCommand.Handler = CommandHandler.Create( + + transformCommand.Handler = CommandHandler.Create( OpenApiService.ProcessOpenApiDocument); rootCommand.Add(transformCommand); From d4fa9c706b29513357def17dba645befba8742d0 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 1 Feb 2022 13:00:50 +0300 Subject: [PATCH 163/288] Configure a mock logger for testing --- .../Services/OpenApiFilterServiceTests.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs index f470b8577..78f8ec048 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs @@ -3,10 +3,12 @@ using System; using System.IO; +using Microsoft.Extensions.Logging; using Microsoft.OpenApi.Hidi; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Tests.UtilityFiles; +using Moq; using Xunit; namespace Microsoft.OpenApi.Tests.Services @@ -14,10 +16,14 @@ namespace Microsoft.OpenApi.Tests.Services public class OpenApiFilterServiceTests { private readonly OpenApiDocument _openApiDocumentMock; + private readonly Mock> _mockLogger; + private readonly ILogger _logger; public OpenApiFilterServiceTests() { _openApiDocumentMock = OpenApiDocumentMock.CreateOpenApiDocument(); + _mockLogger = new Mock>(); + _logger = _mockLogger.Object; } [Theory] @@ -53,7 +59,7 @@ public void ReturnFilteredOpenApiDocumentBasedOnPostmanCollection() var stream = fileInput.OpenRead(); // Act - var requestUrls = OpenApiService.ParseJsonCollectionFile(stream); + var requestUrls = OpenApiService.ParseJsonCollectionFile(stream, _logger); var predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source: _openApiDocumentMock); var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(_openApiDocumentMock, predicate); @@ -72,7 +78,7 @@ public void ThrowsExceptionWhenUrlsInCollectionAreMissingFromSourceDocument() var stream = fileInput.OpenRead(); // Act - var requestUrls = OpenApiService.ParseJsonCollectionFile(stream); + var requestUrls = OpenApiService.ParseJsonCollectionFile(stream, _logger); // Assert var message = Assert.Throws(() => From a70ac02952f0d0e3456194873c9aeca075c3da9e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Feb 2022 14:09:43 +0000 Subject: [PATCH 164/288] Bump Verify from 14.14.1 to 15.2.0 Bumps [Verify](https://github.com/VerifyTests/Verify) from 14.14.1 to 15.2.0. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/compare/14.14.1...15.2.0) --- 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 8b40a3128..a77f3905a 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -19,7 +19,7 @@ - + From fb2bf585d539cc0c6e928e3b55c88e766bcdda32 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 1 Feb 2022 18:14:42 +0300 Subject: [PATCH 165/288] Resolve PR feedback --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index b85f68fcc..d1dea081a 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -11,6 +11,7 @@ using System.Security; using System.Text; using System.Text.Json; +using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; @@ -23,7 +24,7 @@ namespace Microsoft.OpenApi.Hidi { public class OpenApiService { - public static void ProcessOpenApiDocument( + public static async void ProcessOpenApiDocument( string openapi, FileInfo output, OpenApiSpecVersion? version, @@ -74,7 +75,7 @@ public static void ProcessOpenApiDocument( return; } - var stream = GetStream(openapi, logger); + var stream = await GetStream(openapi, logger); // Parsing OpenAPI file var stopwatch = new Stopwatch(); @@ -130,7 +131,7 @@ public static void ProcessOpenApiDocument( } if (!string.IsNullOrEmpty(filterbycollection)) { - var fileStream = GetStream(filterbycollection, logger); + var fileStream = await GetStream(filterbycollection, logger); var requestUrls = ParseJsonCollectionFile(fileStream, logger); logger.LogTrace("Creating predicate based on the paths and Http methods defined in the Postman collection."); @@ -169,7 +170,7 @@ public static void ProcessOpenApiDocument( textWriter.Flush(); } - private static Stream GetStream(string input, ILogger logger) + private static async Task GetStream(string input, ILogger logger) { var stopwatch = new Stopwatch(); stopwatch.Start(); @@ -179,14 +180,15 @@ private static Stream GetStream(string input, ILogger logger) { try { - var httpClient = new HttpClient(new HttpClientHandler() + using var httpClientHandler = new HttpClientHandler() { SslProtocols = System.Security.Authentication.SslProtocols.Tls12, - }) + }; + using var httpClient = new HttpClient(httpClientHandler) { DefaultRequestVersion = HttpVersion.Version20 }; - stream = httpClient.GetStreamAsync(input).Result; + stream = await httpClient.GetStreamAsync(input); } catch (HttpRequestException ex) { @@ -250,14 +252,14 @@ public static Dictionary> ParseJsonCollectionFile(Stream st return requestUrls; } - internal static void ValidateOpenApiDocument(string openapi, LogLevel loglevel) + internal static async void ValidateOpenApiDocument(string openapi, LogLevel loglevel) { if (string.IsNullOrEmpty(openapi)) { throw new ArgumentNullException(nameof(openapi)); } var logger = ConfigureLoggerInstance(loglevel); - var stream = GetStream(openapi, logger); + var stream = await GetStream(openapi, logger); OpenApiDocument document; logger.LogTrace("Parsing the OpenApi file"); From 652379e5a22db04d4123a870a02e60de5f04cf1b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Feb 2022 21:08:40 +0000 Subject: [PATCH 166/288] Bump Verify from 15.2.0 to 15.2.1 Bumps [Verify](https://github.com/VerifyTests/Verify) from 15.2.0 to 15.2.1. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/commits) --- updated-dependencies: - dependency-name: Verify dependency-type: direct:production update-type: version-update:semver-patch ... 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 a77f3905a..b56f5c6da 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -19,7 +19,7 @@ - + From f6a9654253ff8fe66b1fb2d038d9d5283586e53b Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 2 Feb 2022 14:18:51 +0300 Subject: [PATCH 167/288] Upgrades to System.Commandline beta2 --- .../Microsoft.OpenApi.Hidi.csproj | 3 +- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 7 +-- src/Microsoft.OpenApi.Hidi/Program.cs | 45 +++++++++---------- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index c832225fd..ea617ae94 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -3,6 +3,7 @@ Exe netcoreapp3.1 + 9.0 true hidi ./../../artifacts @@ -14,7 +15,7 @@ - + diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index d1dea081a..3c9fdb7d5 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -30,11 +30,12 @@ public static async void ProcessOpenApiDocument( OpenApiSpecVersion? version, OpenApiFormat? format, LogLevel loglevel, + bool inline, + bool resolveexternal, string filterbyoperationids, string filterbytags, - string filterbycollection, - bool inline, - bool resolveexternal) + string filterbycollection + ) { var logger = ConfigureLoggerInstance(loglevel); diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 2f6f8f272..841c710e5 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -2,7 +2,6 @@ // Licensed under the MIT license. using System.CommandLine; -using System.CommandLine.Invocation; using System.IO; using System.Threading.Tasks; using Microsoft.Extensions.Logging; @@ -15,45 +14,45 @@ static async Task Main(string[] args) { var rootCommand = new RootCommand() { }; - + // command option parameters and aliases - var descriptionOption = new Option("--openapi", "Input OpenAPI description file path or URL", typeof(string)); + var descriptionOption = new Option("--openapi", "Input OpenAPI description file path or URL"); descriptionOption.AddAlias("-d"); - var outputOption = new Option("--output", "The output directory path for the generated file.", typeof(FileInfo), () => "./output", arity: ArgumentArity.ZeroOrOne); + var outputOption = new Option("--output", () => new FileInfo("./output"), "The output directory path for the generated file.") { Arity = ArgumentArity.ZeroOrOne }; outputOption.AddAlias("-o"); - var versionOption = new Option("--version", "OpenAPI specification version", typeof(OpenApiSpecVersion)); + var versionOption = new Option("--version", "OpenAPI specification version"); versionOption.AddAlias("-v"); - var formatOption = new Option("--format", "File format", typeof(OpenApiFormat)); + var formatOption = new Option("--format", "File format"); formatOption.AddAlias("-f"); - var logLevelOption = new Option("--loglevel", "The log level to use when logging messages to the main output.", typeof(LogLevel), () => LogLevel.Warning); + var logLevelOption = new Option("--loglevel", () => LogLevel.Warning, "The log level to use when logging messages to the main output."); logLevelOption.AddAlias("-ll"); - var inlineOption = new Option("--inline", "Inline $ref instances", typeof(bool)); - inlineOption.AddAlias("-i"); - - var resolveExternalOption = new Option("--resolve-external", "Resolve external $refs", typeof(bool)); - resolveExternalOption.AddAlias("-ex"); - - var filterByOperationIdsOption = new Option("--filter-by-operationids", "Filters OpenApiDocument by OperationId(s) provided", typeof(string)); + var filterByOperationIdsOption = new Option("--filter-by-operationids", "Filters OpenApiDocument by OperationId(s) provided"); filterByOperationIdsOption.AddAlias("-op"); - var filterByTagsOption = new Option("--filter-by-tags", "Filters OpenApiDocument by Tag(s) provided", typeof(string)); + var filterByTagsOption = new Option("--filter-by-tags", "Filters OpenApiDocument by Tag(s) provided"); filterByTagsOption.AddAlias("-t"); - var filterByCollectionOption = new Option("--filter-by-collection", "Filters OpenApiDocument by Postman collection provided", typeof(string)); + var filterByCollectionOption = new Option("--filter-by-collection", "Filters OpenApiDocument by Postman collection provided"); filterByCollectionOption.AddAlias("-c"); + var inlineOption = new Option("--inline", "Inline $ref instances"); + inlineOption.AddAlias("-i"); + + var resolveExternalOption = new Option("--resolve-external", "Resolve external $refs"); + resolveExternalOption.AddAlias("-ex"); + var validateCommand = new Command("validate") { descriptionOption, logLevelOption }; - validateCommand.Handler = CommandHandler.Create(OpenApiService.ValidateOpenApiDocument); + validateCommand.SetHandler(OpenApiService.ValidateOpenApiDocument, descriptionOption, logLevelOption); var transformCommand = new Command("transform") { @@ -61,16 +60,16 @@ static async Task Main(string[] args) outputOption, versionOption, formatOption, - logLevelOption, - inlineOption, - resolveExternalOption, + logLevelOption, filterByOperationIdsOption, filterByTagsOption, - filterByCollectionOption + filterByCollectionOption, + inlineOption, + resolveExternalOption, }; - transformCommand.Handler = CommandHandler.Create( - OpenApiService.ProcessOpenApiDocument); + transformCommand.SetHandler ( + OpenApiService.ProcessOpenApiDocument, descriptionOption, outputOption, versionOption, formatOption, logLevelOption, inlineOption, resolveExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); rootCommand.Add(transformCommand); rootCommand.Add(validateCommand); From 126e1d722c0ceae35367b91aa5325217c94aaed3 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Wed, 2 Feb 2022 08:16:12 -0500 Subject: [PATCH 168/288] Updated versions to preview3 --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index ea617ae94..9fe37bbc2 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -7,7 +7,7 @@ true hidi ./../../artifacts - 0.5.0-preview2 + 0.5.0-preview3 diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index a594df10d..2f6bc75b9 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -10,7 +10,7 @@ Microsoft Microsoft.OpenApi.Readers Microsoft.OpenApi.Readers - 1.3.1-preview2 + 1.3.1-preview3 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 d2839edc7..388cf45e2 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-preview2 + 1.3.1-preview3 .NET models with JSON and YAML writers for OpenAPI specification © Microsoft Corporation. All rights reserved. OpenAPI .NET From 5550f01d766013209f1ac8a68468a5ad3c9be224 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 3 Feb 2022 17:04:34 +0300 Subject: [PATCH 169/288] 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 170/288] 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 171/288] 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 172/288] 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 d61f62902a9e3f972b7cd9fd74b067d563f37839 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 7 Feb 2022 17:23:47 +0300 Subject: [PATCH 173/288] Set Nuget properties to align with compliance guidelines during package publishing --- .../Microsoft.OpenApi.Hidi.csproj | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 9fe37bbc2..f9fd1e40d 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -3,11 +3,29 @@ Exe netcoreapp3.1 - 9.0 + 9.0 true + https://github.com/Microsoft/OpenAPI.NET + MIT + true + Microsoft + Microsoft + Microsoft.OpenApi.Hidi + Microsoft.OpenApi.Hidi hidi ./../../artifacts 0.5.0-preview3 + © Microsoft Corporation. All rights reserved. + OpenAPI .NET + https://github.com/Microsoft/OpenAPI.NET + +- Publish symbols. + + Microsoft.OpenApi.Hidi + Microsoft.OpenApi.Hidi + true + + true From e5abfb3cc2a405982b89716ccf7103cb52fac7d5 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Tue, 8 Feb 2022 00:00:03 -0500 Subject: [PATCH 174/288] Updated version to preview4 --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index f9fd1e40d..a210a5c94 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -14,7 +14,7 @@ Microsoft.OpenApi.Hidi hidi ./../../artifacts - 0.5.0-preview3 + 0.5.0-preview4 © Microsoft Corporation. All rights reserved. OpenAPI .NET https://github.com/Microsoft/OpenAPI.NET diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 2f6bc75b9..ac11100c2 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -10,7 +10,7 @@ Microsoft Microsoft.OpenApi.Readers Microsoft.OpenApi.Readers - 1.3.1-preview3 + 1.3.1-preview4 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 388cf45e2..7279e56db 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-preview3 + 1.3.1-preview4 .NET models with JSON and YAML writers for OpenAPI specification © Microsoft Corporation. All rights reserved. OpenAPI .NET From 8683e372ac7ff8402f2b776ed6d13e4491e59423 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 8 Feb 2022 14:50:08 +0300 Subject: [PATCH 175/288] 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 176/288] 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 177/288] 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 178/288] 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 179/288] 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 180/288] 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 181/288] 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 182/288] 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 183/288] 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 184/288] 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 185/288] 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 186/288] 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 187/288] 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 188/288] 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 189/288] 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 190/288] 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 191/288] 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 192/288] 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 193/288] 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 4c26dbb5727b2b8412a380e7dd7ae61df96cf780 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sat, 19 Feb 2022 12:38:48 -0500 Subject: [PATCH 194/288] Added hostdocument to OpenApiReference --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 2 +- .../OpenApiReaderSettings.cs | 13 +- .../OpenApiStreamReader.cs | 2 +- .../OpenApiYamlDocumentReader.cs | 56 ++++----- .../Interfaces/IEffective.cs | 23 ++++ .../Interfaces/IOpenApiReferenceable.cs | 1 + .../Models/OpenApiDocument.cs | 34 ++++-- .../Models/OpenApiParameter.cs | 14 ++- .../Models/OpenApiReference.cs | 5 + src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 24 +++- .../Models/OpenApiSecurityScheme.cs | 4 +- .../Services/OpenApiReferenceResolver.cs | 43 ++++--- .../OpenApiWorkspaceStreamTests.cs | 13 +- .../TryLoadReferenceV2Tests.cs | 13 +- .../V2Tests/OpenApiDocumentTests.cs | 28 +++-- .../V3Tests/OpenApiCallbackTests.cs | 2 + .../V3Tests/OpenApiDocumentTests.cs | 115 +++++++++++++----- .../V3Tests/OpenApiSchemaTests.cs | 28 +++-- .../Workspaces/OpenApiWorkspaceTests.cs | 5 +- .../Writers/OpenApiYamlWriterTests.cs | 13 +- 20 files changed, 287 insertions(+), 151 deletions(-) create mode 100644 src/Microsoft.OpenApi/Interfaces/IEffective.cs diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 05b44c9c6..890327ddc 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -53,7 +53,7 @@ string filterByCollection var result = new OpenApiStreamReader(new OpenApiReaderSettings { - ReferenceResolution = inlineExternal == true ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, + LoadExternalRefs = inlineExternal, RuleSet = ValidationRuleSet.GetDefaultRuleSet(), BaseUrl = new Uri(inputUrl.AbsoluteUri) } diff --git a/src/Microsoft.OpenApi.Readers/OpenApiReaderSettings.cs b/src/Microsoft.OpenApi.Readers/OpenApiReaderSettings.cs index 2e8d50adb..12ccdb681 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiReaderSettings.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiReaderSettings.cs @@ -4,15 +4,10 @@ using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Readers.Interface; -using Microsoft.OpenApi.Readers.ParseNodes; -using Microsoft.OpenApi.Readers.Services; using Microsoft.OpenApi.Validations; using System; using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Microsoft.OpenApi.Readers { @@ -30,7 +25,7 @@ public enum ReferenceResolutionSetting /// ResolveLocalReferences, /// - /// Not used anymore. Will be removed in v2. Convert all references to references of valid domain objects. + /// ResolveAllReferences effectively means load external references. Will be removed in v2. External references are never "resolved". /// ResolveAllReferences } @@ -43,8 +38,14 @@ public class OpenApiReaderSettings /// /// Indicates how references in the source document should be handled. /// + /// This setting will be going away in the next major version of this library. Use GetEffective on model objects to get resolved references. public ReferenceResolutionSetting ReferenceResolution { get; set; } = ReferenceResolutionSetting.ResolveLocalReferences; + /// + /// When external references are found, load them into a shared workspace + /// + public bool LoadExternalRefs { get; set; } = false; + /// /// Dictionary of parsers for converting extensions into strongly typed classes /// diff --git a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs index 987e79ceb..13bdbdef8 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs @@ -25,7 +25,7 @@ public OpenApiStreamReader(OpenApiReaderSettings settings = null) { _settings = settings ?? new OpenApiReaderSettings(); - if(_settings.ReferenceResolution == ReferenceResolutionSetting.ResolveAllReferences + if((_settings.ReferenceResolution == ReferenceResolutionSetting.ResolveAllReferences || _settings.LoadExternalRefs) && _settings.BaseUrl == null) { throw new ArgumentException("BaseUrl must be provided to resolve external references."); diff --git a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs index 63b78ccba..6cf64a5bb 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs @@ -53,6 +53,11 @@ public OpenApiDocument Read(YamlDocument input, out OpenApiDiagnostic diagnostic // Parse the OpenAPI Document document = context.Parse(input); + if (_settings.LoadExternalRefs) + { + throw new InvalidOperationException("Cannot load external refs using the synchronous Read, use ReadAsync instead."); + } + ResolveReferences(diagnostic, document); } catch (OpenApiException ex) @@ -88,7 +93,12 @@ public async Task ReadAsync(YamlDocument input) // Parse the OpenAPI Document document = context.Parse(input); - await ResolveReferencesAsync(diagnostic, document, _settings.BaseUrl); + if (_settings.LoadExternalRefs) + { + await LoadExternalRefs(document); + } + + ResolveReferences(diagnostic, document); } catch (OpenApiException ex) { @@ -112,28 +122,18 @@ public async Task ReadAsync(YamlDocument input) }; } - - private void ResolveReferences(OpenApiDiagnostic diagnostic, OpenApiDocument document) + private async Task LoadExternalRefs(OpenApiDocument document) { - // Resolve References if requested - switch (_settings.ReferenceResolution) - { - case ReferenceResolutionSetting.ResolveAllReferences: - throw new ArgumentException("Cannot resolve all references via a synchronous call. Use ReadAsync."); - case ReferenceResolutionSetting.ResolveLocalReferences: - var errors = document.ResolveReferences(false); + // Create workspace for all documents to live in. + var openApiWorkSpace = new OpenApiWorkspace(); - foreach (var item in errors) - { - diagnostic.Errors.Add(item); - } - break; - case ReferenceResolutionSetting.DoNotResolveReferences: - break; - } + // Load this root document into the workspace + var streamLoader = new DefaultStreamLoader(_settings.BaseUrl); + var workspaceLoader = new OpenApiWorkspaceLoader(openApiWorkSpace, _settings.CustomExternalLoader ?? streamLoader, _settings); + await workspaceLoader.LoadAsync(new OpenApiReference() { ExternalResource = "/" }, document); } - private async Task ResolveReferencesAsync(OpenApiDiagnostic diagnostic, OpenApiDocument document, Uri baseUrl) + private void ResolveReferences(OpenApiDiagnostic diagnostic, OpenApiDocument document) { List errors = new List(); @@ -141,23 +141,9 @@ private async Task ResolveReferencesAsync(OpenApiDiagnostic diagnostic, OpenApiD switch (_settings.ReferenceResolution) { case ReferenceResolutionSetting.ResolveAllReferences: - - // Create workspace for all documents to live in. - var openApiWorkSpace = new OpenApiWorkspace(); - - // Load this root document into the workspace - var streamLoader = new DefaultStreamLoader(baseUrl); - var workspaceLoader = new OpenApiWorkspaceLoader(openApiWorkSpace, _settings.CustomExternalLoader ?? streamLoader, _settings); - await workspaceLoader.LoadAsync(new OpenApiReference() { ExternalResource = "/" }, document); - - // Resolve all references in all the documents loaded into the OpenApiWorkspace - foreach (var doc in openApiWorkSpace.Documents) - { - errors.AddRange(doc.ResolveReferences(true)); - } - break; + throw new ArgumentException("Resolving external references is not supported"); case ReferenceResolutionSetting.ResolveLocalReferences: - errors.AddRange(document.ResolveReferences(false)); + errors.AddRange(document.ResolveReferences()); break; case ReferenceResolutionSetting.DoNotResolveReferences: break; diff --git a/src/Microsoft.OpenApi/Interfaces/IEffective.cs b/src/Microsoft.OpenApi/Interfaces/IEffective.cs new file mode 100644 index 000000000..b62ec12ab --- /dev/null +++ b/src/Microsoft.OpenApi/Interfaces/IEffective.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using Microsoft.OpenApi.Models; + +namespace Microsoft.OpenApi.Interfaces +{ + /// + /// OpenApiElements that implement IEffective indicate that their description is not self-contained. + /// External elements affect the effective description. + /// + /// Currently this will only be used for accessing external references. + /// In the next major version, this will be the approach accessing all referenced elements. + /// This will enable us to support merging properties that are peers of the $ref + /// Type of OpenApi Element that is being referenced. + public interface IEffective where T : class,IOpenApiElement + { + /// + /// Returns a calculated and cloned version of the element. + /// + T GetEffective(OpenApiDocument document); + } +} diff --git a/src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceable.cs b/src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceable.cs index eb47c64bc..c790e1fda 100644 --- a/src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceable.cs +++ b/src/Microsoft.OpenApi/Interfaces/IOpenApiReferenceable.cs @@ -31,5 +31,6 @@ public interface IOpenApiReferenceable : IOpenApiSerializable /// Serialize to OpenAPI V2 document without using reference. /// void SerializeAsV2WithoutReference(IOpenApiWriter writer); + } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 4f4e673af..6ffc260d1 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -321,27 +321,37 @@ private static void WriteHostInfoV2(IOpenApiWriter writer, IList /// /// Walk the OpenApiDocument and resolve unresolved references /// - /// Indicates if external references should be resolved. Document needs to reference a workspace for this to be possible. - public IEnumerable ResolveReferences(bool useExternal = false) + /// + /// This method will be replaced by a LoadExternalReferences in the next major update to this library. + /// Resolving references at load time is going to go away. + /// + public IEnumerable ResolveReferences() { - var resolver = new OpenApiReferenceResolver(this, useExternal); + var resolver = new OpenApiReferenceResolver(this, false); var walker = new OpenApiWalker(resolver); walker.Walk(this); return resolver.Errors; } - /// - /// Load the referenced object from a object - /// - public IOpenApiReferenceable ResolveReference(OpenApiReference reference) + /// + /// Load the referenced object from a object + /// + internal T ResolveReferenceTo(OpenApiReference reference) where T : class, IOpenApiReferenceable + { + if (reference.IsExternal) { - return ResolveReference(reference, false); + return ResolveReference(reference, true) as T; } + else + { + return ResolveReference(reference, false) as T; + } + } - /// - /// Load the referenced object from a object - /// - public IOpenApiReferenceable ResolveReference(OpenApiReference reference, bool useExternal) + /// + /// Load the referenced object from a object + /// + internal IOpenApiReferenceable ResolveReference(OpenApiReference reference, bool useExternal) { if (reference == null) { diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index 50d78ae00..ebc70465a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -12,7 +12,7 @@ namespace Microsoft.OpenApi.Models /// /// Parameter Object. /// - public class OpenApiParameter : IOpenApiSerializable, IOpenApiReferenceable, IOpenApiExtensible + public class OpenApiParameter : IOpenApiSerializable, IOpenApiReferenceable, IEffective, IOpenApiExtensible { private bool? _explode; @@ -332,6 +332,18 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer) writer.WriteEndObject(); } + + public OpenApiParameter GetEffective(OpenApiDocument doc) + { + if (this.Reference != null) + { + return doc.ResolveReferenceTo(this.Reference); + } + else + { + return this; + } + } } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiReference.cs b/src/Microsoft.OpenApi/Models/OpenApiReference.cs index cbe64d3e6..3f1370800 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiReference.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiReference.cs @@ -45,6 +45,11 @@ public class OpenApiReference : IOpenApiSerializable /// public bool IsLocal => ExternalResource == null; + /// + /// The OpenApiDocument that is hosting the OpenApiReference instance. This is used to enable dereferencing the reference. + /// + public OpenApiDocument HostDocument { get; set; } = null; + /// /// Gets the full reference string for v3.0. /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 1d579a89a..c98c32c17 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -11,7 +11,7 @@ namespace Microsoft.OpenApi.Models /// /// Schema Object. /// - public class OpenApiSchema : IOpenApiSerializable, IOpenApiReferenceable, IOpenApiExtensible + public class OpenApiSchema : IOpenApiSerializable, IOpenApiReferenceable, IEffective, IOpenApiExtensible { /// /// Follow JSON Schema definition. Short text providing information about the data. @@ -252,6 +252,7 @@ public void SerializeAsV3(IOpenApiWriter writer) } var settings = writer.GetSettings(); + var target = this; if (Reference != null) { @@ -259,6 +260,13 @@ public void SerializeAsV3(IOpenApiWriter writer) { Reference.SerializeAsV3(writer); return; + } + else + { + if (Reference.IsExternal) // Temporary until v2 + { + target = this.GetEffective(Reference.HostDocument); + } } // If Loop is detected then just Serialize as a reference. @@ -270,7 +278,7 @@ public void SerializeAsV3(IOpenApiWriter writer) } } - SerializeAsV3WithoutReference(writer); + target.SerializeAsV3WithoutReference(writer); if (Reference != null) { @@ -283,6 +291,7 @@ public void SerializeAsV3(IOpenApiWriter writer) /// public void SerializeAsV3WithoutReference(IOpenApiWriter writer) { + writer.WriteStartObject(); // title @@ -666,5 +675,16 @@ internal void WriteAsSchemaProperties( // extensions writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi2_0); } + + public OpenApiSchema GetEffective(OpenApiDocument doc) + { + if (this.Reference != null) + { + return doc.ResolveReferenceTo(this.Reference); + } else + { + return this; + } + } } } diff --git a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs index 7694c5fd4..902ce19bc 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSecurityScheme.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Linq; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; @@ -83,7 +84,8 @@ public void SerializeAsV3(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null) + + if (Reference != null) { Reference.SerializeAsV3(writer); return; diff --git a/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs b/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs index 6755883b6..840f9c660 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiReferenceResolver.cs @@ -42,6 +42,13 @@ public override void Visit(OpenApiDocument doc) } } + public override void Visit(IOpenApiReferenceable referenceable) + { + if (referenceable.Reference != null) + { + referenceable.Reference.HostDocument = _currentDocument; + } + } public override void Visit(OpenApiComponents components) { ResolveMap(components.Parameters); @@ -237,7 +244,7 @@ private void ResolveTags(IList tags) { try { - return _currentDocument.ResolveReference(reference) as T; + return _currentDocument.ResolveReference(reference, false) as T; } catch (OpenApiException ex) { @@ -245,24 +252,26 @@ private void ResolveTags(IList tags) return null; } } - else if (_resolveRemoteReferences == true) - { - if (_currentDocument.Workspace == null) - { - _errors.Add(new OpenApiReferenceError(reference,"Cannot resolve external references for documents not in workspaces.")); - // Leave as unresolved reference - return new T() - { - UnresolvedReference = true, - Reference = reference - }; - } - var target = _currentDocument.Workspace.ResolveReference(reference); + // The concept of merging references with their target at load time is going away in the next major version + // External references will not support this approach. + //else if (_resolveRemoteReferences == true) + //{ + // if (_currentDocument.Workspace == null) + // { + // _errors.Add(new OpenApiReferenceError(reference,"Cannot resolve external references for documents not in workspaces.")); + // // Leave as unresolved reference + // return new T() + // { + // UnresolvedReference = true, + // Reference = reference + // }; + // } + // var target = _currentDocument.Workspace.ResolveReference(reference); - // TODO: If it is a document fragment, then we should resolve it within the current context + // // TODO: If it is a document fragment, then we should resolve it within the current context - return target as T; - } + // return target as T; + //} else { // Leave as unresolved reference diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs index b3cbb8c6d..4a2c2cafe 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs @@ -1,13 +1,9 @@ using System; -using System.Collections.Generic; using System.IO; using System.Linq; -using System.Text; using System.Threading.Tasks; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Readers.Interface; -using Microsoft.OpenApi.Readers.Services; -using Microsoft.OpenApi.Services; using Xunit; namespace Microsoft.OpenApi.Readers.Tests.OpenApiWorkspaceTests @@ -24,7 +20,7 @@ public async Task LoadingDocumentWithResolveAllReferencesShouldLoadDocumentIntoW // Create a reader that will resolve all references var reader = new OpenApiStreamReader(new OpenApiReaderSettings() { - ReferenceResolution = ReferenceResolutionSetting.ResolveAllReferences, + LoadExternalRefs = true, CustomExternalLoader = new MockLoader(), BaseUrl = new Uri("file://c:\\") }); @@ -54,7 +50,7 @@ public async Task LoadDocumentWithExternalReferenceShouldLoadBothDocumentsIntoWo // Create a reader that will resolve all references var reader = new OpenApiStreamReader(new OpenApiReaderSettings() { - ReferenceResolution = ReferenceResolutionSetting.ResolveAllReferences, + LoadExternalRefs = true, CustomExternalLoader = new ResourceLoader(), BaseUrl = new Uri("fie://c:\\") }); @@ -73,7 +69,7 @@ public async Task LoadDocumentWithExternalReferenceShouldLoadBothDocumentsIntoWo .Operations[OperationType.Get] .Responses["200"] .Content["application/json"] - .Schema; + .Schema.GetEffective(result.OpenApiDocument); Assert.Equal("object", referencedSchema.Type); Assert.Equal("string", referencedSchema.Properties["subject"].Type); Assert.False(referencedSchema.UnresolvedReference); @@ -81,8 +77,9 @@ public async Task LoadDocumentWithExternalReferenceShouldLoadBothDocumentsIntoWo var referencedParameter = result.OpenApiDocument .Paths["/todos"] .Operations[OperationType.Get] - .Parameters + .Parameters.Select(p => p.GetEffective(result.OpenApiDocument)) .Where(p => p.Name == "filter").FirstOrDefault(); + Assert.Equal("string", referencedParameter.Schema.Type); } diff --git a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs index d7f110b10..a641b7d6f 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs @@ -38,7 +38,7 @@ public void LoadSchemaReference() }; // Act - var referencedObject = document.ResolveReference(reference); + var referencedObject = document.ResolveReferenceTo(reference); // Assert referencedObject.Should().BeEquivalentTo( @@ -93,7 +93,7 @@ public void LoadParameterReference() }; // Act - var referencedObject = document.ResolveReference(reference); + var referencedObject = document.ResolveReferenceTo(reference); // Assert referencedObject.Should().BeEquivalentTo( @@ -136,7 +136,7 @@ public void LoadSecuritySchemeReference() }; // Act - var referencedObject = document.ResolveReference(reference); + var referencedObject = document.ResolveReferenceTo(reference); // Assert referencedObject.Should().BeEquivalentTo( @@ -173,7 +173,7 @@ public void LoadResponseReference() }; // Act - var referencedObject = document.ResolveReference(reference); + var referencedObject = document.ResolveReferenceTo(reference); // Assert referencedObject.Should().BeEquivalentTo( @@ -212,7 +212,7 @@ public void LoadResponseAndSchemaReference() }; // Act - var referencedObject = document.ResolveReference(reference); + var referencedObject = document.ResolveReferenceTo(reference); // Assert referencedObject.Should().BeEquivalentTo( @@ -241,7 +241,8 @@ public void LoadResponseAndSchemaReference() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = "SampleObject2" + Id = "SampleObject2", + HostDocument = document } } } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs index ad8e7e445..57593a79e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs @@ -8,15 +8,23 @@ using FluentAssertions; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Exceptions; +using Microsoft.OpenApi.Extensions; +using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Writers; using Xunit; namespace Microsoft.OpenApi.Readers.Tests.V2Tests { + + public class OpenApiDocumentTests { private const string SampleFolderPath = "V2Tests/Samples/"; + + + [Fact] public void ShouldThrowWhenReferenceTypeIsInvalid() { @@ -161,7 +169,8 @@ public void ShouldParseProducesInAnyOrder() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = "Item" + Id = "Item", + HostDocument = doc }, Items = new OpenApiSchema() { @@ -177,7 +186,8 @@ public void ShouldParseProducesInAnyOrder() Reference = new OpenApiReference() { Type = ReferenceType.Schema, - Id = "Item" + Id = "Item", + HostDocument = doc } } }; @@ -187,7 +197,8 @@ public void ShouldParseProducesInAnyOrder() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = "Item" + Id = "Item", + HostDocument = doc }, Properties = new Dictionary() { @@ -205,7 +216,8 @@ public void ShouldParseProducesInAnyOrder() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = "Error" + Id = "Error", + HostDocument= doc }, Properties = new Dictionary() { @@ -375,7 +387,8 @@ public void ShouldAssignSchemaToAllResponses() Reference = new OpenApiReference { Id = "Item", - Type = ReferenceType.Schema + Type = ReferenceType.Schema, + HostDocument = document } } }; @@ -402,7 +415,8 @@ public void ShouldAssignSchemaToAllResponses() Reference = new OpenApiReference { Id = "Error", - Type = ReferenceType.Schema + Type = ReferenceType.Schema, + HostDocument= document } }; var responses = document.Paths["/items"].Operations[OperationType.Get].Responses; @@ -430,7 +444,7 @@ public void ShouldAllowComponentsThatJustContainAReference() OpenApiDocument doc = reader.Read(stream, out OpenApiDiagnostic diags); OpenApiSchema schema1 = doc.Components.Schemas["AllPets"]; Assert.False(schema1.UnresolvedReference); - OpenApiSchema schema2 = (OpenApiSchema)doc.ResolveReference(schema1.Reference); + OpenApiSchema schema2 = doc.ResolveReferenceTo(schema1.Reference); if (schema2.UnresolvedReference && schema1.Reference.Id == schema2.Reference.Id) { // detected a cycle - this code gets triggered diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs index f23bee9f9..320f01fae 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs @@ -127,6 +127,7 @@ public void ParseCallbackWithReferenceShouldSucceed() { Type = ReferenceType.Callback, Id = "simpleHook", + HostDocument = openApiDoc } }); } @@ -185,6 +186,7 @@ public void ParseMultipleCallbacksWithReferenceShouldSucceed() { Type = ReferenceType.Callback, Id = "simpleHook", + HostDocument = openApiDoc } }); diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs index 93d3c1a1b..f1d8b805f 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs @@ -9,9 +9,12 @@ using System.Threading; using FluentAssertions; using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; +using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Validations; using Microsoft.OpenApi.Validations.Rules; +using Microsoft.OpenApi.Writers; using Newtonsoft.Json; using Xunit; using Xunit.Abstractions; @@ -25,6 +28,49 @@ public class OpenApiDocumentTests private readonly ITestOutputHelper _output; + public T Clone(T element) where T : IOpenApiSerializable + { + using (var stream = new MemoryStream()) + { + IOpenApiWriter writer; + var streamWriter = new FormattingStreamWriter(stream, CultureInfo.InvariantCulture); + writer = new OpenApiJsonWriter(streamWriter, new OpenApiJsonWriterSettings() { + InlineLocalReferences = true}); + element.SerializeAsV3(writer); + writer.Flush(); + stream.Position = 0; + + using (var streamReader = new StreamReader(stream)) + { + var result = streamReader.ReadToEnd(); + return new OpenApiStringReader().ReadFragment(result, OpenApiSpecVersion.OpenApi3_0, out OpenApiDiagnostic diagnostic4); + } + } + } + + public OpenApiSecurityScheme CloneSecurityScheme(OpenApiSecurityScheme element) + { + using (var stream = new MemoryStream()) + { + IOpenApiWriter writer; + var streamWriter = new FormattingStreamWriter(stream, CultureInfo.InvariantCulture); + writer = new OpenApiJsonWriter(streamWriter, new OpenApiJsonWriterSettings() + { + InlineLocalReferences = true + }); + element.SerializeAsV3WithoutReference(writer); + writer.Flush(); + stream.Position = 0; + + using (var streamReader = new StreamReader(stream)) + { + var result = streamReader.ReadToEnd(); + return new OpenApiStringReader().ReadFragment(result, OpenApiSpecVersion.OpenApi3_0, out OpenApiDiagnostic diagnostic4); + } + } + } + + public OpenApiDocumentTests(ITestOutputHelper output) { _output = output; @@ -256,7 +302,8 @@ public void ParseStandardPetStoreDocumentShouldSucceed() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = "pet" + Id = "pet", + HostDocument = actual } }, ["newPet"] = new OpenApiSchema @@ -285,7 +332,8 @@ public void ParseStandardPetStoreDocumentShouldSucceed() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = "newPet" + Id = "newPet", + HostDocument = actual } }, ["errorModel"] = new OpenApiSchema @@ -311,38 +359,39 @@ public void ParseStandardPetStoreDocumentShouldSucceed() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = "errorModel" + Id = "errorModel", + HostDocument = actual } }, } }; // Create a clone of the schema to avoid modifying things in components. - var petSchema = - JsonConvert.DeserializeObject( - JsonConvert.SerializeObject(components.Schemas["pet"])); + var petSchema = Clone(components.Schemas["pet"]); + petSchema.Reference = new OpenApiReference { Id = "pet", - Type = ReferenceType.Schema + Type = ReferenceType.Schema, + HostDocument = actual }; - var newPetSchema = - JsonConvert.DeserializeObject( - JsonConvert.SerializeObject(components.Schemas["newPet"])); + var newPetSchema = Clone(components.Schemas["newPet"]); + newPetSchema.Reference = new OpenApiReference { Id = "newPet", - Type = ReferenceType.Schema + Type = ReferenceType.Schema, + HostDocument = actual }; - var errorModelSchema = - JsonConvert.DeserializeObject( - JsonConvert.SerializeObject(components.Schemas["errorModel"])); + var errorModelSchema = Clone(components.Schemas["errorModel"]); + errorModelSchema.Reference = new OpenApiReference { Id = "errorModel", - Type = ReferenceType.Schema + Type = ReferenceType.Schema, + HostDocument = actual }; var expected = new OpenApiDocument @@ -683,7 +732,8 @@ public void ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = "pet" + Id = "pet", + HostDocument = actual } }, ["newPet"] = new OpenApiSchema @@ -712,7 +762,8 @@ public void ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = "newPet" + Id = "newPet", + HostDocument = actual } }, ["errorModel"] = new OpenApiSchema @@ -752,7 +803,8 @@ public void ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() Reference = new OpenApiReference { Id = "securitySchemeName1", - Type = ReferenceType.SecurityScheme + Type = ReferenceType.SecurityScheme, + HostDocument = actual } }, @@ -763,34 +815,31 @@ public void ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() Reference = new OpenApiReference { Id = "securitySchemeName2", - Type = ReferenceType.SecurityScheme + Type = ReferenceType.SecurityScheme, + HostDocument = actual } } } }; // Create a clone of the schema to avoid modifying things in components. - var petSchema = - JsonConvert.DeserializeObject( - JsonConvert.SerializeObject(components.Schemas["pet"])); + var petSchema = Clone(components.Schemas["pet"]); petSchema.Reference = new OpenApiReference { Id = "pet", Type = ReferenceType.Schema }; - var newPetSchema = - JsonConvert.DeserializeObject( - JsonConvert.SerializeObject(components.Schemas["newPet"])); + var newPetSchema = Clone(components.Schemas["newPet"]); + newPetSchema.Reference = new OpenApiReference { Id = "newPet", Type = ReferenceType.Schema }; - var errorModelSchema = - JsonConvert.DeserializeObject( - JsonConvert.SerializeObject(components.Schemas["errorModel"])); + var errorModelSchema = Clone(components.Schemas["errorModel"]); + errorModelSchema.Reference = new OpenApiReference { Id = "errorModel", @@ -814,16 +863,16 @@ public void ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() Name = "tagName2" }; - var securityScheme1 = JsonConvert.DeserializeObject( - JsonConvert.SerializeObject(components.SecuritySchemes["securitySchemeName1"])); + var securityScheme1 = CloneSecurityScheme(components.SecuritySchemes["securitySchemeName1"]); + securityScheme1.Reference = new OpenApiReference { Id = "securitySchemeName1", Type = ReferenceType.SecurityScheme }; - var securityScheme2 = JsonConvert.DeserializeObject( - JsonConvert.SerializeObject(components.SecuritySchemes["securitySchemeName2"])); + var securityScheme2 = CloneSecurityScheme(components.SecuritySchemes["securitySchemeName2"]); + securityScheme2.Reference = new OpenApiReference { Id = "securitySchemeName2", @@ -1170,7 +1219,7 @@ public void ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed() } }; - actual.Should().BeEquivalentTo(expected); + actual.Should().BeEquivalentTo(expected, options => options.Excluding(m => m.Name == "HostDocument")); } context.Should().BeEquivalentTo( diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs index dbf0cf3f6..9bdafeba6 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs @@ -359,7 +359,8 @@ public void ParseBasicSchemaWithReferenceShouldSucceed() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = "ErrorModel" + Id = "ErrorModel", + HostDocument = openApiDoc }, Required = { @@ -372,7 +373,8 @@ public void ParseBasicSchemaWithReferenceShouldSucceed() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = "ExtendedErrorModel" + Id = "ExtendedErrorModel", + HostDocument = openApiDoc }, AllOf = { @@ -381,7 +383,8 @@ public void ParseBasicSchemaWithReferenceShouldSucceed() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = "ErrorModel" + Id = "ErrorModel", + HostDocument = openApiDoc }, // Schema should be dereferenced in our model, so all the properties // from the ErrorModel above should be propagated here. @@ -420,7 +423,7 @@ public void ParseBasicSchemaWithReferenceShouldSucceed() } } } - }); + },options => options.Excluding(m => m.Name == "HostDocument")); } } @@ -469,7 +472,8 @@ public void ParseAdvancedSchemaWithReferenceShouldSucceed() Reference = new OpenApiReference() { Id= "Pet", - Type = ReferenceType.Schema + Type = ReferenceType.Schema, + HostDocument = openApiDoc } }, ["Cat"] = new OpenApiSchema @@ -482,7 +486,8 @@ public void ParseAdvancedSchemaWithReferenceShouldSucceed() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = "Pet" + Id = "Pet", + HostDocument = openApiDoc }, // Schema should be dereferenced in our model, so all the properties // from the Pet above should be propagated here. @@ -532,7 +537,8 @@ public void ParseAdvancedSchemaWithReferenceShouldSucceed() Reference = new OpenApiReference() { Id= "Cat", - Type = ReferenceType.Schema + Type = ReferenceType.Schema, + HostDocument = openApiDoc } }, ["Dog"] = new OpenApiSchema @@ -545,7 +551,8 @@ public void ParseAdvancedSchemaWithReferenceShouldSucceed() Reference = new OpenApiReference { Type = ReferenceType.Schema, - Id = "Pet" + Id = "Pet", + HostDocument = openApiDoc }, // Schema should be dereferenced in our model, so all the properties // from the Pet above should be propagated here. @@ -591,11 +598,12 @@ public void ParseAdvancedSchemaWithReferenceShouldSucceed() Reference = new OpenApiReference() { Id= "Dog", - Type = ReferenceType.Schema + Type = ReferenceType.Schema, + HostDocument = openApiDoc } } } - }); + }, options => options.Excluding(m => m.Name == "HostDocument")); } } diff --git a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs index bee746eae..63045847b 100644 --- a/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Workspaces/OpenApiWorkspaceTests.cs @@ -126,11 +126,12 @@ public void OpenApiWorkspacesAllowDocumentsToReferenceEachOther_short() workspace.AddDocument("root", doc); workspace.AddDocument("common", CreateCommonDocument()); - var errors = doc.ResolveReferences(true); + var errors = doc.ResolveReferences(); Assert.Empty(errors); var schema = doc.Paths["/"].Operations[OperationType.Get].Responses["200"].Content["application/json"].Schema; - Assert.False(schema.UnresolvedReference); + var effectiveSchema = schema.GetEffective(doc); + Assert.False(effectiveSchema.UnresolvedReference); } [Fact] diff --git a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs index 29e8c7676..bfaa3da51 100644 --- a/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs +++ b/test/Microsoft.OpenApi.Tests/Writers/OpenApiYamlWriterTests.cs @@ -468,6 +468,8 @@ private static OpenApiDocument CreateDocWithSimpleSchemaToInline() ["thing"] = thingSchema} } }; + thingSchema.Reference.HostDocument = doc; + return doc; } @@ -544,12 +546,6 @@ private static OpenApiDocument CreateDocWithRecursiveSchemaReference() var relatedSchema = new OpenApiSchema() { Type = "integer", - UnresolvedReference = false, - Reference = new OpenApiReference - { - Id = "related", - Type = ReferenceType.Schema - } }; thingSchema.Properties["related"] = relatedSchema; @@ -587,6 +583,7 @@ private static OpenApiDocument CreateDocWithRecursiveSchemaReference() ["thing"] = thingSchema} } }; + thingSchema.Reference.HostDocument = doc; return doc; } @@ -623,9 +620,7 @@ public void WriteInlineRecursiveSchemav2() children: $ref: '#/definitions/thing' related: - $ref: '#/definitions/related' - related: - type: integer"; + type: integer"; // Component schemas that are there due to cycles are still inlined because the items they reference may not exist in the components because they don't have cycles. var outputString = new StringWriter(CultureInfo.InvariantCulture); From d41cf71d7c65c3adae3486003a73e43c79644a84 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sat, 19 Feb 2022 15:01:59 -0500 Subject: [PATCH 195/288] Missed these files --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 103 +------------------ src/Microsoft.OpenApi.Hidi/Program.cs | 22 ---- 2 files changed, 4 insertions(+), 121 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 7f51960d3..632042f38 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -34,14 +34,6 @@ public static async void ProcessOpenApiDocument( FileInfo output, OpenApiSpecVersion? version, OpenApiFormat? format, -<<<<<<< HEAD - bool inlineExternal, - bool inlineLocal, - string filterByOperationIds, - string filterByTags, - string filterByCollection - ) -======= LogLevel loglevel, bool inline, bool resolveexternal, @@ -49,7 +41,6 @@ string filterByCollection string filterbytags, string filterbycollection ) ->>>>>>> origin/vnext { var logger = ConfigureLoggerInstance(loglevel); @@ -95,18 +86,6 @@ string filterbycollection OpenApiFormat openApiFormat; var stopwatch = new Stopwatch(); -<<<<<<< HEAD - var inputUrl = GetInputUrl(input); - var stream = GetStream(inputUrl); - - OpenApiDocument document; - - var result = new OpenApiStreamReader(new OpenApiReaderSettings - { - LoadExternalRefs = inlineExternal, - RuleSet = ValidationRuleSet.GetDefaultRuleSet(), - BaseUrl = new Uri(inputUrl.AbsoluteUri) -======= if (!string.IsNullOrEmpty(csdl)) { // Default to yaml and OpenApiVersion 3 during csdl to OpenApi conversion @@ -151,13 +130,8 @@ string filterbycollection openApiFormat = format ?? GetOpenApiFormat(openapi, logger); version ??= result.OpenApiDiagnostic.SpecificationVersion; ->>>>>>> origin/vnext } -<<<<<<< HEAD - document = result.OpenApiDocument; -======= ->>>>>>> origin/vnext Func predicate; // Check if filter options are provided, then slice the OpenAPI document @@ -178,15 +152,7 @@ string filterbycollection logger.LogTrace("Creating predicate based on the tags supplied."); predicate = OpenApiFilterService.CreatePredicate(tags: filterbytags); -<<<<<<< HEAD - if (!string.IsNullOrEmpty(filterByCollection)) - { - var fileStream = GetStream(GetInputUrl(filterByCollection)); - var requestUrls = ParseJsonCollectionFile(fileStream); - predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source:document); -======= logger.LogTrace("Creating subset OpenApi document."); ->>>>>>> origin/vnext document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } if (!string.IsNullOrEmpty(filterbycollection)) @@ -229,26 +195,6 @@ string filterbycollection textWriter.Flush(); } -<<<<<<< HEAD - private static Uri GetInputUrl(string input) - { - if (input.StartsWith("http")) - { - return new Uri(input); - } - else - { - return new Uri("file://" + Path.GetFullPath(input)); - } - } - - private static Stream GetStream(Uri input) - { - Stream stream; - if (input.Scheme == "http" || input.Scheme == "https") - { - var httpClient = new HttpClient(new HttpClientHandler() -======= /// /// Converts CSDL to OpenAPI /// @@ -303,10 +249,9 @@ private static async Task GetStream(string input, ILogger logger) stopwatch.Start(); Stream stream; - if (input.StartsWith("http")) + if (input.Scheme == "http" || input.Scheme == "https") { try ->>>>>>> origin/vnext { var httpClientHandler = new HttpClientHandler() { @@ -326,14 +271,6 @@ private static async Task GetStream(string input, ILogger logger) } else if (input.Scheme == "file") { -<<<<<<< HEAD - var fileInput = new FileInfo(input.AbsolutePath); - stream = fileInput.OpenRead(); - } - else - { - throw new ArgumentException("Unrecognized exception"); -======= try { var fileInput = new FileInfo(input); @@ -350,7 +287,6 @@ ex is SecurityException || logger.LogError($"Could not open the file at {input}, reason: {ex.Message}"); return null; } ->>>>>>> origin/vnext } stopwatch.Stop(); logger.LogTrace("{timestamp}ms: Read file {input}", stopwatch.ElapsedMilliseconds, input); @@ -389,31 +325,18 @@ public static Dictionary> ParseJsonCollectionFile(Stream st return requestUrls; } -<<<<<<< HEAD - internal static async Task ValidateOpenApiDocument(string input, bool resolveExternal) -======= internal static async Task ValidateOpenApiDocument(string openapi, LogLevel loglevel) ->>>>>>> origin/vnext { if (string.IsNullOrEmpty(openapi)) { throw new ArgumentNullException(nameof(openapi)); } -<<<<<<< HEAD - var inputUrl = GetInputUrl(input); - var stream = GetStream(GetInputUrl(input)); - - OpenApiDocument document; - - var result = await new OpenApiStreamReader(new OpenApiReaderSettings -======= var logger = ConfigureLoggerInstance(loglevel); var stream = await GetStream(openapi, logger); OpenApiDocument document; logger.LogTrace("Parsing the OpenApi file"); document = new OpenApiStreamReader(new OpenApiReaderSettings ->>>>>>> origin/vnext { ReferenceResolution = resolveExternal == true ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, RuleSet = ValidationRuleSet.GetDefaultRuleSet(), @@ -432,30 +355,12 @@ internal static async Task ValidateOpenApiDocument(string openapi, LogLevel logl } } - if (document.Workspace == null) { - var statsVisitor = new StatsVisitor(); - var walker = new OpenApiWalker(statsVisitor); - walker.Walk(document); - Console.WriteLine(statsVisitor.GetStatisticsReport()); - } - else - { - foreach (var memberDocument in document.Workspace.Documents) - { - Console.WriteLine("Stats for " + memberDocument.Info.Title); - var statsVisitor = new StatsVisitor(); - var walker = new OpenApiWalker(statsVisitor); - walker.Walk(memberDocument); - Console.WriteLine(statsVisitor.GetStatisticsReport()); - } - } + var statsVisitor = new StatsVisitor(); + var walker = new OpenApiWalker(statsVisitor); + walker.Walk(document); -<<<<<<< HEAD - -======= logger.LogTrace("Finished walking through the OpenApi document. Generating a statistics report.."); Console.WriteLine(statsVisitor.GetStatisticsReport()); ->>>>>>> origin/vnext } private static OpenApiFormat GetOpenApiFormat(string input, ILogger logger) diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index c078d7ba6..95e6f63f2 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -51,27 +51,6 @@ static async Task Main(string[] args) var validateCommand = new Command("validate") { -<<<<<<< HEAD - new Option("--input", "Input OpenAPI description file path or URL", typeof(string) ), - new Option("--resolveExternal","Resolve external $refs", typeof(bool)) - }; - validateCommand.Handler = CommandHandler.Create(OpenApiService.ValidateOpenApiDocument); - - var transformCommand = new Command("transform") - { - new Option("--input", "Input OpenAPI description 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) ), - new Option("--inlineExternal", "Inline external $ref instances", typeof(bool) ), - new Option("--inlineLocal", "Inline local $ref instances", typeof(bool) ), - new Option("--filterByOperationIds", "Filters OpenApiDocument by OperationId(s) provided", typeof(string)), - new Option("--filterByTags", "Filters OpenApiDocument by Tag(s) provided", typeof(string)), - new Option("--filterByCollection", "Filters OpenApiDocument by Postman collection provided", typeof(string)) - }; - transformCommand.Handler = CommandHandler.Create( - OpenApiService.ProcessOpenApiDocument); -======= descriptionOption, logLevelOption }; @@ -95,7 +74,6 @@ static async Task Main(string[] args) transformCommand.SetHandler ( OpenApiService.ProcessOpenApiDocument, descriptionOption, csdlOption, outputOption, versionOption, formatOption, logLevelOption, inlineOption, resolveExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); ->>>>>>> origin/vnext rootCommand.Add(transformCommand); rootCommand.Add(validateCommand); From 972098762d02b8a49707719e472eec8682669241 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 21 Feb 2022 11:24:56 +0300 Subject: [PATCH 196/288] 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 403fdbc6ab8bbd0352e07067853e1e6ca085d8cb Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Mon, 21 Feb 2022 17:45:43 -0500 Subject: [PATCH 197/288] Updated referencable items to use GetEffective when inlining --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 20 +++--- src/Microsoft.OpenApi.Hidi/Program.cs | 14 ++--- .../Models/OpenApiCallback.cs | 34 ++++++++-- .../Models/OpenApiExample.cs | 33 ++++++++-- src/Microsoft.OpenApi/Models/OpenApiHeader.cs | 53 +++++++++++++--- src/Microsoft.OpenApi/Models/OpenApiLink.cs | 35 +++++++++-- .../Models/OpenApiParameter.cs | 62 +++++++++++++------ .../Models/OpenApiPathItem.cs | 50 ++++++++++++--- .../Models/OpenApiRequestBody.cs | 31 +++++++++- .../Models/OpenApiResponse.cs | 51 ++++++++++++--- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 18 +++++- 11 files changed, 321 insertions(+), 80 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 632042f38..e813e72a4 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -28,15 +28,15 @@ namespace Microsoft.OpenApi.Hidi { public class OpenApiService { - public static async void ProcessOpenApiDocument( + public static async Task ProcessOpenApiDocument( string openapi, string csdl, FileInfo output, OpenApiSpecVersion? version, OpenApiFormat? format, LogLevel loglevel, - bool inline, - bool resolveexternal, + bool inlineLocal, + bool inlineExternal, string filterbyoperationids, string filterbytags, string filterbycollection @@ -104,8 +104,9 @@ string filterbycollection logger.LogTrace("Parsing OpenApi file"); var result = new OpenApiStreamReader(new OpenApiReaderSettings { - ReferenceResolution = resolveexternal ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, - RuleSet = ValidationRuleSet.GetDefaultRuleSet() + RuleSet = ValidationRuleSet.GetDefaultRuleSet(), + LoadExternalRefs = inlineExternal, + BaseUrl = openapi.StartsWith("http") ? new Uri(openapi) : new Uri("file:" + new FileInfo(openapi).DirectoryName + "\\") } ).ReadAsync(stream).GetAwaiter().GetResult(); @@ -249,7 +250,7 @@ private static async Task GetStream(string input, ILogger logger) stopwatch.Start(); Stream stream; - if (input.Scheme == "http" || input.Scheme == "https") + if (input.StartsWith("http")) { try { @@ -269,7 +270,7 @@ private static async Task GetStream(string input, ILogger logger) return null; } } - else if (input.Scheme == "file") + else { try { @@ -336,11 +337,10 @@ internal static async Task ValidateOpenApiDocument(string openapi, LogLevel logl OpenApiDocument document; logger.LogTrace("Parsing the OpenApi file"); - document = new OpenApiStreamReader(new OpenApiReaderSettings + var result = await new OpenApiStreamReader(new OpenApiReaderSettings { - ReferenceResolution = resolveExternal == true ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, RuleSet = ValidationRuleSet.GetDefaultRuleSet(), - BaseUrl = new Uri(inputUrl.AbsoluteUri) + BaseUrl = new Uri(openapi) } ).ReadAsync(stream); diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 95e6f63f2..309fa5360 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -43,11 +43,11 @@ static async Task Main(string[] args) var filterByCollectionOption = new Option("--filter-by-collection", "Filters OpenApiDocument by Postman collection provided"); filterByCollectionOption.AddAlias("-c"); - var inlineOption = new Option("--inline", "Inline $ref instances"); - inlineOption.AddAlias("-i"); + var inlineLocalOption = new Option("--inlineLocal", "Inline local $ref instances"); + inlineLocalOption.AddAlias("-il"); - var resolveExternalOption = new Option("--resolve-external", "Resolve external $refs"); - resolveExternalOption.AddAlias("-ex"); + var inlineExternalOption = new Option("--inlineExternal", "Inline external $ref instances"); + inlineExternalOption.AddAlias("-ie"); var validateCommand = new Command("validate") { @@ -68,12 +68,12 @@ static async Task Main(string[] args) filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption, - inlineOption, - resolveExternalOption, + inlineLocalOption, + inlineExternalOption }; transformCommand.SetHandler ( - OpenApiService.ProcessOpenApiDocument, descriptionOption, csdlOption, outputOption, versionOption, formatOption, logLevelOption, inlineOption, resolveExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); + OpenApiService.ProcessOpenApiDocument, descriptionOption, csdlOption, outputOption, versionOption, formatOption, logLevelOption, inlineLocalOption, inlineExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); rootCommand.Add(transformCommand); rootCommand.Add(validateCommand); diff --git a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs index 644334ab4..bd8bfce76 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs @@ -70,15 +70,41 @@ public void SerializeAsV3(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) + var target = this; + + if (Reference != null) { - Reference.SerializeAsV3(writer); - return; + if (!writer.GetSettings().ShouldInlineReference(Reference)) + { + Reference.SerializeAsV3(writer); + return; + } + else + { + target = GetEffective(Reference.HostDocument); + } } + target.SerializeAsV3WithoutReference(writer); + } - SerializeAsV3WithoutReference(writer); + /// + /// Returns an effective OpenApiCallback object based on the presence of a $ref + /// + /// The host OpenApiDocument that contains the reference. + /// OpenApiCallback + public OpenApiCallback GetEffective(OpenApiDocument doc) + { + if (this.Reference != null) + { + return doc.ResolveReferenceTo(this.Reference); + } + else + { + return this; + } } + /// /// Serialize to OpenAPI V3 document without using reference. /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiExample.cs b/src/Microsoft.OpenApi/Models/OpenApiExample.cs index 787c2972e..f7371f55c 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExample.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExample.cs @@ -64,13 +64,38 @@ public void SerializeAsV3(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) + var target = this; + + if (Reference != null) { - Reference.SerializeAsV3(writer); - return; + if (!writer.GetSettings().ShouldInlineReference(Reference)) + { + Reference.SerializeAsV3(writer); + return; + } + else + { + target = GetEffective(Reference.HostDocument); + } } + target.SerializeAsV3WithoutReference(writer); + } - SerializeAsV3WithoutReference(writer); + /// + /// Returns an effective OpenApiExample object based on the presence of a $ref + /// + /// The host OpenApiDocument that contains the reference. + /// OpenApiExample + public OpenApiExample GetEffective(OpenApiDocument doc) + { + if (this.Reference != null) + { + return doc.ResolveReferenceTo(this.Reference); + } + else + { + return this; + } } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs index d94681a1c..791af1d70 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs @@ -96,15 +96,42 @@ public void SerializeAsV3(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) + var target = this; + + if (Reference != null) { - Reference.SerializeAsV3(writer); - return; + if (!writer.GetSettings().ShouldInlineReference(Reference)) + { + Reference.SerializeAsV3(writer); + return; + } + else + { + target = GetEffective(Reference.HostDocument); + } } + target.SerializeAsV3WithoutReference(writer); - SerializeAsV3WithoutReference(writer); } + /// + /// Returns an effective OpenApiHeader object based on the presence of a $ref + /// + /// The host OpenApiDocument that contains the reference. + /// OpenApiHeader + public OpenApiHeader GetEffective(OpenApiDocument doc) + { + if (this.Reference != null) + { + return doc.ResolveReferenceTo(this.Reference); + } + else + { + return this; + } + } + + /// /// Serialize to OpenAPI V3 document without using reference. /// @@ -161,13 +188,21 @@ public void SerializeAsV2(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) + var target = this; + + if (Reference != null) { - Reference.SerializeAsV2(writer); - return; + if (!writer.GetSettings().ShouldInlineReference(Reference)) + { + Reference.SerializeAsV2(writer); + return; + } + else + { + target = GetEffective(Reference.HostDocument); + } } - - SerializeAsV2WithoutReference(writer); + target.SerializeAsV2WithoutReference(writer); } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiLink.cs b/src/Microsoft.OpenApi/Models/OpenApiLink.cs index 82502f14a..1d1488ca6 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLink.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLink.cs @@ -71,15 +71,42 @@ public void SerializeAsV3(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) + var target = this; + + if (Reference != null) { - Reference.SerializeAsV3(writer); - return; + if (!writer.GetSettings().ShouldInlineReference(Reference)) + { + Reference.SerializeAsV3(writer); + return; + } + else + { + target = GetEffective(Reference.HostDocument); + } } + target.SerializeAsV3WithoutReference(writer); - SerializeAsV3WithoutReference(writer); } + /// + /// Returns an effective OpenApiLink object based on the presence of a $ref + /// + /// The host OpenApiDocument that contains the reference. + /// OpenApiLink + public OpenApiLink GetEffective(OpenApiDocument doc) + { + if (this.Reference != null) + { + return doc.ResolveReferenceTo(this.Reference); + } + else + { + return this; + } + } + + /// /// Serialize to OpenAPI V3 document without using reference. /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs index ebc70465a..12f37f61a 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiParameter.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiParameter.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System.Collections.Generic; +using System.Runtime; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Interfaces; @@ -145,13 +146,39 @@ public void SerializeAsV3(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) + var target = this; + + if (Reference != null) { - Reference.SerializeAsV3(writer); - return; + if (!writer.GetSettings().ShouldInlineReference(Reference)) + { + Reference.SerializeAsV3(writer); + return; + } + else + { + target = this.GetEffective(Reference.HostDocument); + } } - SerializeAsV3WithoutReference(writer); + target.SerializeAsV3WithoutReference(writer); + } + + /// + /// Returns an effective OpenApiParameter object based on the presence of a $ref + /// + /// The host OpenApiDocument that contains the reference. + /// OpenApiParameter + public OpenApiParameter GetEffective(OpenApiDocument doc) + { + if (this.Reference != null) + { + return doc.ResolveReferenceTo(this.Reference); + } + else + { + return this; + } } /// @@ -216,13 +243,21 @@ public void SerializeAsV2(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) + var target = this; + if (Reference != null) { - Reference.SerializeAsV2(writer); - return; + if (!writer.GetSettings().ShouldInlineReference(Reference)) + { + Reference.SerializeAsV2(writer); + return; + } + else + { + target = this.GetEffective(Reference.HostDocument); + } } - SerializeAsV2WithoutReference(writer); + target.SerializeAsV2WithoutReference(writer); } /// @@ -333,17 +368,6 @@ public void SerializeAsV2WithoutReference(IOpenApiWriter writer) writer.WriteEndObject(); } - public OpenApiParameter GetEffective(OpenApiDocument doc) - { - if (this.Reference != null) - { - return doc.ResolveReferenceTo(this.Reference); - } - else - { - return this; - } - } } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs index 78e97ec18..a8fc27c27 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs @@ -74,15 +74,38 @@ public void SerializeAsV3(IOpenApiWriter writer) { throw Error.ArgumentNull(nameof(writer)); } + var target = this; - if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) + if (Reference != null) { - Reference.SerializeAsV3(writer); - return; + if (!writer.GetSettings().ShouldInlineReference(Reference)) + { + Reference.SerializeAsV3(writer); + return; + } + else + { + target = GetEffective(Reference.HostDocument); + } } + target.SerializeAsV3WithoutReference(writer); + } - SerializeAsV3WithoutReference(writer); - + /// + /// Returns an effective OpenApiPathItem object based on the presence of a $ref + /// + /// The host OpenApiDocument that contains the reference. + /// OpenApiPathItem + public OpenApiPathItem GetEffective(OpenApiDocument doc) + { + if (this.Reference != null) + { + return doc.ResolveReferenceTo(this.Reference); + } + else + { + return this; + } } /// @@ -95,13 +118,22 @@ public void SerializeAsV2(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) + var target = this; + + if (Reference != null) { - Reference.SerializeAsV2(writer); - return; + if (!writer.GetSettings().ShouldInlineReference(Reference)) + { + Reference.SerializeAsV2(writer); + return; + } + else + { + target = this.GetEffective(Reference.HostDocument); + } } - SerializeAsV2WithoutReference(writer); + target.SerializeAsV2WithoutReference(writer); } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs index d6308efcf..353e294f2 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs @@ -55,13 +55,38 @@ public void SerializeAsV3(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } + var target = this; + if (Reference != null) { - Reference.SerializeAsV3(writer); - return; + if (!writer.GetSettings().ShouldInlineReference(Reference)) + { + Reference.SerializeAsV3(writer); + return; + } + else + { + target = GetEffective(Reference.HostDocument); + } } + target.SerializeAsV3WithoutReference(writer); + } - SerializeAsV3WithoutReference(writer); + /// + /// Returns an effective OpenApiRequestBody object based on the presence of a $ref + /// + /// The host OpenApiDocument that contains the reference. + /// OpenApiRequestBody + public OpenApiRequestBody GetEffective(OpenApiDocument doc) + { + if (this.Reference != null) + { + return doc.ResolveReferenceTo(this.Reference); + } + else + { + return this; + } } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs index ef30602b9..faf279013 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs @@ -61,13 +61,38 @@ public void SerializeAsV3(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) + var target = this; + + if (Reference != null) { - Reference.SerializeAsV3(writer); - return; + if (!writer.GetSettings().ShouldInlineReference(Reference)) + { + Reference.SerializeAsV3(writer); + return; + } + else + { + target = GetEffective(Reference.HostDocument); + } } + target.SerializeAsV3WithoutReference(writer); + } - SerializeAsV3WithoutReference(writer); + /// + /// Returns an effective OpenApiRequestBody object based on the presence of a $ref + /// + /// The host OpenApiDocument that contains the reference. + /// OpenApiResponse + public OpenApiResponse GetEffective(OpenApiDocument doc) + { + if (this.Reference != null) + { + return doc.ResolveReferenceTo(this.Reference); + } + else + { + return this; + } } /// @@ -105,13 +130,21 @@ public void SerializeAsV2(IOpenApiWriter writer) throw Error.ArgumentNull(nameof(writer)); } - if (Reference != null && !writer.GetSettings().ShouldInlineReference(Reference)) + var target = this; + + if (Reference != null) { - Reference.SerializeAsV2(writer); - return; + if (!writer.GetSettings().ShouldInlineReference(Reference)) + { + Reference.SerializeAsV2(writer); + return; + } + else + { + target = GetEffective(Reference.HostDocument); + } } - - SerializeAsV2WithoutReference(writer); + target.SerializeAsV2WithoutReference(writer); } /// diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index c98c32c17..74aed7da1 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -451,14 +451,23 @@ internal void SerializeAsV2( throw Error.ArgumentNull(nameof(writer)); } + var settings = writer.GetSettings(); + var target = this; + if (Reference != null) { - var settings = writer.GetSettings(); if (!settings.ShouldInlineReference(Reference)) { Reference.SerializeAsV2(writer); return; } + else + { + if (Reference.IsExternal) // Temporary until v2 + { + target = this.GetEffective(Reference.HostDocument); + } + } // If Loop is detected then just Serialize as a reference. if (!settings.LoopDetector.PushLoop(this)) @@ -475,7 +484,7 @@ internal void SerializeAsV2( parentRequiredProperties = new HashSet(); } - SerializeAsV2WithoutReference(writer, parentRequiredProperties, propertyName); + target.SerializeAsV2WithoutReference(writer, parentRequiredProperties, propertyName); } /// @@ -676,6 +685,11 @@ internal void WriteAsSchemaProperties( writer.WriteExtensions(Extensions, OpenApiSpecVersion.OpenApi2_0); } + /// + /// Returns an effective OpenApiSchema object based on the presence of a $ref + /// + /// The host OpenApiDocument that contains the reference. + /// OpenApiSchema public OpenApiSchema GetEffective(OpenApiDocument doc) { if (this.Reference != null) From d7616ee3f5dc44f1dc5957748a96d52ebd6de836 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Mon, 21 Feb 2022 22:27:15 -0500 Subject: [PATCH 198/288] Added IEffective interfaces to models that have references --- .../Models/OpenApiCallback.cs | 2 +- .../Models/OpenApiExample.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiHeader.cs | 2 +- src/Microsoft.OpenApi/Models/OpenApiLink.cs | 2 +- .../Models/OpenApiPathItem.cs | 2 +- .../Models/OpenApiRequestBody.cs | 2 +- .../Models/OpenApiResponse.cs | 2 +- .../PublicApi/PublicApi.approved.txt | 39 ++++++++++++------- 8 files changed, 33 insertions(+), 20 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs index bd8bfce76..57aa3c888 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiCallback.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiCallback.cs @@ -12,7 +12,7 @@ namespace Microsoft.OpenApi.Models /// /// Callback Object: A map of possible out-of band callbacks related to the parent operation. /// - public class OpenApiCallback : IOpenApiSerializable, IOpenApiReferenceable, IOpenApiExtensible + public class OpenApiCallback : IOpenApiSerializable, IOpenApiReferenceable, IOpenApiExtensible, IEffective { /// /// A Path Item Object used to define a callback request and expected responses. diff --git a/src/Microsoft.OpenApi/Models/OpenApiExample.cs b/src/Microsoft.OpenApi/Models/OpenApiExample.cs index f7371f55c..d4c268584 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiExample.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiExample.cs @@ -11,7 +11,7 @@ namespace Microsoft.OpenApi.Models /// /// Example Object. /// - public class OpenApiExample : IOpenApiSerializable, IOpenApiReferenceable, IOpenApiExtensible + public class OpenApiExample : IOpenApiSerializable, IOpenApiReferenceable, IOpenApiExtensible, IEffective { /// /// Short description for the example. diff --git a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs index 791af1d70..e8576a0ca 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiHeader.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiHeader.cs @@ -13,7 +13,7 @@ namespace Microsoft.OpenApi.Models /// Header Object. /// The Header Object follows the structure of the Parameter Object. /// - public class OpenApiHeader : IOpenApiSerializable, IOpenApiReferenceable, IOpenApiExtensible + public class OpenApiHeader : IOpenApiSerializable, IOpenApiReferenceable, IOpenApiExtensible, IEffective { /// /// Indicates if object is populated with data or is just a reference to the data diff --git a/src/Microsoft.OpenApi/Models/OpenApiLink.cs b/src/Microsoft.OpenApi/Models/OpenApiLink.cs index 1d1488ca6..f5acb0d3f 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiLink.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiLink.cs @@ -11,7 +11,7 @@ namespace Microsoft.OpenApi.Models /// /// Link Object. /// - public class OpenApiLink : IOpenApiSerializable, IOpenApiReferenceable, IOpenApiExtensible + public class OpenApiLink : IOpenApiSerializable, IOpenApiReferenceable, IOpenApiExtensible, IEffective { /// /// A relative or absolute reference to an OAS operation. diff --git a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs index a8fc27c27..375f1f034 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiPathItem.cs @@ -11,7 +11,7 @@ namespace Microsoft.OpenApi.Models /// /// Path Item Object: to describe the operations available on a single path. /// - public class OpenApiPathItem : IOpenApiSerializable, IOpenApiExtensible, IOpenApiReferenceable + public class OpenApiPathItem : IOpenApiSerializable, IOpenApiExtensible, IOpenApiReferenceable, IEffective { /// /// An optional, string summary, intended to apply to all operations in this path. diff --git a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs index 353e294f2..8a65f1fde 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiRequestBody.cs @@ -11,7 +11,7 @@ namespace Microsoft.OpenApi.Models /// /// Request Body Object /// - public class OpenApiRequestBody : IOpenApiSerializable, IOpenApiReferenceable, IOpenApiExtensible + public class OpenApiRequestBody : IOpenApiSerializable, IOpenApiReferenceable, IOpenApiExtensible, IEffective { /// /// Indicates if object is populated with data or is just a reference to the data diff --git a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs index faf279013..0a31ca0a4 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiResponse.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiResponse.cs @@ -11,7 +11,7 @@ namespace Microsoft.OpenApi.Models /// /// Response object. /// - public class OpenApiResponse : IOpenApiSerializable, IOpenApiReferenceable, IOpenApiExtensible + public class OpenApiResponse : IOpenApiSerializable, IOpenApiReferenceable, IOpenApiExtensible, IEffective { /// /// REQUIRED. A short description of the response. diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 484d64dba..43900109b 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -271,6 +271,11 @@ namespace Microsoft.OpenApi.Extensions } namespace Microsoft.OpenApi.Interfaces { + public interface IEffective + where T : class, Microsoft.OpenApi.Interfaces.IOpenApiElement + { + T GetEffective(Microsoft.OpenApi.Models.OpenApiDocument document); + } public interface IOpenApiElement { } public interface IOpenApiExtensible : Microsoft.OpenApi.Interfaces.IOpenApiElement { @@ -315,7 +320,7 @@ namespace Microsoft.OpenApi } namespace Microsoft.OpenApi.Models { - public class OpenApiCallback : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public class OpenApiCallback : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiCallback() { } public System.Collections.Generic.IDictionary Extensions { get; set; } @@ -323,6 +328,7 @@ namespace Microsoft.OpenApi.Models public Microsoft.OpenApi.Models.OpenApiReference Reference { get; set; } public bool UnresolvedReference { get; set; } public void AddPathItem(Microsoft.OpenApi.Expressions.RuntimeExpression expression, Microsoft.OpenApi.Models.OpenApiPathItem pathItem) { } + public Microsoft.OpenApi.Models.OpenApiCallback GetEffective(Microsoft.OpenApi.Models.OpenApiDocument doc) { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV2WithoutReference(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -500,9 +506,7 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.IList Servers { get; set; } public System.Collections.Generic.IList Tags { get; set; } public Microsoft.OpenApi.Services.OpenApiWorkspace Workspace { get; set; } - public Microsoft.OpenApi.Interfaces.IOpenApiReferenceable ResolveReference(Microsoft.OpenApi.Models.OpenApiReference reference) { } - public Microsoft.OpenApi.Interfaces.IOpenApiReferenceable ResolveReference(Microsoft.OpenApi.Models.OpenApiReference reference, bool useExternal) { } - public System.Collections.Generic.IEnumerable ResolveReferences(bool useExternal = false) { } + public System.Collections.Generic.IEnumerable ResolveReferences() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } @@ -526,7 +530,7 @@ namespace Microsoft.OpenApi.Models public string Pointer { get; set; } public override string ToString() { } } - public class OpenApiExample : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public class OpenApiExample : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiExample() { } public string Description { get; set; } @@ -536,6 +540,7 @@ namespace Microsoft.OpenApi.Models public string Summary { get; set; } public bool UnresolvedReference { get; set; } public Microsoft.OpenApi.Any.IOpenApiAny Value { get; set; } + public Microsoft.OpenApi.Models.OpenApiExample GetEffective(Microsoft.OpenApi.Models.OpenApiDocument doc) { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV2WithoutReference(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -558,7 +563,7 @@ namespace Microsoft.OpenApi.Models public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiHeader : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public class OpenApiHeader : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiHeader() { } public bool AllowEmptyValue { get; set; } @@ -575,6 +580,7 @@ namespace Microsoft.OpenApi.Models public Microsoft.OpenApi.Models.OpenApiSchema Schema { get; set; } public Microsoft.OpenApi.Models.ParameterStyle? Style { get; set; } public bool UnresolvedReference { get; set; } + public Microsoft.OpenApi.Models.OpenApiHeader GetEffective(Microsoft.OpenApi.Models.OpenApiDocument doc) { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV2WithoutReference(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -602,7 +608,7 @@ namespace Microsoft.OpenApi.Models public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiLink : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public class OpenApiLink : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiLink() { } public string Description { get; set; } @@ -614,6 +620,7 @@ namespace Microsoft.OpenApi.Models public Microsoft.OpenApi.Models.RuntimeExpressionAnyWrapper RequestBody { get; set; } public Microsoft.OpenApi.Models.OpenApiServer Server { get; set; } public bool UnresolvedReference { get; set; } + public Microsoft.OpenApi.Models.OpenApiLink GetEffective(Microsoft.OpenApi.Models.OpenApiDocument doc) { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV2WithoutReference(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -672,7 +679,7 @@ namespace Microsoft.OpenApi.Models public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiParameter : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public class OpenApiParameter : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiParameter() { } public bool AllowEmptyValue { get; set; } @@ -691,12 +698,13 @@ namespace Microsoft.OpenApi.Models public Microsoft.OpenApi.Models.OpenApiSchema Schema { get; set; } public Microsoft.OpenApi.Models.ParameterStyle? Style { get; set; } public bool UnresolvedReference { get; set; } + public Microsoft.OpenApi.Models.OpenApiParameter GetEffective(Microsoft.OpenApi.Models.OpenApiDocument doc) { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV2WithoutReference(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3WithoutReference(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiPathItem : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public class OpenApiPathItem : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiPathItem() { } public string Description { get; set; } @@ -708,6 +716,7 @@ namespace Microsoft.OpenApi.Models public string Summary { get; set; } public bool UnresolvedReference { get; set; } public void AddOperation(Microsoft.OpenApi.Models.OperationType operationType, Microsoft.OpenApi.Models.OpenApiOperation operation) { } + public Microsoft.OpenApi.Models.OpenApiPathItem GetEffective(Microsoft.OpenApi.Models.OpenApiDocument doc) { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV2WithoutReference(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -721,6 +730,7 @@ namespace Microsoft.OpenApi.Models { public OpenApiReference() { } public string ExternalResource { get; set; } + public Microsoft.OpenApi.Models.OpenApiDocument HostDocument { get; set; } public string Id { get; set; } public bool IsExternal { get; } public bool IsLocal { get; } @@ -730,7 +740,7 @@ namespace Microsoft.OpenApi.Models public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiRequestBody : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public class OpenApiRequestBody : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiRequestBody() { } public System.Collections.Generic.IDictionary Content { get; set; } @@ -739,12 +749,13 @@ namespace Microsoft.OpenApi.Models public Microsoft.OpenApi.Models.OpenApiReference Reference { get; set; } public bool Required { get; set; } public bool UnresolvedReference { get; set; } + public Microsoft.OpenApi.Models.OpenApiRequestBody GetEffective(Microsoft.OpenApi.Models.OpenApiDocument doc) { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV2WithoutReference(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3WithoutReference(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } } - public class OpenApiResponse : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public class OpenApiResponse : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiResponse() { } public System.Collections.Generic.IDictionary Content { get; set; } @@ -754,6 +765,7 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.IDictionary Links { get; set; } public Microsoft.OpenApi.Models.OpenApiReference Reference { get; set; } public bool UnresolvedReference { get; set; } + public Microsoft.OpenApi.Models.OpenApiResponse GetEffective(Microsoft.OpenApi.Models.OpenApiDocument doc) { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV2WithoutReference(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -763,7 +775,7 @@ namespace Microsoft.OpenApi.Models { public OpenApiResponses() { } } - public class OpenApiSchema : Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable + public class OpenApiSchema : Microsoft.OpenApi.Interfaces.IEffective, Microsoft.OpenApi.Interfaces.IOpenApiElement, Microsoft.OpenApi.Interfaces.IOpenApiExtensible, Microsoft.OpenApi.Interfaces.IOpenApiReferenceable, Microsoft.OpenApi.Interfaces.IOpenApiSerializable { public OpenApiSchema() { } public Microsoft.OpenApi.Models.OpenApiSchema AdditionalProperties { get; set; } @@ -805,6 +817,7 @@ namespace Microsoft.OpenApi.Models public bool UnresolvedReference { get; set; } public bool WriteOnly { get; set; } public Microsoft.OpenApi.Models.OpenApiXml Xml { get; set; } + public Microsoft.OpenApi.Models.OpenApiSchema GetEffective(Microsoft.OpenApi.Models.OpenApiDocument doc) { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV2WithoutReference(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } @@ -1206,7 +1219,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 e34a4f9851b0fdc6bd049d600a20ff5a15ebe30b Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Mon, 21 Feb 2022 22:34:19 -0500 Subject: [PATCH 199/288] Removed redundant using --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index e813e72a4..fb785f9e1 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -12,7 +12,6 @@ using System.Text; using System.Threading.Tasks; using System.Text.Json; -using System.Threading.Tasks; using Microsoft.Extensions.Logging; using System.Xml.Linq; using Microsoft.OData.Edm.Csdl; From 2b2bc251d17c1ac9624494d6a3373e5e306fdbba Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 22 Feb 2022 19:11:10 +0300 Subject: [PATCH 200/288] 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 201/288] 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 202/288] 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 203/288] 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 204/288] 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 205/288] 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 206/288] 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 207/288] 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 208/288] 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 209/288] - 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 210/288] - 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 211/288] - 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 212/288] - 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 213/288] - 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 214/288] 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 215/288] 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 216/288] 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 217/288] 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 218/288] 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 219/288] - 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 220/288] - 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 221/288] - 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 222/288] - 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 223/288] - 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 224/288] - 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 225/288] - 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 226/288] - 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 5034952d506ae08837ca75d73fb71940eda070b9 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 3 Mar 2022 18:58:39 +0300 Subject: [PATCH 227/288] Update cmd parameter to accept string values for OpenApi spec version --- src/Microsoft.OpenApi.Hidi/Program.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 95e6f63f2..4fed0cb44 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -25,7 +25,7 @@ static async Task Main(string[] args) var outputOption = new Option("--output", () => new FileInfo("./output"), "The output directory path for the generated file.") { Arity = ArgumentArity.ZeroOrOne }; outputOption.AddAlias("-o"); - var versionOption = new Option("--version", "OpenAPI specification version"); + var versionOption = new Option("--version", "OpenAPI specification version"); versionOption.AddAlias("-v"); var formatOption = new Option("--format", "File format"); @@ -72,7 +72,7 @@ static async Task Main(string[] args) resolveExternalOption, }; - transformCommand.SetHandler ( + transformCommand.SetHandler ( OpenApiService.ProcessOpenApiDocument, descriptionOption, csdlOption, outputOption, versionOption, formatOption, logLevelOption, inlineOption, resolveExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); rootCommand.Add(transformCommand); From 5fbb5683195a2879374c8df0588fa3373b8d44bb Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 3 Mar 2022 19:00:54 +0300 Subject: [PATCH 228/288] Cast string to OpenApiSpecVersion enum value --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 12 ++++--- .../OpenApiSpecVersionExtension.cs | 31 +++++++++++++++++++ 2 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 src/Microsoft.OpenApi.Hidi/OpenApiSpecVersionExtension.cs diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 1f86e3c06..77ddd08c0 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -22,6 +22,7 @@ using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Validations; using Microsoft.OpenApi.Writers; +using static Microsoft.OpenApi.Hidi.OpenApiSpecVersionExtension; namespace Microsoft.OpenApi.Hidi { @@ -31,7 +32,7 @@ public static async Task ProcessOpenApiDocument( string openapi, string csdl, FileInfo output, - OpenApiSpecVersion? version, + string? version, OpenApiFormat? format, LogLevel loglevel, bool inline, @@ -83,13 +84,14 @@ string filterbycollection Stream stream; OpenApiDocument document; OpenApiFormat openApiFormat; + OpenApiSpecVersion? openApiVersion = null; var stopwatch = new Stopwatch(); if (!string.IsNullOrEmpty(csdl)) { // Default to yaml and OpenApiVersion 3 during csdl to OpenApi conversion openApiFormat = format ?? GetOpenApiFormat(csdl, logger); - version ??= OpenApiSpecVersion.OpenApi3_0; + openApiVersion = version.TryParseOpenApiSpecVersion(); stream = await GetStream(csdl, logger); document = await ConvertCsdlToOpenApi(stream); @@ -128,7 +130,7 @@ string filterbycollection } openApiFormat = format ?? GetOpenApiFormat(openapi, logger); - version ??= result.OpenApiDiagnostic.SpecificationVersion; + openApiVersion ??= result.OpenApiDiagnostic.SpecificationVersion; } Func predicate; @@ -185,14 +187,14 @@ string filterbycollection logger.LogTrace("Serializing to OpenApi document using the provided spec version and writer"); stopwatch.Start(); - document.Serialize(writer, (OpenApiSpecVersion)version); + document.Serialize(writer, (OpenApiSpecVersion)openApiVersion); stopwatch.Stop(); logger.LogTrace($"Finished serializing in {stopwatch.ElapsedMilliseconds}ms"); textWriter.Flush(); } - + /// /// Converts CSDL to OpenAPI /// diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiSpecVersionExtension.cs b/src/Microsoft.OpenApi.Hidi/OpenApiSpecVersionExtension.cs new file mode 100644 index 000000000..9b877099e --- /dev/null +++ b/src/Microsoft.OpenApi.Hidi/OpenApiSpecVersionExtension.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +using System; +using System.Linq; + +namespace Microsoft.OpenApi.Hidi +{ + public static class OpenApiSpecVersionExtension + { + public static OpenApiSpecVersion TryParseOpenApiSpecVersion(this string value) + { + if (string.IsNullOrEmpty(value)) + { + throw new InvalidOperationException("Please provide a version"); + } + var res = value.Split('.', StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); + + if (int.TryParse(res, out int result)) + { + + if (result >= 2 || result <= 3) + { + return (OpenApiSpecVersion)result; + } + } + + return OpenApiSpecVersion.OpenApi3_0; // default + } + } +} From 75267c216e5f5e5f3224cf714406301b36cb9410 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 3 Mar 2022 13:09:29 -0500 Subject: [PATCH 229/288] - 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 @@ - + From 50e02ae2c3f46b7c904abcdbb2531888726c579b Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 3 Mar 2022 14:09:51 -0500 Subject: [PATCH 230/288] - fixes branch filter for deploy jobs --- .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 35633cb2f..1551e83b4 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -248,7 +248,7 @@ stages: PathtoPublish: '$(Build.ArtifactStagingDirectory)/Microsoft.OpenApi.Hidi-v$(hidiversion)' - stage: deploy - condition: and(contains(variables['build.sourceBranch'], 'refs/heads/vnext'), succeeded()) + condition: and(contains(variables['build.sourceBranch'], 'refs/heads/master'), succeeded()) dependsOn: build jobs: - deployment: deploy_hidi From e04ae7c08b32d09b8c171774dad6fb4fb66596c5 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 3 Mar 2022 15:06:25 -0500 Subject: [PATCH 231/288] - fixes failing hidi release script for exe --- .azure-pipelines/ci-build.yml | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 1551e83b4..a4af01161 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -265,22 +265,18 @@ 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 + - pwsh: | + $artifactMainDirectory = Get-ChildItem -Filter Microsoft.OpenApi.Hidi-* -Directory -Recurse | select -First 1 + $artifactName = $artifactMainDirectory.Name -replace "Microsoft.OpenApi.Hidi-", "" + #Set Variable $artifactName + Write-Host "##vso[task.setvariable variable=artifactName; isSecret=false; isOutput=true;]$artifactName" + Write-Host "##vso[task.setvariable variable=artifactMainDirectory; isSecret=false; isOutput=true;]$artifactMainDirectory" + displayName: 'Fetch Artifact Name' + - task: NuGetCommand@2 displayName: 'NuGet push' inputs: @@ -296,7 +292,7 @@ stages: tag: '$(artifactName)' title: '$(artifactName)' releaseNotesSource: inline - assets: '$(System.DefaultWorkingDirectory)\**\*.exe' + assets: '$(artifactMainDirectory)\**\*.exe' changeLogType: issueBased - deployment: deploy_lib From da118bf71cfe8899f22b9a771dcec15e26206a92 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 7 Mar 2022 12:06:25 +0300 Subject: [PATCH 232/288] Refactor logic to accept a string as a regular param and rename the extension class --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 4 ++-- ...rsionExtension.cs => OpenApiSpecVersionHelper.cs} | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) rename src/Microsoft.OpenApi.Hidi/{OpenApiSpecVersionExtension.cs => OpenApiSpecVersionHelper.cs} (76%) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 77ddd08c0..952dc0b94 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -22,7 +22,7 @@ using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Validations; using Microsoft.OpenApi.Writers; -using static Microsoft.OpenApi.Hidi.OpenApiSpecVersionExtension; +using static Microsoft.OpenApi.Hidi.OpenApiSpecVersionHelper; namespace Microsoft.OpenApi.Hidi { @@ -91,7 +91,7 @@ string filterbycollection { // Default to yaml and OpenApiVersion 3 during csdl to OpenApi conversion openApiFormat = format ?? GetOpenApiFormat(csdl, logger); - openApiVersion = version.TryParseOpenApiSpecVersion(); + openApiVersion = TryParseOpenApiSpecVersion(version); stream = await GetStream(csdl, logger); document = await ConvertCsdlToOpenApi(stream); diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiSpecVersionExtension.cs b/src/Microsoft.OpenApi.Hidi/OpenApiSpecVersionHelper.cs similarity index 76% rename from src/Microsoft.OpenApi.Hidi/OpenApiSpecVersionExtension.cs rename to src/Microsoft.OpenApi.Hidi/OpenApiSpecVersionHelper.cs index 9b877099e..a78255be2 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiSpecVersionExtension.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiSpecVersionHelper.cs @@ -6,24 +6,24 @@ namespace Microsoft.OpenApi.Hidi { - public static class OpenApiSpecVersionExtension + public static class OpenApiSpecVersionHelper { - public static OpenApiSpecVersion TryParseOpenApiSpecVersion(this string value) + public static OpenApiSpecVersion TryParseOpenApiSpecVersion(string value) { if (string.IsNullOrEmpty(value)) { throw new InvalidOperationException("Please provide a version"); } var res = value.Split('.', StringSplitOptions.RemoveEmptyEntries).FirstOrDefault(); - + if (int.TryParse(res, out int result)) { - if (result >= 2 || result <= 3) + if (result >= 2 && result < 3) { - return (OpenApiSpecVersion)result; + return OpenApiSpecVersion.OpenApi2_0; } - } + } return OpenApiSpecVersion.OpenApi3_0; // default } From 24daf0ceab2bccb8017d2ef78a980f6a054df443 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 8 Mar 2022 14:55:49 +0300 Subject: [PATCH 233/288] Better error handling --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 58 ++++++++++++++------ src/Microsoft.OpenApi.Hidi/Program.cs | 5 +- 2 files changed, 43 insertions(+), 20 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 1f86e3c06..def1afb60 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -22,6 +22,7 @@ using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Validations; using Microsoft.OpenApi.Writers; +using System.Threading; namespace Microsoft.OpenApi.Hidi { @@ -38,7 +39,8 @@ public static async Task ProcessOpenApiDocument( bool resolveexternal, string filterbyoperationids, string filterbytags, - string filterbycollection + string filterbycollection, + CancellationToken cancellationToken ) { var logger = ConfigureLoggerInstance(loglevel); @@ -52,7 +54,11 @@ string filterbycollection } catch (ArgumentNullException ex) { - logger.LogError(ex.Message); +#if DEBUG + logger.LogCritical(ex, ex.Message); +#else + logger.LogCritical(ex.Message); +#endif return; } try @@ -64,19 +70,27 @@ string filterbycollection } catch (ArgumentException ex) { - logger.LogError(ex.Message); +#if DEBUG + logger.LogCritical(ex, ex.Message); +#else + logger.LogCritical(ex.Message); +#endif return; } try { if (output.Exists) { - throw new IOException("The file you're writing to already exists. Please input a new file path."); + throw new IOException($"The file {output} already exists. Please input a new file path."); } } catch (IOException ex) { - logger.LogError(ex.Message); +#if DEBUG + logger.LogCritical(ex, ex.Message); +#else + logger.LogCritical(ex.Message); +#endif return; } @@ -91,12 +105,12 @@ string filterbycollection openApiFormat = format ?? GetOpenApiFormat(csdl, logger); version ??= OpenApiSpecVersion.OpenApi3_0; - stream = await GetStream(csdl, logger); + stream = await GetStream(csdl, logger, cancellationToken); document = await ConvertCsdlToOpenApi(stream); } else { - stream = await GetStream(openapi, logger); + stream = await GetStream(openapi, logger, cancellationToken); // Parsing OpenAPI file stopwatch.Start(); @@ -156,7 +170,7 @@ string filterbycollection } if (!string.IsNullOrEmpty(filterbycollection)) { - var fileStream = await GetStream(filterbycollection, logger); + var fileStream = await GetStream(filterbycollection, logger, cancellationToken); var requestUrls = ParseJsonCollectionFile(fileStream, logger); logger.LogTrace("Creating predicate based on the paths and Http methods defined in the Postman collection."); @@ -245,7 +259,7 @@ public static OpenApiDocument FixReferences(OpenApiDocument document) return doc; } - private static async Task GetStream(string input, ILogger logger) + private static async Task GetStream(string input, ILogger logger, CancellationToken cancellationToken) { var stopwatch = new Stopwatch(); stopwatch.Start(); @@ -263,11 +277,15 @@ private static async Task GetStream(string input, ILogger logger) { DefaultRequestVersion = HttpVersion.Version20 }; - stream = await httpClient.GetStreamAsync(input); + stream = await httpClient.GetStreamAsync(input, cancellationToken); } catch (HttpRequestException ex) { - logger.LogError($"Could not download the file at {input}, reason{ex}"); +#if DEBUG + logger.LogCritical(ex, $"Could not download the file at {input}, reason: {ex.Message}"); +#else + logger.LogCritical($"Could not download the file at {input}, reason: {ex.Message}", input, ex.Message); +#endif return null; } } @@ -286,7 +304,11 @@ ex is UnauthorizedAccessException || ex is SecurityException || ex is NotSupportedException) { - logger.LogError($"Could not open the file at {input}, reason: {ex.Message}"); +#if DEBUG + logger.LogCritical(ex, $"Could not open the file at {input}, reason: {ex.Message}"); +#else + logger.LogCritical($"Could not open the file at {input}, reason: {ex.Message}"); +#endif return null; } } @@ -327,14 +349,14 @@ public static Dictionary> ParseJsonCollectionFile(Stream st return requestUrls; } - internal static async Task ValidateOpenApiDocument(string openapi, LogLevel loglevel) + internal static async Task ValidateOpenApiDocument(string openapi, LogLevel loglevel, CancellationToken cancellationToken) { if (string.IsNullOrEmpty(openapi)) { throw new ArgumentNullException(nameof(openapi)); } var logger = ConfigureLoggerInstance(loglevel); - var stream = await GetStream(openapi, logger); + var stream = await GetStream(openapi, logger, cancellationToken); OpenApiDocument document; logger.LogTrace("Parsing the OpenApi file"); @@ -369,16 +391,16 @@ private static OpenApiFormat GetOpenApiFormat(string input, ILogger logger) private static ILogger ConfigureLoggerInstance(LogLevel loglevel) { // Configure logger options - #if DEBUG +#if DEBUG loglevel = loglevel > LogLevel.Debug ? LogLevel.Debug : loglevel; - #endif +#endif var logger = LoggerFactory.Create((builder) => { builder .AddConsole() - #if DEBUG +#if DEBUG .AddDebug() - #endif +#endif .SetMinimumLevel(loglevel); }).CreateLogger(); diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 95e6f63f2..f3d455e4a 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -3,6 +3,7 @@ using System.CommandLine; using System.IO; +using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; @@ -55,7 +56,7 @@ static async Task Main(string[] args) logLevelOption }; - validateCommand.SetHandler(OpenApiService.ValidateOpenApiDocument, descriptionOption, logLevelOption); + validateCommand.SetHandler(OpenApiService.ValidateOpenApiDocument, descriptionOption, logLevelOption); var transformCommand = new Command("transform") { @@ -72,7 +73,7 @@ static async Task Main(string[] args) resolveExternalOption, }; - transformCommand.SetHandler ( + transformCommand.SetHandler ( OpenApiService.ProcessOpenApiDocument, descriptionOption, csdlOption, outputOption, versionOption, formatOption, logLevelOption, inlineOption, resolveExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); rootCommand.Add(transformCommand); From 0e39178616322b24862fd6d46debe5e37765f2f2 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 8 Mar 2022 16:43:02 +0300 Subject: [PATCH 234/288] Remove string interpolation --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index def1afb60..7b94c4997 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -128,10 +128,13 @@ CancellationToken cancellationToken var context = result.OpenApiDiagnostic; if (context.Errors.Count > 0) { + logger.LogTrace("{timestamp}ms: Parsed OpenAPI with errors. {count} paths found.", stopwatch.ElapsedMilliseconds, document.Paths.Count); + var errorReport = new StringBuilder(); foreach (var error in context.Errors) { + logger.LogError("OpenApi Parsing error: {message}", error.ToString()); errorReport.AppendLine(error.ToString()); } logger.LogError($"{stopwatch.ElapsedMilliseconds}ms: OpenApi Parsing errors {string.Join(Environment.NewLine, context.Errors.Select(e => e.Message).ToArray())}"); @@ -282,9 +285,9 @@ private static async Task GetStream(string input, ILogger logger, Cancel catch (HttpRequestException ex) { #if DEBUG - logger.LogCritical(ex, $"Could not download the file at {input}, reason: {ex.Message}"); + logger.LogCritical(ex, "Could not download the file at {inputPath}, reason: {exMessage}", input, ex.Message); #else - logger.LogCritical($"Could not download the file at {input}, reason: {ex.Message}", input, ex.Message); + logger.LogCritical( "Could not download the file at {inputPath}, reason: {exMessage}", input, ex.Message); #endif return null; } @@ -305,9 +308,9 @@ ex is SecurityException || ex is NotSupportedException) { #if DEBUG - logger.LogCritical(ex, $"Could not open the file at {input}, reason: {ex.Message}"); + logger.LogCritical(ex, "Could not open the file at {inputPath}, reason: {exMessage}", input, ex.Message); #else - logger.LogCritical($"Could not open the file at {input}, reason: {ex.Message}"); + logger.LogCritical("Could not open the file at {inputPath}, reason: {exMessage}", input, ex.Message); #endif return null; } From 7128fb235107e1a589ff338c5fcdef11b6dfc7c2 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 8 Mar 2022 16:54:37 +0300 Subject: [PATCH 235/288] Add a try catch block to catch any exceptions thrown during document validation --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 56 ++++++++++++-------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 7b94c4997..64c228387 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -354,35 +354,49 @@ public static Dictionary> ParseJsonCollectionFile(Stream st internal static async Task ValidateOpenApiDocument(string openapi, LogLevel loglevel, CancellationToken cancellationToken) { - if (string.IsNullOrEmpty(openapi)) - { - throw new ArgumentNullException(nameof(openapi)); - } var logger = ConfigureLoggerInstance(loglevel); - var stream = await GetStream(openapi, logger, cancellationToken); - OpenApiDocument document; - logger.LogTrace("Parsing the OpenApi file"); - document = new OpenApiStreamReader(new OpenApiReaderSettings + try { - RuleSet = ValidationRuleSet.GetDefaultRuleSet() - } - ).Read(stream, out var context); + if (string.IsNullOrEmpty(openapi)) + { + throw new ArgumentNullException(nameof(openapi)); + } + var stream = await GetStream(openapi, logger, cancellationToken); - if (context.Errors.Count != 0) - { - foreach (var error in context.Errors) + OpenApiDocument document; + logger.LogTrace("Parsing the OpenApi file"); + document = new OpenApiStreamReader(new OpenApiReaderSettings { - Console.WriteLine(error.ToString()); + RuleSet = ValidationRuleSet.GetDefaultRuleSet() + } + ).Read(stream, out var context); + + if (context.Errors.Count != 0) + { + foreach (var error in context.Errors) + { + logger.LogError("OpenApi Parsing error: {message}", error.ToString()); + Console.WriteLine(error.ToString()); + } } - } - var statsVisitor = new StatsVisitor(); - var walker = new OpenApiWalker(statsVisitor); - walker.Walk(document); + var statsVisitor = new StatsVisitor(); + var walker = new OpenApiWalker(statsVisitor); + walker.Walk(document); + + logger.LogTrace("Finished walking through the OpenApi document. Generating a statistics report.."); + Console.WriteLine(statsVisitor.GetStatisticsReport()); + } + catch(Exception ex) + { +#if DEBUG + logger.LogCritical(ex, ex.Message); +#else + logger.LogCritical(ex.Message); +#endif + } - logger.LogTrace("Finished walking through the OpenApi document. Generating a statistics report.."); - Console.WriteLine(statsVisitor.GetStatisticsReport()); } private static OpenApiFormat GetOpenApiFormat(string input, ILogger logger) From 37ecce28f8459a5b25987d6a5f71c2ade9677030 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 8 Mar 2022 17:49:47 +0300 Subject: [PATCH 236/288] Clean up code --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 30 ++------------------ 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 64c228387..09ad21d90 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -49,42 +49,18 @@ CancellationToken cancellationToken { if (string.IsNullOrEmpty(openapi) && string.IsNullOrEmpty(csdl)) { - throw new ArgumentNullException("Please input a file path"); + throw new ArgumentException("Please input a file path"); } - } - catch (ArgumentNullException ex) - { -#if DEBUG - logger.LogCritical(ex, ex.Message); -#else - logger.LogCritical(ex.Message); -#endif - return; - } - try - { if(output == null) { - throw new ArgumentException(nameof(output)); + throw new ArgumentNullException(nameof(output)); } - } - catch (ArgumentException ex) - { -#if DEBUG - logger.LogCritical(ex, ex.Message); -#else - logger.LogCritical(ex.Message); -#endif - return; - } - try - { if (output.Exists) { throw new IOException($"The file {output} already exists. Please input a new file path."); } } - catch (IOException ex) + catch (Exception ex) { #if DEBUG logger.LogCritical(ex, ex.Message); From 7defeda67fa9bb2a2efb6bfe93fd4b1a8d0897b9 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 8 Mar 2022 20:47:58 +0300 Subject: [PATCH 237/288] Add a --clean-output parameter for overwriting existing files --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 5 +++++ src/Microsoft.OpenApi.Hidi/Program.cs | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 1f86e3c06..9e50debf2 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -31,6 +31,7 @@ public static async Task ProcessOpenApiDocument( string openapi, string csdl, FileInfo output, + bool cleanoutput, OpenApiSpecVersion? version, OpenApiFormat? format, LogLevel loglevel, @@ -69,6 +70,10 @@ string filterbycollection } try { + if (cleanoutput) + { + output.Delete(); + } if (output.Exists) { throw new IOException("The file you're writing to already exists. Please input a new file path."); diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 95e6f63f2..960031ded 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -25,6 +25,9 @@ static async Task Main(string[] args) var outputOption = new Option("--output", () => new FileInfo("./output"), "The output directory path for the generated file.") { Arity = ArgumentArity.ZeroOrOne }; outputOption.AddAlias("-o"); + var cleanOutputOption = new Option("--clean-output", "Overwrite an existing file"); + cleanOutputOption.AddAlias("-co"); + var versionOption = new Option("--version", "OpenAPI specification version"); versionOption.AddAlias("-v"); @@ -62,6 +65,7 @@ static async Task Main(string[] args) descriptionOption, csdlOption, outputOption, + cleanOutputOption, versionOption, formatOption, logLevelOption, @@ -72,8 +76,8 @@ static async Task Main(string[] args) resolveExternalOption, }; - transformCommand.SetHandler ( - OpenApiService.ProcessOpenApiDocument, descriptionOption, csdlOption, outputOption, versionOption, formatOption, logLevelOption, inlineOption, resolveExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); + transformCommand.SetHandler ( + OpenApiService.ProcessOpenApiDocument, descriptionOption, csdlOption, outputOption, cleanOutputOption, versionOption, formatOption, logLevelOption, inlineOption, resolveExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); rootCommand.Add(transformCommand); rootCommand.Add(validateCommand); From f683b7212d9a3a0fa6228c61b263eec1b9258ae9 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 8 Mar 2022 21:03:34 +0300 Subject: [PATCH 238/288] Add an exit statement and use logger to log errors to the console --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 09ad21d90..ec53b615f 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -353,7 +353,6 @@ internal static async Task ValidateOpenApiDocument(string openapi, LogLevel logl foreach (var error in context.Errors) { logger.LogError("OpenApi Parsing error: {message}", error.ToString()); - Console.WriteLine(error.ToString()); } } @@ -362,7 +361,7 @@ internal static async Task ValidateOpenApiDocument(string openapi, LogLevel logl walker.Walk(document); logger.LogTrace("Finished walking through the OpenApi document. Generating a statistics report.."); - Console.WriteLine(statsVisitor.GetStatisticsReport()); + logger.LogInformation(statsVisitor.GetStatisticsReport()); } catch(Exception ex) { @@ -371,6 +370,7 @@ internal static async Task ValidateOpenApiDocument(string openapi, LogLevel logl #else logger.LogCritical(ex.Message); #endif + return; } } From abd6f508866c9250b292f3e51c681e5d39fdb996 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 8 Mar 2022 21:32:17 +0300 Subject: [PATCH 239/288] Clean up code to bubble up exceptions to the global catch block --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 216 +++++++++---------- 1 file changed, 103 insertions(+), 113 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index ec53b615f..11fe6decc 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -59,131 +59,131 @@ CancellationToken cancellationToken { throw new IOException($"The file {output} already exists. Please input a new file path."); } - } - catch (Exception ex) - { -#if DEBUG - logger.LogCritical(ex, ex.Message); -#else - logger.LogCritical(ex.Message); -#endif - return; - } - Stream stream; - OpenApiDocument document; - OpenApiFormat openApiFormat; - var stopwatch = new Stopwatch(); - - if (!string.IsNullOrEmpty(csdl)) - { - // 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, cancellationToken); - document = await ConvertCsdlToOpenApi(stream); - } - else - { - stream = await GetStream(openapi, logger, cancellationToken); + Stream stream; + OpenApiDocument document; + OpenApiFormat openApiFormat; + var stopwatch = new Stopwatch(); - // Parsing OpenAPI file - stopwatch.Start(); - logger.LogTrace("Parsing OpenApi file"); - var result = new OpenApiStreamReader(new OpenApiReaderSettings + if (!string.IsNullOrEmpty(csdl)) { - ReferenceResolution = resolveexternal ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, - RuleSet = ValidationRuleSet.GetDefaultRuleSet() + // 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, cancellationToken); + document = await ConvertCsdlToOpenApi(stream); } - ).ReadAsync(stream).GetAwaiter().GetResult(); + else + { + stream = await GetStream(openapi, logger, cancellationToken); - document = result.OpenApiDocument; - stopwatch.Stop(); + // Parsing OpenAPI file + stopwatch.Start(); + logger.LogTrace("Parsing OpenApi file"); + var result = new OpenApiStreamReader(new OpenApiReaderSettings + { + ReferenceResolution = resolveexternal ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, + RuleSet = ValidationRuleSet.GetDefaultRuleSet() + } + ).ReadAsync(stream).GetAwaiter().GetResult(); - var context = result.OpenApiDiagnostic; - if (context.Errors.Count > 0) - { - logger.LogTrace("{timestamp}ms: Parsed OpenAPI with errors. {count} paths found.", stopwatch.ElapsedMilliseconds, document.Paths.Count); + document = result.OpenApiDocument; + stopwatch.Stop(); - var errorReport = new StringBuilder(); + var context = result.OpenApiDiagnostic; + if (context.Errors.Count > 0) + { + logger.LogTrace("{timestamp}ms: Parsed OpenAPI with errors. {count} paths found.", stopwatch.ElapsedMilliseconds, document.Paths.Count); - foreach (var error in context.Errors) + var errorReport = new StringBuilder(); + + foreach (var error in context.Errors) + { + logger.LogError("OpenApi Parsing error: {message}", error.ToString()); + errorReport.AppendLine(error.ToString()); + } + logger.LogError($"{stopwatch.ElapsedMilliseconds}ms: OpenApi Parsing errors {string.Join(Environment.NewLine, context.Errors.Select(e => e.Message).ToArray())}"); + } + else { - logger.LogError("OpenApi Parsing error: {message}", error.ToString()); - errorReport.AppendLine(error.ToString()); + logger.LogTrace("{timestamp}ms: Parsed OpenApi successfully. {count} paths found.", stopwatch.ElapsedMilliseconds, document.Paths.Count); } - logger.LogError($"{stopwatch.ElapsedMilliseconds}ms: OpenApi Parsing errors {string.Join(Environment.NewLine, context.Errors.Select(e => e.Message).ToArray())}"); + + openApiFormat = format ?? GetOpenApiFormat(openapi, logger); + version ??= result.OpenApiDiagnostic.SpecificationVersion; } - else + + Func predicate; + + // Check if filter options are provided, then slice the OpenAPI document + if (!string.IsNullOrEmpty(filterbyoperationids) && !string.IsNullOrEmpty(filterbytags)) { - logger.LogTrace("{timestamp}ms: Parsed OpenApi successfully. {count} paths found.", stopwatch.ElapsedMilliseconds, document.Paths.Count); + throw new InvalidOperationException("Cannot filter by operationIds and tags at the same time."); } + if (!string.IsNullOrEmpty(filterbyoperationids)) + { + logger.LogTrace("Creating predicate based on the operationIds supplied."); + predicate = OpenApiFilterService.CreatePredicate(operationIds: filterbyoperationids); - openApiFormat = format ?? GetOpenApiFormat(openapi, logger); - version ??= result.OpenApiDiagnostic.SpecificationVersion; - } - - Func predicate; + logger.LogTrace("Creating subset OpenApi document."); + document = OpenApiFilterService.CreateFilteredDocument(document, predicate); + } + if (!string.IsNullOrEmpty(filterbytags)) + { + logger.LogTrace("Creating predicate based on the tags supplied."); + predicate = OpenApiFilterService.CreatePredicate(tags: filterbytags); - // Check if filter options are provided, then slice the OpenAPI document - if (!string.IsNullOrEmpty(filterbyoperationids) && !string.IsNullOrEmpty(filterbytags)) - { - throw new InvalidOperationException("Cannot filter by operationIds and tags at the same time."); - } - if (!string.IsNullOrEmpty(filterbyoperationids)) - { - logger.LogTrace("Creating predicate based on the operationIds supplied."); - predicate = OpenApiFilterService.CreatePredicate(operationIds: filterbyoperationids); + logger.LogTrace("Creating subset OpenApi document."); + document = OpenApiFilterService.CreateFilteredDocument(document, predicate); + } + if (!string.IsNullOrEmpty(filterbycollection)) + { + var fileStream = await GetStream(filterbycollection, logger, cancellationToken); + var requestUrls = ParseJsonCollectionFile(fileStream, logger); - logger.LogTrace("Creating subset OpenApi document."); - document = OpenApiFilterService.CreateFilteredDocument(document, predicate); - } - if (!string.IsNullOrEmpty(filterbytags)) - { - logger.LogTrace("Creating predicate based on the tags supplied."); - predicate = OpenApiFilterService.CreatePredicate(tags: filterbytags); + logger.LogTrace("Creating predicate based on the paths and Http methods defined in the Postman collection."); + predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source: document); - logger.LogTrace("Creating subset OpenApi document."); - document = OpenApiFilterService.CreateFilteredDocument(document, predicate); - } - if (!string.IsNullOrEmpty(filterbycollection)) - { - var fileStream = await GetStream(filterbycollection, logger, cancellationToken); - var requestUrls = ParseJsonCollectionFile(fileStream, logger); + logger.LogTrace("Creating subset OpenApi document."); + document = OpenApiFilterService.CreateFilteredDocument(document, predicate); + } - logger.LogTrace("Creating predicate based on the paths and Http methods defined in the Postman collection."); - predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source:document); + logger.LogTrace("Creating a new file"); + using var outputStream = output?.Create(); + var textWriter = outputStream != null ? new StreamWriter(outputStream) : Console.Out; - logger.LogTrace("Creating subset OpenApi document."); - document = OpenApiFilterService.CreateFilteredDocument(document, predicate); - } - - logger.LogTrace("Creating a new file"); - using var outputStream = output?.Create(); - var textWriter = outputStream != null ? new StreamWriter(outputStream) : Console.Out; + var settings = new OpenApiWriterSettings() + { + ReferenceInline = inline ? ReferenceInlineSetting.InlineLocalReferences : ReferenceInlineSetting.DoNotInlineReferences + }; - var settings = new OpenApiWriterSettings() - { - ReferenceInline = inline ? ReferenceInlineSetting.InlineLocalReferences : ReferenceInlineSetting.DoNotInlineReferences - }; + IOpenApiWriter writer = openApiFormat switch + { + OpenApiFormat.Json => new OpenApiJsonWriter(textWriter, settings), + OpenApiFormat.Yaml => new OpenApiYamlWriter(textWriter, settings), + _ => throw new ArgumentException("Unknown format"), + }; - IOpenApiWriter writer = openApiFormat switch - { - OpenApiFormat.Json => new OpenApiJsonWriter(textWriter, settings), - OpenApiFormat.Yaml => new OpenApiYamlWriter(textWriter, settings), - _ => throw new ArgumentException("Unknown format"), - }; + logger.LogTrace("Serializing to OpenApi document using the provided spec version and writer"); - logger.LogTrace("Serializing to OpenApi document using the provided spec version and writer"); - - stopwatch.Start(); - document.Serialize(writer, (OpenApiSpecVersion)version); - stopwatch.Stop(); + stopwatch.Start(); + document.Serialize(writer, (OpenApiSpecVersion)version); + stopwatch.Stop(); - logger.LogTrace($"Finished serializing in {stopwatch.ElapsedMilliseconds}ms"); + logger.LogTrace($"Finished serializing in {stopwatch.ElapsedMilliseconds}ms"); - textWriter.Flush(); + textWriter.Flush(); + } + catch (Exception ex) + { +#if DEBUG + logger.LogCritical(ex, ex.Message); +#else + logger.LogCritical(ex.Message); +#endif + return; + } } /// @@ -260,12 +260,7 @@ private static async Task GetStream(string input, ILogger logger, Cancel } catch (HttpRequestException ex) { -#if DEBUG - logger.LogCritical(ex, "Could not download the file at {inputPath}, reason: {exMessage}", input, ex.Message); -#else - logger.LogCritical( "Could not download the file at {inputPath}, reason: {exMessage}", input, ex.Message); -#endif - return null; + throw new InvalidOperationException($"Could not download the file at {input}", ex); } } else @@ -283,12 +278,7 @@ ex is UnauthorizedAccessException || ex is SecurityException || ex is NotSupportedException) { -#if DEBUG - logger.LogCritical(ex, "Could not open the file at {inputPath}, reason: {exMessage}", input, ex.Message); -#else - logger.LogCritical("Could not open the file at {inputPath}, reason: {exMessage}", input, ex.Message); -#endif - return null; + throw new InvalidOperationException($"Could not open the file at {input}", ex); } } stopwatch.Stop(); From 9544806f4dfde6bf97c5d165b8af92baaeac5bd0 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 8 Mar 2022 22:21:04 +0300 Subject: [PATCH 240/288] Add exit codes for process termination handling --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 11fe6decc..2cf1b01ad 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -28,7 +28,7 @@ namespace Microsoft.OpenApi.Hidi { public class OpenApiService { - public static async Task ProcessOpenApiDocument( + public static async Task ProcessOpenApiDocument( string openapi, string csdl, FileInfo output, @@ -174,6 +174,8 @@ CancellationToken cancellationToken logger.LogTrace($"Finished serializing in {stopwatch.ElapsedMilliseconds}ms"); textWriter.Flush(); + + return 0; } catch (Exception ex) { @@ -182,7 +184,7 @@ CancellationToken cancellationToken #else logger.LogCritical(ex.Message); #endif - return; + return 1; } } @@ -318,7 +320,7 @@ public static Dictionary> ParseJsonCollectionFile(Stream st return requestUrls; } - internal static async Task ValidateOpenApiDocument(string openapi, LogLevel loglevel, CancellationToken cancellationToken) + internal static async Task ValidateOpenApiDocument(string openapi, LogLevel loglevel, CancellationToken cancellationToken) { var logger = ConfigureLoggerInstance(loglevel); @@ -352,6 +354,8 @@ internal static async Task ValidateOpenApiDocument(string openapi, LogLevel logl logger.LogTrace("Finished walking through the OpenApi document. Generating a statistics report.."); logger.LogInformation(statsVisitor.GetStatisticsReport()); + + return 0; } catch(Exception ex) { @@ -360,7 +364,7 @@ internal static async Task ValidateOpenApiDocument(string openapi, LogLevel logl #else logger.LogCritical(ex.Message); #endif - return; + return 1; } } From be964247425e09a4f7fb7a4afca0bd8c1d3a8276 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Wed, 9 Mar 2022 00:16:49 -0500 Subject: [PATCH 241/288] f --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 8f1fa2c43..ba8b84e0e 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -64,14 +64,15 @@ CancellationToken cancellationToken Stream stream; OpenApiDocument document; OpenApiFormat openApiFormat; + OpenApiSpecVersion openApiVersion; var stopwatch = new Stopwatch(); if (!string.IsNullOrEmpty(csdl)) { // Default to yaml and OpenApiVersion 3 during csdl to OpenApi conversion openApiFormat = format ?? GetOpenApiFormat(csdl, logger); - version ??= OpenApiSpecVersion.OpenApi3_0; - + openApiVersion = version == null ? OpenApiSpecVersion.OpenApi3_0 : TryParseOpenApiSpecVersion(version); + stream = await GetStream(csdl, logger, cancellationToken); document = await ConvertCsdlToOpenApi(stream); } @@ -112,7 +113,7 @@ CancellationToken cancellationToken } openApiFormat = format ?? GetOpenApiFormat(openapi, logger); - version ??= result.OpenApiDiagnostic.SpecificationVersion; + openApiVersion = version == null ? TryParseOpenApiSpecVersion(version) : result.OpenApiDiagnostic.SpecificationVersion; } Func predicate; @@ -127,14 +128,14 @@ CancellationToken cancellationToken logger.LogTrace("Creating predicate based on the operationIds supplied."); predicate = OpenApiFilterService.CreatePredicate(operationIds: filterbyoperationids); -\ logger.LogTrace("Creating subset OpenApi document."); + logger.LogTrace("Creating subset OpenApi document."); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } if (!string.IsNullOrEmpty(filterbytags)) { logger.LogTrace("Creating predicate based on the tags supplied."); predicate = OpenApiFilterService.CreatePredicate(tags: filterbytags); -\ + logger.LogTrace("Creating subset OpenApi document."); document = OpenApiFilterService.CreateFilteredDocument(document, predicate); } @@ -169,7 +170,7 @@ CancellationToken cancellationToken logger.LogTrace("Serializing to OpenApi document using the provided spec version and writer"); stopwatch.Start(); - document.Serialize(writer, (OpenApiSpecVersion)version); + document.Serialize(writer, openApiVersion); stopwatch.Stop(); logger.LogTrace($"Finished serializing in {stopwatch.ElapsedMilliseconds}ms"); From b785cb9932c0e1cc27e3d8cd996ca83b36e263e9 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 9 Mar 2022 08:38:55 +0300 Subject: [PATCH 242/288] Add a condition for ensuring the output file path exists before cleaning it --- 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 a961a0e8f..e96317943 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -56,7 +56,7 @@ CancellationToken cancellationToken { throw new ArgumentNullException(nameof(output)); } - if (cleanoutput) + if (cleanoutput && output.Exists) { output.Delete(); } From 3be26f5f3010a282810178e814c2a0a0ce8a13c6 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 9 Mar 2022 09:07:50 +0300 Subject: [PATCH 243/288] Package updates --- .github/workflows/ci-cd.yml | 2 +- .github/workflows/codeql-analysis.yml | 2 +- .../Microsoft.OpenApi.Hidi.csproj | 2 +- .../Microsoft.OpenApi.Readers.csproj | 4 ++-- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- .../Microsoft.OpenApi.Tests.csproj | 10 +++++----- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 6f619ca85..8e5cb1f51 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -41,7 +41,7 @@ jobs: - name: Checkout repository id: checkout_repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: token: ${{ secrets.GITHUB_TOKEN }} fetch-depth: 0 diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 1d2d4106d..0adca3d2d 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -14,7 +14,7 @@ jobs: steps: - name: Checkout repository id: checkout_repo - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup .NET uses: actions/setup-dotnet@v2 diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index e33f4777e..2e52659ea 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -32,7 +32,7 @@ - + diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index b4c41e6aa..77b9cad26 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -40,7 +40,7 @@ - + @@ -66,4 +66,4 @@ SRResource.Designer.cs - + \ No newline at end of file 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 086d80d75..7d346009e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -247,7 +247,7 @@ - + diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 360eeea92..aa7f00a17 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -17,11 +17,11 @@ - + - - - + + + all @@ -30,7 +30,7 @@ - + From 6e5d120570c4d8f16a63f86c100c35cf9f80cd6f Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 9 Mar 2022 09:10:09 +0300 Subject: [PATCH 244/288] Bump up system.commandline --- 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 2e52659ea..e1809f275 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -36,7 +36,7 @@ - + From 53748ad035c57b6cb5bb2f49e1d72135929fe88e Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 9 Mar 2022 09:33:17 +0300 Subject: [PATCH 245/288] Code cleanup --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index e1809f275..d9a958db9 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -32,8 +32,8 @@ - - + + From 194576e7e3df29fb387b51fd51aa4c9bd33d99ae Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 10 Mar 2022 22:37:35 +0300 Subject: [PATCH 246/288] Fix exception thrown when OpenSpecVersion is null --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index ba8b84e0e..357152343 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; @@ -113,7 +113,7 @@ CancellationToken cancellationToken } openApiFormat = format ?? GetOpenApiFormat(openapi, logger); - openApiVersion = version == null ? TryParseOpenApiSpecVersion(version) : result.OpenApiDiagnostic.SpecificationVersion; + openApiVersion = version == null ? result.OpenApiDiagnostic.SpecificationVersion : TryParseOpenApiSpecVersion(version); } Func predicate; From af25fe44d1bcffc8a6e544d8d9c30017a0de3cc5 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 10 Mar 2022 22:38:24 +0300 Subject: [PATCH 247/288] Add recursive solution for nested collection item object --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 41 ++++++++++++++------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 357152343..129dfa54b 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; @@ -301,24 +301,41 @@ public static Dictionary> ParseJsonCollectionFile(Stream st logger.LogTrace("Parsing the json collection file into a JsonDocument"); using var document = JsonDocument.Parse(stream); var root = document.RootElement; - var itemElement = root.GetProperty("item"); - foreach (var requestObject in itemElement.EnumerateArray().Select(item => item.GetProperty("request"))) - { - // Fetch list of methods and urls from collection, store them in a dictionary - var path = requestObject.GetProperty("url").GetProperty("raw").ToString(); - var method = requestObject.GetProperty("method").ToString(); - if (!requestUrls.ContainsKey(path)) + requestUrls = Enumerate(root, requestUrls); + + logger.LogTrace("Finished fetching the list of paths and Http methods defined in the Postman collection."); + return requestUrls; + } + + private static Dictionary> Enumerate(JsonElement itemElement, Dictionary> paths) + { + var itemsArray = itemElement.GetProperty("item"); + + foreach (var item in itemsArray.EnumerateArray()) + { + if (item.TryGetProperty("request", out var request)) { - requestUrls.Add(path, new List { method }); + // Fetch list of methods and urls from collection, store them in a dictionary + var path = request.GetProperty("url").GetProperty("raw").ToString(); + var method = request.GetProperty("method").ToString(); + + if (!paths.ContainsKey(path)) + { + paths.Add(path, new List { method }); + } + else + { + paths[path].Add(method); + } } else { - requestUrls[path].Add(method); + Enumerate(item, paths); } } - logger.LogTrace("Finished fetching the list of paths and Http methods defined in the Postman collection."); - return requestUrls; + + return paths; } internal static async Task ValidateOpenApiDocument(string openapi, LogLevel loglevel, CancellationToken cancellationToken) From bc87d1ef003040168fb104c1344886df6aa5ebbc Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 10 Mar 2022 23:23:15 +0300 Subject: [PATCH 248/288] Code refactoring --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 32 ++++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 129dfa54b..eebc5b5dd 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -314,20 +314,26 @@ private static Dictionary> Enumerate(JsonElement itemElemen foreach (var item in itemsArray.EnumerateArray()) { - if (item.TryGetProperty("request", out var request)) + if(item.ValueKind == JsonValueKind.Object) { - // Fetch list of methods and urls from collection, store them in a dictionary - var path = request.GetProperty("url").GetProperty("raw").ToString(); - var method = request.GetProperty("method").ToString(); - - if (!paths.ContainsKey(path)) - { - paths.Add(path, new List { method }); - } - else - { - paths[path].Add(method); - } + if(item.TryGetProperty("request", out var request)) + { + // Fetch list of methods and urls from collection, store them in a dictionary + var path = request.GetProperty("url").GetProperty("raw").ToString(); + var method = request.GetProperty("method").ToString(); + if (!paths.ContainsKey(path)) + { + paths.Add(path, new List { method }); + } + else + { + paths[path].Add(method); + } + } + else + { + Enumerate(item, paths); + } } else { From c666c4ae4b1034b73ef602152bbcb87263bd2099 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 10 Mar 2022 23:23:51 +0300 Subject: [PATCH 249/288] Add nested sample collection file and copy it to output directory --- .../Microsoft.OpenApi.Tests.csproj | 3 + .../UtilityFiles/postmanCollection_ver3.json | 1382 +++++++++++++++++ 2 files changed, 1385 insertions(+) create mode 100644 test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver3.json diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 360eeea92..eea157d2e 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -44,6 +44,9 @@ Always + + Always + Always diff --git a/test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver3.json b/test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver3.json new file mode 100644 index 000000000..2c7637ed7 --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver3.json @@ -0,0 +1,1382 @@ +{ + "info": { + "_postman_id": "6281bdba-62b8-2276-a5d6-268e87f48c89", + "name": "Graph-Collection", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "admin", + "item": [ + { + "name": "/admin", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin" + ] + } + } + }, + { + "name": "/admin", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/healthOverviews", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/healthOverviews", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "healthOverviews" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/healthOverviews", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/healthOverviews", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "healthOverviews" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "healthOverviews", + "{serviceHealth-id}" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "healthOverviews", + "{serviceHealth-id}" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "healthOverviews", + "{serviceHealth-id}" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}/issues", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}/issues", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "healthOverviews", + "{serviceHealth-id}", + "issues" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}/issues", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}/issues", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "healthOverviews", + "{serviceHealth-id}", + "issues" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}/issues/{serviceHealthIssue-id}", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}/issues/{serviceHealthIssue-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "healthOverviews", + "{serviceHealth-id}", + "issues", + "{serviceHealthIssue-id}" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}/issues/{serviceHealthIssue-id}", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}/issues/{serviceHealthIssue-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "healthOverviews", + "{serviceHealth-id}", + "issues", + "{serviceHealthIssue-id}" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}/issues/{serviceHealthIssue-id}", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}/issues/{serviceHealthIssue-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "healthOverviews", + "{serviceHealth-id}", + "issues", + "{serviceHealthIssue-id}" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}/issues/{serviceHealthIssue-id}/microsoft.graph.incidentReport()", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/healthOverviews/{serviceHealth-id}/issues/{serviceHealthIssue-id}/microsoft.graph.incidentReport()", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "healthOverviews", + "{serviceHealth-id}", + "issues", + "{serviceHealthIssue-id}", + "microsoft.graph.incidentReport()" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/issues", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/issues", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "issues" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/issues", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/issues", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "issues" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/issues/{serviceHealthIssue-id}", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/issues/{serviceHealthIssue-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "issues", + "{serviceHealthIssue-id}" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/issues/{serviceHealthIssue-id}", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/issues/{serviceHealthIssue-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "issues", + "{serviceHealthIssue-id}" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/issues/{serviceHealthIssue-id}", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/issues/{serviceHealthIssue-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "issues", + "{serviceHealthIssue-id}" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/issues/{serviceHealthIssue-id}/microsoft.graph.incidentReport()", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/issues/{serviceHealthIssue-id}/microsoft.graph.incidentReport()", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "issues", + "{serviceHealthIssue-id}", + "microsoft.graph.incidentReport()" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/microsoft.graph.archive", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/microsoft.graph.archive", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "microsoft.graph.archive" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/microsoft.graph.favorite", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/microsoft.graph.favorite", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "microsoft.graph.favorite" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/microsoft.graph.markRead", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/microsoft.graph.markRead", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "microsoft.graph.markRead" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/microsoft.graph.markUnread", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/microsoft.graph.markUnread", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "microsoft.graph.markUnread" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/microsoft.graph.unarchive", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/microsoft.graph.unarchive", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "microsoft.graph.unarchive" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/microsoft.graph.unfavorite", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/microsoft.graph.unfavorite", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "microsoft.graph.unfavorite" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "{serviceUpdateMessage-id}" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "{serviceUpdateMessage-id}" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "{serviceUpdateMessage-id}" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachments", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachments", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "{serviceUpdateMessage-id}", + "attachments" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachments", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachments", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "{serviceUpdateMessage-id}", + "attachments" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachments/{serviceAnnouncementAttachment-id}", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachments/{serviceAnnouncementAttachment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "{serviceUpdateMessage-id}", + "attachments", + "{serviceAnnouncementAttachment-id}" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachments/{serviceAnnouncementAttachment-id}", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachments/{serviceAnnouncementAttachment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "{serviceUpdateMessage-id}", + "attachments", + "{serviceAnnouncementAttachment-id}" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachments/{serviceAnnouncementAttachment-id}", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachments/{serviceAnnouncementAttachment-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "{serviceUpdateMessage-id}", + "attachments", + "{serviceAnnouncementAttachment-id}" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachments/{serviceAnnouncementAttachment-id}/content", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachments/{serviceAnnouncementAttachment-id}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "{serviceUpdateMessage-id}", + "attachments", + "{serviceAnnouncementAttachment-id}", + "content" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachments/{serviceAnnouncementAttachment-id}/content", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachments/{serviceAnnouncementAttachment-id}/content", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "{serviceUpdateMessage-id}", + "attachments", + "{serviceAnnouncementAttachment-id}", + "content" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachmentsArchive", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachmentsArchive", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "{serviceUpdateMessage-id}", + "attachmentsArchive" + ] + } + } + }, + { + "name": "/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachmentsArchive", + "request": { + "method": "PUT", + "url": { + "raw": "https://graph.microsoft.com/v1.0/admin/serviceAnnouncement/messages/{serviceUpdateMessage-id}/attachmentsArchive", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "admin", + "serviceAnnouncement", + "messages", + "{serviceUpdateMessage-id}", + "attachmentsArchive" + ] + } + } + } + ] + }, + { + "name": "agreementAcceptances", + "item": [ + { + "name": "/agreementAcceptances", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/agreementAcceptances", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "agreementAcceptances" + ] + } + } + }, + { + "name": "/agreementAcceptances", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/agreementAcceptances", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "agreementAcceptances" + ] + } + } + }, + { + "name": "/agreementAcceptances/{agreementAcceptance-id}", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/agreementAcceptances/{agreementAcceptance-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "agreementAcceptances", + "{agreementAcceptance-id}" + ] + } + } + }, + { + "name": "/agreementAcceptances/{agreementAcceptance-id}", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/agreementAcceptances/{agreementAcceptance-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "agreementAcceptances", + "{agreementAcceptance-id}" + ] + } + } + }, + { + "name": "/agreementAcceptances/{agreementAcceptance-id}", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/agreementAcceptances/{agreementAcceptance-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "agreementAcceptances", + "{agreementAcceptance-id}" + ] + } + } + } + ] + }, + { + "name": "appCatalogs", + "item": [ + { + "name": "/appCatalogs", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/appCatalogs", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "appCatalogs" + ] + } + } + }, + { + "name": "/appCatalogs", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/appCatalogs", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "appCatalogs" + ] + } + } + }, + { + "name": "/appCatalogs/teamsApps", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "appCatalogs", + "teamsApps" + ] + } + } + }, + { + "name": "/appCatalogs/teamsApps", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "appCatalogs", + "teamsApps" + ] + } + } + }, + { + "name": "/appCatalogs/teamsApps/{teamsApp-id}", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{teamsApp-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "appCatalogs", + "teamsApps", + "{teamsApp-id}" + ] + } + } + }, + { + "name": "/appCatalogs/teamsApps/{teamsApp-id}", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{teamsApp-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "appCatalogs", + "teamsApps", + "{teamsApp-id}" + ] + } + } + }, + { + "name": "/appCatalogs/teamsApps/{teamsApp-id}", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{teamsApp-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "appCatalogs", + "teamsApps", + "{teamsApp-id}" + ] + } + } + }, + { + "name": "/appCatalogs/teamsApps/{teamsApp-id}/appDefinitions", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{teamsApp-id}/appDefinitions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "appCatalogs", + "teamsApps", + "{teamsApp-id}", + "appDefinitions" + ] + } + } + }, + { + "name": "/appCatalogs/teamsApps/{teamsApp-id}/appDefinitions", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{teamsApp-id}/appDefinitions", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "appCatalogs", + "teamsApps", + "{teamsApp-id}", + "appDefinitions" + ] + } + } + }, + { + "name": "/appCatalogs/teamsApps/{teamsApp-id}/appDefinitions/{teamsAppDefinition-id}", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{teamsApp-id}/appDefinitions/{teamsAppDefinition-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "appCatalogs", + "teamsApps", + "{teamsApp-id}", + "appDefinitions", + "{teamsAppDefinition-id}" + ] + } + } + }, + { + "name": "/appCatalogs/teamsApps/{teamsApp-id}/appDefinitions/{teamsAppDefinition-id}", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{teamsApp-id}/appDefinitions/{teamsAppDefinition-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "appCatalogs", + "teamsApps", + "{teamsApp-id}", + "appDefinitions", + "{teamsAppDefinition-id}" + ] + } + } + }, + { + "name": "/appCatalogs/teamsApps/{teamsApp-id}/appDefinitions/{teamsAppDefinition-id}", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{teamsApp-id}/appDefinitions/{teamsAppDefinition-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "appCatalogs", + "teamsApps", + "{teamsApp-id}", + "appDefinitions", + "{teamsAppDefinition-id}" + ] + } + } + }, + { + "name": "/appCatalogs/teamsApps/{teamsApp-id}/appDefinitions/{teamsAppDefinition-id}/bot", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{teamsApp-id}/appDefinitions/{teamsAppDefinition-id}/bot", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "appCatalogs", + "teamsApps", + "{teamsApp-id}", + "appDefinitions", + "{teamsAppDefinition-id}", + "bot" + ] + } + } + }, + { + "name": "/appCatalogs/teamsApps/{teamsApp-id}/appDefinitions/{teamsAppDefinition-id}/bot", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{teamsApp-id}/appDefinitions/{teamsAppDefinition-id}/bot", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "appCatalogs", + "teamsApps", + "{teamsApp-id}", + "appDefinitions", + "{teamsAppDefinition-id}", + "bot" + ] + } + } + }, + { + "name": "/appCatalogs/teamsApps/{teamsApp-id}/appDefinitions/{teamsAppDefinition-id}/bot", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/appCatalogs/teamsApps/{teamsApp-id}/appDefinitions/{teamsAppDefinition-id}/bot", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "appCatalogs", + "teamsApps", + "{teamsApp-id}", + "appDefinitions", + "{teamsAppDefinition-id}", + "bot" + ] + } + } + } + ] + } + ] +} \ No newline at end of file From 2a8996d414e3f546c5c885441174dc1a6b223e4f Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 10 Mar 2022 23:24:01 +0300 Subject: [PATCH 250/288] Add unit test --- .../Services/OpenApiFilterServiceTests.cs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs index 78f8ec048..28c259fc6 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs @@ -69,6 +69,23 @@ public void ReturnFilteredOpenApiDocumentBasedOnPostmanCollection() Assert.Equal(3, subsetOpenApiDocument.Paths.Count); } + [Fact] + public void ShouldParseNestedPostmanCollection() + { + // Arrange + var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\postmanCollection_ver3.json"); + var fileInput = new FileInfo(filePath); + var stream = fileInput.OpenRead(); + + // Act + var requestUrls = OpenApiService.ParseJsonCollectionFile(stream, _logger); + var pathCount = requestUrls.Count; + + // Assert + Assert.NotNull(requestUrls); + Assert.Equal(30, pathCount); + } + [Fact] public void ThrowsExceptionWhenUrlsInCollectionAreMissingFromSourceDocument() { From 7ac200e87446bed7a245429c0e0d2a3f22629e0c Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Fri, 11 Mar 2022 23:21:10 -0500 Subject: [PATCH 251/288] Fixed issues related to merge conflicts --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 21 ++++++++++++-------- src/Microsoft.OpenApi.Hidi/Program.cs | 10 +++++++--- src/Microsoft.OpenApi.Hidi/appsettings.json | 7 ------- 3 files changed, 20 insertions(+), 18 deletions(-) delete mode 100644 src/Microsoft.OpenApi.Hidi/appsettings.json diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index ba8b84e0e..3d38ea678 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -71,8 +71,8 @@ CancellationToken cancellationToken { // Default to yaml and OpenApiVersion 3 during csdl to OpenApi conversion openApiFormat = format ?? GetOpenApiFormat(csdl, logger); - openApiVersion = version == null ? OpenApiSpecVersion.OpenApi3_0 : TryParseOpenApiSpecVersion(version); - + openApiVersion = version != null ? TryParseOpenApiSpecVersion(version) : OpenApiSpecVersion.OpenApi3_0; + stream = await GetStream(csdl, logger, cancellationToken); document = await ConvertCsdlToOpenApi(stream); } @@ -113,7 +113,7 @@ CancellationToken cancellationToken } openApiFormat = format ?? GetOpenApiFormat(openapi, logger); - openApiVersion = version == null ? TryParseOpenApiSpecVersion(version) : result.OpenApiDiagnostic.SpecificationVersion; + openApiVersion = version != null ? TryParseOpenApiSpecVersion(version) : result.OpenApiDiagnostic.SpecificationVersion; } Func predicate; @@ -181,9 +181,10 @@ CancellationToken cancellationToken catch (Exception ex) { #if DEBUG - logger.LogCritical(ex, ex.Message); + logger.LogCritical(ex, ex.Message); #else logger.LogCritical(ex.Message); + #endif return 1; } @@ -335,12 +336,14 @@ internal static async Task ValidateOpenApiDocument(string openapi, LogLevel OpenApiDocument document; logger.LogTrace("Parsing the OpenApi file"); - document = new OpenApiStreamReader(new OpenApiReaderSettings + var result = await new OpenApiStreamReader(new OpenApiReaderSettings { RuleSet = ValidationRuleSet.GetDefaultRuleSet() } - ).Read(stream, out var context); + ).ReadAsync(stream); + document = result.OpenApiDocument; + var context = result.OpenApiDiagnostic; if (context.Errors.Count != 0) { foreach (var error in context.Errors) @@ -355,7 +358,7 @@ internal static async Task ValidateOpenApiDocument(string openapi, LogLevel logger.LogTrace("Finished walking through the OpenApi document. Generating a statistics report.."); logger.LogInformation(statsVisitor.GetStatisticsReport()); - + return 0; } catch(Exception ex) @@ -385,7 +388,9 @@ private static ILogger ConfigureLoggerInstance(LogLevel loglevel) var logger = LoggerFactory.Create((builder) => { builder - .AddConsole() + .AddConsole(c => { + c.LogToStandardErrorThreshold = LogLevel.Error; + }) #if DEBUG .AddDebug() #endif diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 24abb4a98..4fcf3f16b 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. +using System; using System.CommandLine; using System.IO; using System.Threading; @@ -11,7 +12,7 @@ namespace Microsoft.OpenApi.Hidi { static class Program { - static async Task Main(string[] args) + static async Task Main(string[] args) { var rootCommand = new RootCommand() { }; @@ -32,7 +33,7 @@ static async Task Main(string[] args) var formatOption = new Option("--format", "File format"); formatOption.AddAlias("-f"); - var logLevelOption = new Option("--loglevel", () => LogLevel.Warning, "The log level to use when logging messages to the main output."); + var logLevelOption = new Option("--loglevel", () => LogLevel.Information, "The log level to use when logging messages to the main output."); logLevelOption.AddAlias("-ll"); var filterByOperationIdsOption = new Option("--filter-by-operationids", "Filters OpenApiDocument by OperationId(s) provided"); @@ -80,7 +81,10 @@ static async Task Main(string[] args) rootCommand.Add(validateCommand); // Parse the incoming args and invoke the handler - return await rootCommand.InvokeAsync(args); + await rootCommand.InvokeAsync(args); + + //// Wait for logger to write messages to the console before exiting + await Task.Delay(10); } } } diff --git a/src/Microsoft.OpenApi.Hidi/appsettings.json b/src/Microsoft.OpenApi.Hidi/appsettings.json deleted file mode 100644 index 882248cf8..000000000 --- a/src/Microsoft.OpenApi.Hidi/appsettings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "Logging": { - "LogLevel": { - "Default": "Debug" - } - } -} \ No newline at end of file From f1b3f3b8d40d8d697611ab6033a1c433d0c411db Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sun, 13 Mar 2022 18:05:58 -0400 Subject: [PATCH 252/288] Added scope to tracing --- .../Microsoft.OpenApi.Hidi.csproj | 2 +- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 417 ++++++++++-------- src/Microsoft.OpenApi.Hidi/Program.cs | 2 +- 3 files changed, 234 insertions(+), 187 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index e33f4777e..b501e2cd2 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/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 3d38ea678..e4da1c900 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -29,7 +29,10 @@ namespace Microsoft.OpenApi.Hidi { public class OpenApiService { - public static async Task ProcessOpenApiDocument( + /// + /// Implementation of the transform command + /// + public static async Task TransformOpenApiDocument( string openapi, string csdl, FileInfo output, @@ -69,127 +72,210 @@ CancellationToken cancellationToken if (!string.IsNullOrEmpty(csdl)) { - // Default to yaml and OpenApiVersion 3 during csdl to OpenApi conversion - openApiFormat = format ?? GetOpenApiFormat(csdl, logger); - openApiVersion = version != null ? TryParseOpenApiSpecVersion(version) : OpenApiSpecVersion.OpenApi3_0; - - stream = await GetStream(csdl, logger, cancellationToken); - document = await ConvertCsdlToOpenApi(stream); + using (logger.BeginScope($"Convert CSDL: {csdl}", csdl)) + { + stopwatch.Start(); + // Default to yaml and OpenApiVersion 3 during csdl to OpenApi conversion + openApiFormat = format ?? GetOpenApiFormat(csdl, logger); + openApiVersion = version != null ? TryParseOpenApiSpecVersion(version) : OpenApiSpecVersion.OpenApi3_0; + + stream = await GetStream(csdl, logger, cancellationToken); + document = await ConvertCsdlToOpenApi(stream); + stopwatch.Stop(); + logger.LogTrace("{timestamp}ms: Generated OpenAPI with {paths} paths.", stopwatch.ElapsedMilliseconds, document.Paths.Count); + } } else { stream = await GetStream(openapi, logger, cancellationToken); - // Parsing OpenAPI file - stopwatch.Start(); - logger.LogTrace("Parsing OpenApi file"); - var result = await new OpenApiStreamReader(new OpenApiReaderSettings + using (logger.BeginScope($"Parse OpenAPI: {openapi}",openapi)) { - ReferenceResolution = resolveexternal ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, - RuleSet = ValidationRuleSet.GetDefaultRuleSet() - } - ).ReadAsync(stream); + stopwatch.Restart(); + var result = await new OpenApiStreamReader(new OpenApiReaderSettings + { + ReferenceResolution = resolveexternal ? ReferenceResolutionSetting.ResolveAllReferences : ReferenceResolutionSetting.ResolveLocalReferences, + RuleSet = ValidationRuleSet.GetDefaultRuleSet() + } + ).ReadAsync(stream); - document = result.OpenApiDocument; - stopwatch.Stop(); + document = result.OpenApiDocument; - var context = result.OpenApiDiagnostic; - if (context.Errors.Count > 0) - { - logger.LogTrace("{timestamp}ms: Parsed OpenAPI with errors. {count} paths found.", stopwatch.ElapsedMilliseconds, document.Paths.Count); + var context = result.OpenApiDiagnostic; + if (context.Errors.Count > 0) + { + logger.LogTrace("{timestamp}ms: Parsed OpenAPI with errors. {count} paths found.", stopwatch.ElapsedMilliseconds, document.Paths.Count); - var errorReport = new StringBuilder(); + var errorReport = new StringBuilder(); - foreach (var error in context.Errors) + foreach (var error in context.Errors) + { + logger.LogError("OpenApi Parsing error: {message}", error.ToString()); + errorReport.AppendLine(error.ToString()); + } + logger.LogError($"{stopwatch.ElapsedMilliseconds}ms: OpenApi Parsing errors {string.Join(Environment.NewLine, context.Errors.Select(e => e.Message).ToArray())}"); + } + else { - logger.LogError("OpenApi Parsing error: {message}", error.ToString()); - errorReport.AppendLine(error.ToString()); + logger.LogTrace("{timestamp}ms: Parsed OpenApi successfully. {count} paths found.", stopwatch.ElapsedMilliseconds, document.Paths.Count); } - logger.LogError($"{stopwatch.ElapsedMilliseconds}ms: OpenApi Parsing errors {string.Join(Environment.NewLine, context.Errors.Select(e => e.Message).ToArray())}"); + + openApiFormat = format ?? GetOpenApiFormat(openapi, logger); + openApiVersion = version != null ? TryParseOpenApiSpecVersion(version) : result.OpenApiDiagnostic.SpecificationVersion; + stopwatch.Stop(); } - else + } + + using (logger.BeginScope("Filter")) + { + Func predicate = null; + + // Check if filter options are provided, then slice the OpenAPI document + if (!string.IsNullOrEmpty(filterbyoperationids) && !string.IsNullOrEmpty(filterbytags)) { - logger.LogTrace("{timestamp}ms: Parsed OpenApi successfully. {count} paths found.", stopwatch.ElapsedMilliseconds, document.Paths.Count); + throw new InvalidOperationException("Cannot filter by operationIds and tags at the same time."); } + if (!string.IsNullOrEmpty(filterbyoperationids)) + { + logger.LogTrace("Creating predicate based on the operationIds supplied."); + predicate = OpenApiFilterService.CreatePredicate(operationIds: filterbyoperationids); - openApiFormat = format ?? GetOpenApiFormat(openapi, logger); - openApiVersion = version != null ? TryParseOpenApiSpecVersion(version) : result.OpenApiDiagnostic.SpecificationVersion; - } + } + if (!string.IsNullOrEmpty(filterbytags)) + { + logger.LogTrace("Creating predicate based on the tags supplied."); + predicate = OpenApiFilterService.CreatePredicate(tags: filterbytags); - Func predicate; + } + if (!string.IsNullOrEmpty(filterbycollection)) + { + var fileStream = await GetStream(filterbycollection, logger, cancellationToken); + var requestUrls = ParseJsonCollectionFile(fileStream, logger); - // Check if filter options are provided, then slice the OpenAPI document - if (!string.IsNullOrEmpty(filterbyoperationids) && !string.IsNullOrEmpty(filterbytags)) - { - throw new InvalidOperationException("Cannot filter by operationIds and tags at the same time."); + logger.LogTrace("Creating predicate based on the paths and Http methods defined in the Postman collection."); + predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source: document); + } + if (predicate != null) + { + stopwatch.Restart(); + document = OpenApiFilterService.CreateFilteredDocument(document, predicate); + stopwatch.Stop(); + logger.LogTrace("{timestamp}ms: Creating filtered OpenApi document with {paths} paths.", stopwatch.ElapsedMilliseconds, document.Paths.Count); + } } - if (!string.IsNullOrEmpty(filterbyoperationids)) - { - logger.LogTrace("Creating predicate based on the operationIds supplied."); - predicate = OpenApiFilterService.CreatePredicate(operationIds: filterbyoperationids); - logger.LogTrace("Creating subset OpenApi document."); - document = OpenApiFilterService.CreateFilteredDocument(document, predicate); - } - if (!string.IsNullOrEmpty(filterbytags)) + using (logger.BeginScope("Output")) { - logger.LogTrace("Creating predicate based on the tags supplied."); - predicate = OpenApiFilterService.CreatePredicate(tags: filterbytags); + ; + using var outputStream = output?.Create(); + var textWriter = outputStream != null ? new StreamWriter(outputStream) : Console.Out; - logger.LogTrace("Creating subset OpenApi document."); - document = OpenApiFilterService.CreateFilteredDocument(document, predicate); - } - if (!string.IsNullOrEmpty(filterbycollection)) - { - var fileStream = await GetStream(filterbycollection, logger, cancellationToken); - var requestUrls = ParseJsonCollectionFile(fileStream, logger); + var settings = new OpenApiWriterSettings() + { + ReferenceInline = inline ? ReferenceInlineSetting.InlineLocalReferences : ReferenceInlineSetting.DoNotInlineReferences + }; + + IOpenApiWriter writer = openApiFormat switch + { + OpenApiFormat.Json => new OpenApiJsonWriter(textWriter, settings), + OpenApiFormat.Yaml => new OpenApiYamlWriter(textWriter, settings), + _ => throw new ArgumentException("Unknown format"), + }; + + logger.LogTrace("Serializing to OpenApi document using the provided spec version and writer"); - logger.LogTrace("Creating predicate based on the paths and Http methods defined in the Postman collection."); - predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source: document); + stopwatch.Start(); + document.Serialize(writer, openApiVersion); + stopwatch.Stop(); - logger.LogTrace("Creating subset OpenApi document."); - document = OpenApiFilterService.CreateFilteredDocument(document, predicate); + logger.LogTrace($"Finished serializing in {stopwatch.ElapsedMilliseconds}ms"); + textWriter.Flush(); } + return 0; + } + catch (Exception ex) + { +#if DEBUG + logger.LogCritical(ex, ex.Message); +#else + logger.LogCritical(ex.Message); + +#endif + return 1; + } + } - logger.LogTrace("Creating a new file"); - using var outputStream = output?.Create(); - var textWriter = outputStream != null ? new StreamWriter(outputStream) : Console.Out; + /// + /// Implementation of the validate command + /// + public static async Task ValidateOpenApiDocument( + string openapi, + LogLevel loglevel, + CancellationToken cancellationToken) + { + var logger = ConfigureLoggerInstance(loglevel); - var settings = new OpenApiWriterSettings() + try + { + if (string.IsNullOrEmpty(openapi)) { - ReferenceInline = inline ? ReferenceInlineSetting.InlineLocalReferences : ReferenceInlineSetting.DoNotInlineReferences - }; + throw new ArgumentNullException(nameof(openapi)); + } + var stream = await GetStream(openapi, logger, cancellationToken); - IOpenApiWriter writer = openApiFormat switch + OpenApiDocument document; + Stopwatch stopwatch = Stopwatch.StartNew(); + using (logger.BeginScope($"Parsing OpenAPI: {openapi}", openapi)) { - OpenApiFormat.Json => new OpenApiJsonWriter(textWriter, settings), - OpenApiFormat.Yaml => new OpenApiYamlWriter(textWriter, settings), - _ => throw new ArgumentException("Unknown format"), - }; + stopwatch.Start(); + + var result = await new OpenApiStreamReader(new OpenApiReaderSettings + { + RuleSet = ValidationRuleSet.GetDefaultRuleSet() + } + ).ReadAsync(stream); - logger.LogTrace("Serializing to OpenApi document using the provided spec version and writer"); + logger.LogTrace("{timestamp}ms: Completed parsing.", stopwatch.ElapsedMilliseconds); - stopwatch.Start(); - document.Serialize(writer, openApiVersion); - stopwatch.Stop(); + document = result.OpenApiDocument; + var context = result.OpenApiDiagnostic; + if (context.Errors.Count != 0) + { + using (logger.BeginScope("Detected errors")) + { + foreach (var error in context.Errors) + { + logger.LogError(error.ToString()); + } + } + } + stopwatch.Stop(); + } - logger.LogTrace($"Finished serializing in {stopwatch.ElapsedMilliseconds}ms"); - textWriter.Flush(); + using (logger.BeginScope("Calculating statistics")) + { + var statsVisitor = new StatsVisitor(); + var walker = new OpenApiWalker(statsVisitor); + walker.Walk(document); + + logger.LogTrace("Finished walking through the OpenApi document. Generating a statistics report.."); + logger.LogInformation(statsVisitor.GetStatisticsReport()); + } return 0; } catch (Exception ex) { -#if DEBUG - logger.LogCritical(ex, ex.Message); +#if DEBUG + logger.LogCritical(ex, ex.Message); #else logger.LogCritical(ex.Message); - #endif return 1; - } + } + } - + /// /// Converts CSDL to OpenAPI /// @@ -225,71 +311,6 @@ public static async Task 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. - // 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 async Task GetStream(string input, ILogger logger, CancellationToken cancellationToken) - { - var stopwatch = new Stopwatch(); - stopwatch.Start(); - - Stream stream; - if (input.StartsWith("http")) - { - try - { - var httpClientHandler = new HttpClientHandler() - { - SslProtocols = System.Security.Authentication.SslProtocols.Tls12, - }; - using var httpClient = new HttpClient(httpClientHandler) - { - DefaultRequestVersion = HttpVersion.Version20 - }; - stream = await httpClient.GetStreamAsync(input, cancellationToken); - } - catch (HttpRequestException ex) - { - throw new InvalidOperationException($"Could not download the file at {input}", ex); - } - } - else - { - try - { - var fileInput = new FileInfo(input); - stream = fileInput.OpenRead(); - } - catch (Exception ex) when (ex is FileNotFoundException || - ex is PathTooLongException || - ex is DirectoryNotFoundException || - ex is IOException || - ex is UnauthorizedAccessException || - ex is SecurityException || - ex is NotSupportedException) - { - throw new InvalidOperationException($"Could not open the file at {input}", ex); - } - } - stopwatch.Stop(); - logger.LogTrace("{timestamp}ms: Read file {input}", stopwatch.ElapsedMilliseconds, input); - return stream; - } - /// /// Takes in a file stream, parses the stream into a JsonDocument and gets a list of paths and Http methods /// @@ -322,57 +343,83 @@ public static Dictionary> ParseJsonCollectionFile(Stream st return requestUrls; } - internal static async Task ValidateOpenApiDocument(string openapi, LogLevel loglevel, CancellationToken cancellationToken) + /// + /// Fixes the references in the resulting OpenApiDocument. + /// + /// The converted OpenApiDocument. + /// A valid OpenApiDocument instance. + private static OpenApiDocument FixReferences(OpenApiDocument document) { - var logger = ConfigureLoggerInstance(loglevel); + // 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. - try + var sb = new StringBuilder(); + document.SerializeAsV3(new OpenApiYamlWriter(new StringWriter(sb))); + var doc = new OpenApiStringReader().Read(sb.ToString(), out _); + + return doc; + } + + /// + /// Reads stream from file system or makes HTTP request depending on the input string + /// + private static async Task GetStream(string input, ILogger logger, CancellationToken cancellationToken) + { + Stream stream; + using (logger.BeginScope("Reading input stream")) { - if (string.IsNullOrEmpty(openapi)) - { - throw new ArgumentNullException(nameof(openapi)); - } - var stream = await GetStream(openapi, logger, cancellationToken); + var stopwatch = new Stopwatch(); + stopwatch.Start(); - OpenApiDocument document; - logger.LogTrace("Parsing the OpenApi file"); - var result = await new OpenApiStreamReader(new OpenApiReaderSettings + if (input.StartsWith("http")) { - RuleSet = ValidationRuleSet.GetDefaultRuleSet() + try + { + var httpClientHandler = new HttpClientHandler() + { + SslProtocols = System.Security.Authentication.SslProtocols.Tls12, + }; + using var httpClient = new HttpClient(httpClientHandler) + { + DefaultRequestVersion = HttpVersion.Version20 + }; + stream = await httpClient.GetStreamAsync(input, cancellationToken); + } + catch (HttpRequestException ex) + { + throw new InvalidOperationException($"Could not download the file at {input}", ex); + } } - ).ReadAsync(stream); - - document = result.OpenApiDocument; - var context = result.OpenApiDiagnostic; - if (context.Errors.Count != 0) + else { - foreach (var error in context.Errors) + try + { + var fileInput = new FileInfo(input); + stream = fileInput.OpenRead(); + } + catch (Exception ex) when (ex is FileNotFoundException || + ex is PathTooLongException || + ex is DirectoryNotFoundException || + ex is IOException || + ex is UnauthorizedAccessException || + ex is SecurityException || + ex is NotSupportedException) { - logger.LogError("OpenApi Parsing error: {message}", error.ToString()); + throw new InvalidOperationException($"Could not open the file at {input}", ex); } } - - var statsVisitor = new StatsVisitor(); - var walker = new OpenApiWalker(statsVisitor); - walker.Walk(document); - - logger.LogTrace("Finished walking through the OpenApi document. Generating a statistics report.."); - logger.LogInformation(statsVisitor.GetStatisticsReport()); - - return 0; - } - catch(Exception ex) - { -#if DEBUG - logger.LogCritical(ex, ex.Message); -#else - logger.LogCritical(ex.Message); -#endif - return 1; + stopwatch.Stop(); + logger.LogTrace("{timestamp}ms: Read file {input}", stopwatch.ElapsedMilliseconds, input); } - + return stream; } + /// + /// Attempt to guess OpenAPI format based in input URL + /// + /// + /// + /// private static OpenApiFormat GetOpenApiFormat(string input, ILogger logger) { logger.LogTrace("Getting the OpenApi format"); @@ -388,10 +435,10 @@ private static ILogger ConfigureLoggerInstance(LogLevel loglevel) var logger = LoggerFactory.Create((builder) => { builder - .AddConsole(c => { - c.LogToStandardErrorThreshold = LogLevel.Error; + .AddSimpleConsole(c => { + c.IncludeScopes = true; }) -#if DEBUG +#if DEBUG .AddDebug() #endif .SetMinimumLevel(loglevel); diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 4fcf3f16b..efbf7fea6 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -75,7 +75,7 @@ static async Task Main(string[] args) }; transformCommand.SetHandler ( - OpenApiService.ProcessOpenApiDocument, descriptionOption, csdlOption, outputOption, versionOption, formatOption, logLevelOption, inlineOption, resolveExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); + OpenApiService.TransformOpenApiDocument, descriptionOption, csdlOption, outputOption, versionOption, formatOption, logLevelOption, inlineOption, resolveExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); rootCommand.Add(transformCommand); rootCommand.Add(validateCommand); From df0fb111c82e8cd97f5f725888178ae5fbe33f37 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sun, 13 Mar 2022 21:31:16 -0400 Subject: [PATCH 253/288] Fixed input parameters of transform --- 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 e9a1bc318..ac39aaad4 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -79,7 +79,7 @@ static async Task Main(string[] args) }; transformCommand.SetHandler ( - OpenApiService.TransformOpenApiDocument, descriptionOption, csdlOption, outputOption, versionOption, formatOption, logLevelOption, inlineOption, resolveExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); + OpenApiService.TransformOpenApiDocument, descriptionOption, csdlOption, outputOption, cleanOutputOption, versionOption, formatOption, logLevelOption, inlineOption, resolveExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); rootCommand.Add(transformCommand); rootCommand.Add(validateCommand); From 3350d86bab72a22bd84372ea2ccfbe82a2575f7d Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 14 Mar 2022 09:37:54 +0300 Subject: [PATCH 254/288] Rename method --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index eebc5b5dd..d68daea80 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -302,13 +302,13 @@ public static Dictionary> ParseJsonCollectionFile(Stream st using var document = JsonDocument.Parse(stream); var root = document.RootElement; - requestUrls = Enumerate(root, requestUrls); - + requestUrls = EnumerateJsonDocument(root, requestUrls); logger.LogTrace("Finished fetching the list of paths and Http methods defined in the Postman collection."); + return requestUrls; } - private static Dictionary> Enumerate(JsonElement itemElement, Dictionary> paths) + private static Dictionary> EnumerateJsonDocument(JsonElement itemElement, Dictionary> paths) { var itemsArray = itemElement.GetProperty("item"); @@ -332,12 +332,12 @@ private static Dictionary> Enumerate(JsonElement itemElemen } else { - Enumerate(item, paths); + EnumerateJsonDocument(item, paths); } } else { - Enumerate(item, paths); + EnumerateJsonDocument(item, paths); } } From 3445c1d3199ebd8dc598d8d08a05f27904b4faca Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Tue, 15 Mar 2022 11:32:05 +0300 Subject: [PATCH 255/288] Log warning to console if url in collection isn't in the input OpenApi doc and continue processing the rest of the urls and add unit test --- .../Services/OpenApiFilterService.cs | 1 + .../Microsoft.OpenApi.Tests.csproj | 3 + .../Services/OpenApiFilterServiceTests.cs | 22 +++ .../UtilityFiles/postmanCollection_ver4.json | 145 ++++++++++++++++++ 4 files changed, 171 insertions(+) create mode 100644 test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver4.json diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 7b9111e4d..57c5fef09 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -81,6 +81,7 @@ public static class OpenApiFilterService var openApiOperations = GetOpenApiOperations(rootNode, url, apiVersion); if (openApiOperations == null) { + Console.WriteLine($"The url {url} could not be found in the OpenApi description"); continue; } diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index eea157d2e..a187a2887 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -47,6 +47,9 @@ Always + + Always + Always diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs index 28c259fc6..29cb684d2 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiFilterServiceTests.cs @@ -103,6 +103,28 @@ public void ThrowsExceptionWhenUrlsInCollectionAreMissingFromSourceDocument() Assert.Equal("The urls in the Postman collection supplied could not be found.", message); } + [Fact] + public void ContinueProcessingWhenUrlsInCollectionAreMissingFromSourceDocument() + { + // Arrange + var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles\\postmanCollection_ver4.json"); + var fileInput = new FileInfo(filePath); + var stream = fileInput.OpenRead(); + + // Act + var requestUrls = OpenApiService.ParseJsonCollectionFile(stream, _logger); + var pathCount = requestUrls.Count; + var predicate = OpenApiFilterService.CreatePredicate(requestUrls: requestUrls, source: _openApiDocumentMock); + var subsetOpenApiDocument = OpenApiFilterService.CreateFilteredDocument(_openApiDocumentMock, predicate); + var subsetPathCount = subsetOpenApiDocument.Paths.Count; + + // Assert + Assert.NotNull(subsetOpenApiDocument); + Assert.NotEmpty(subsetOpenApiDocument.Paths); + Assert.Equal(2, subsetPathCount); + Assert.NotEqual(pathCount, subsetPathCount); + } + [Fact] public void ThrowsInvalidOperationExceptionInCreatePredicateWhenInvalidArgumentsArePassed() { diff --git a/test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver4.json b/test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver4.json new file mode 100644 index 000000000..edafeb0bd --- /dev/null +++ b/test/Microsoft.OpenApi.Tests/UtilityFiles/postmanCollection_ver4.json @@ -0,0 +1,145 @@ +{ + "info": { + "_postman_id": "43402ca3-f018-7c9b-2315-f176d9b171a3", + "name": "Graph-Collection", + "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" + }, + "item": [ + { + "name": "users-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users" + ] + } + } + }, + { + "name": "users-POST", + "request": { + "method": "POST", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users" + ] + } + } + }, + { + "name": "/appCatalogs", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/appCatalogs", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "appCatalogs" + ] + } + } + }, + { + "name": "/agreementAcceptances", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/agreementAcceptances", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "agreementAcceptances" + ] + } + } + }, + { + "name": "{user-id}-GET", + "request": { + "method": "GET", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}" + ] + } + } + }, + { + "name": "{user-id}-PATCH", + "request": { + "method": "PATCH", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}" + ] + } + } + }, + { + "name": "{user-id}-DELETE", + "request": { + "method": "DELETE", + "url": { + "raw": "https://graph.microsoft.com/v1.0/users/{user-id}", + "protocol": "https", + "host": [ + "graph", + "microsoft", + "com" + ], + "path": [ + "v1.0", + "users", + "{user-id}" + ] + } + } + } + ] +} \ No newline at end of file From 19a9c73da2abc13d237d00fa09e7f82656336e84 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 16 Mar 2022 18:24:41 +0300 Subject: [PATCH 256/288] Update powershell script to fetch Hidi version number and use the output variables in the release notes --- .azure-pipelines/ci-build.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index a4af01161..3d21b83ee 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -270,11 +270,11 @@ stages: inputs: source: current - pwsh: | - $artifactMainDirectory = Get-ChildItem -Filter Microsoft.OpenApi.Hidi-* -Directory -Recurse | select -First 1 - $artifactName = $artifactMainDirectory.Name -replace "Microsoft.OpenApi.Hidi-", "" - #Set Variable $artifactName - Write-Host "##vso[task.setvariable variable=artifactName; isSecret=false; isOutput=true;]$artifactName" - Write-Host "##vso[task.setvariable variable=artifactMainDirectory; isSecret=false; isOutput=true;]$artifactMainDirectory" + $artifactName = Get-ChildItem -Path $(Pipeline.Workspace) -Filter Microsoft.OpenApi.Hidi-* -recurse | select -First 1 + $artifactVersion= $artifactName -replace "Microsoft.OpenApi.Hidi-", "" + #Set Variable $artifactName and $artifactVersion + Write-Host "##vso[task.setvariable variable=artifactVersion; isSecret=false; isOutput=true]$artifactVersion" + Write-Host "##vso[task.setvariable variable=artifactName; isSecret=false; isOutput=true]$artifactName.FullName" displayName: 'Fetch Artifact Name' - task: NuGetCommand@2 @@ -289,10 +289,10 @@ stages: inputs: gitHubConnection: 'Github-MaggieKimani1' tagSource: userSpecifiedTag - tag: '$(artifactName)' + tag: '$(artifactVersion)' title: '$(artifactName)' releaseNotesSource: inline - assets: '$(artifactMainDirectory)\**\*.exe' + assets: '$(Pipeline.Workspace)\**\*.exe' changeLogType: issueBased - deployment: deploy_lib From 74b8b4beb31634e5752def9c9394faef2f2ba7b2 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 16 Mar 2022 18:35:41 +0300 Subject: [PATCH 257/288] Remove whitespace --- .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 3d21b83ee..31af5bd24 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -271,7 +271,7 @@ stages: source: current - pwsh: | $artifactName = Get-ChildItem -Path $(Pipeline.Workspace) -Filter Microsoft.OpenApi.Hidi-* -recurse | select -First 1 - $artifactVersion= $artifactName -replace "Microsoft.OpenApi.Hidi-", "" + $artifactVersion= $artifactName -replace "Microsoft.OpenApi.Hidi-", "" #Set Variable $artifactName and $artifactVersion Write-Host "##vso[task.setvariable variable=artifactVersion; isSecret=false; isOutput=true]$artifactVersion" Write-Host "##vso[task.setvariable variable=artifactName; isSecret=false; isOutput=true]$artifactName.FullName" From 13812b153a355faa230292f443a5eb432c6eecfd Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Wed, 23 Mar 2022 13:31:56 -0400 Subject: [PATCH 258/288] Added CSDL filter for entitysets and singletons --- src/Microsoft.OpenApi.Hidi/CsdlFilter.xslt | 22 ++++++++++ .../Microsoft.OpenApi.Hidi.csproj | 8 ++++ src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 41 ++++++++++++++++++- src/Microsoft.OpenApi.Hidi/Program.cs | 8 +++- .../Services/OpenApiServiceTests.cs | 2 +- 5 files changed, 76 insertions(+), 5 deletions(-) create mode 100644 src/Microsoft.OpenApi.Hidi/CsdlFilter.xslt diff --git a/src/Microsoft.OpenApi.Hidi/CsdlFilter.xslt b/src/Microsoft.OpenApi.Hidi/CsdlFilter.xslt new file mode 100644 index 000000000..ee3bf0d40 --- /dev/null +++ b/src/Microsoft.OpenApi.Hidi/CsdlFilter.xslt @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index d9a958db9..98def8818 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -31,6 +31,14 @@ true + + + + + + + + diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index c15f77d6f..4b73c13d4 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -24,6 +24,10 @@ using Microsoft.OpenApi.Writers; using static Microsoft.OpenApi.Hidi.OpenApiSpecVersionHelper; using System.Threading; +using System.Xml.Xsl; +using System.Xml; +using System.Runtime.CompilerServices; +using System.Reflection; namespace Microsoft.OpenApi.Hidi { @@ -35,6 +39,7 @@ public class OpenApiService public static async Task TransformOpenApiDocument( string openapi, string csdl, + string csdlFilter, FileInfo output, bool cleanoutput, string? version, @@ -85,6 +90,13 @@ CancellationToken cancellationToken openApiVersion = version != null ? TryParseOpenApiSpecVersion(version) : OpenApiSpecVersion.OpenApi3_0; stream = await GetStream(csdl, logger, cancellationToken); + + if (!string.IsNullOrEmpty(csdlFilter)) + { + XslCompiledTransform transform = GetFilterTransform(); + stream = ApplyFilter(csdl, csdlFilter, transform); + stream.Position = 0; + } document = await ConvertCsdlToOpenApi(stream); stopwatch.Stop(); logger.LogTrace("{timestamp}ms: Generated OpenAPI with {paths} paths.", stopwatch.ElapsedMilliseconds, document.Paths.Count); @@ -210,6 +222,31 @@ CancellationToken cancellationToken } } + private static XslCompiledTransform GetFilterTransform() + { + XslCompiledTransform transform = new(); + Assembly assembly = typeof(OpenApiService).GetTypeInfo().Assembly; + Stream xslt = assembly.GetManifestResourceStream("Microsoft.OpenApi.Hidi.CsdlFilter.xslt"); + transform.Load(new XmlTextReader(new StreamReader(xslt))); + return transform; + } + + private static Stream ApplyFilter(string csdl, string entitySetOrSingleton, XslCompiledTransform transform) + { + Stream stream; + StreamReader inputReader = new(csdl); + XmlReader inputXmlReader = XmlReader.Create(inputReader); + MemoryStream filteredStream = new(); + StreamWriter writer = new(filteredStream); + XsltArgumentList args = new(); + args.AddParam("entitySetOrSingleton", "", entitySetOrSingleton); + transform.Transform(inputXmlReader, args, writer); + stream = filteredStream; + return stream; + } + + + /// /// Implementation of the validate command /// @@ -306,8 +343,8 @@ public static async Task ConvertCsdlToOpenApi(Stream csdl) EnableDiscriminatorValue = false, EnableDerivedTypesReferencesForRequestBody = false, EnableDerivedTypesReferencesForResponses = false, - ShowRootPath = true, - ShowLinks = true + ShowRootPath = false, + ShowLinks = false }; OpenApiDocument document = edmModel.ConvertToOpenApi(settings); diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index ac39aaad4..5a2a808dd 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -24,6 +24,9 @@ static async Task Main(string[] args) var csdlOption = new Option("--csdl", "Input CSDL file path or URL"); csdlOption.AddAlias("-cs"); + var csdlFilterOption = new Option("--csdlFilter", "Name of EntitySet or Singleton to filter CSDL on"); + csdlOption.AddAlias("-csf"); + var outputOption = new Option("--output", () => new FileInfo("./output"), "The output directory path for the generated file.") { Arity = ArgumentArity.ZeroOrOne }; outputOption.AddAlias("-o"); @@ -66,6 +69,7 @@ static async Task Main(string[] args) { descriptionOption, csdlOption, + csdlFilterOption, outputOption, cleanOutputOption, versionOption, @@ -78,8 +82,8 @@ static async Task Main(string[] args) resolveExternalOption, }; - transformCommand.SetHandler ( - OpenApiService.TransformOpenApiDocument, descriptionOption, csdlOption, outputOption, cleanOutputOption, versionOption, formatOption, logLevelOption, inlineOption, resolveExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); + transformCommand.SetHandler ( + OpenApiService.TransformOpenApiDocument, descriptionOption, csdlOption, csdlFilterOption, outputOption, cleanOutputOption, versionOption, formatOption, logLevelOption, inlineOption, resolveExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); rootCommand.Add(transformCommand); rootCommand.Add(validateCommand); diff --git a/test/Microsoft.OpenApi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Tests/Services/OpenApiServiceTests.cs index 1c9fd003b..af5437aa1 100644 --- a/test/Microsoft.OpenApi.Tests/Services/OpenApiServiceTests.cs +++ b/test/Microsoft.OpenApi.Tests/Services/OpenApiServiceTests.cs @@ -22,7 +22,7 @@ public async Task ReturnConvertedCSDLFile() // Act var openApiDoc = await OpenApiService.ConvertCsdlToOpenApi(csdlStream); - var expectedPathCount = 6; + var expectedPathCount = 5; // Assert Assert.NotNull(openApiDoc); From 7aae53be9813a0b12478dbaf8f1e4c18a9c6a4dd Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sun, 27 Mar 2022 09:07:50 -0400 Subject: [PATCH 259/288] Fixed issue with v2 external references --- .../Microsoft.OpenApi.Hidi.csproj | 4 +- .../Microsoft.OpenApi.Readers.csproj | 2 +- .../V2/OpenApiV2VersionService.cs | 48 ++++++++++++++++++- .../V3/OpenApiV3VersionService.cs | 2 +- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- .../ConvertToOpenApiReferenceV2Tests.cs | 22 ++++++++- .../Microsoft.OpenApi.Tests.csproj | 8 ++-- 7 files changed, 76 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index cd8d14132..add38e832 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -33,10 +33,10 @@ - + - + diff --git a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj index 1b4542073..4241daf6a 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -40,7 +40,7 @@ - + diff --git a/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs b/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs index fbd4dbb85..c4d765734 100644 --- a/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs +++ b/src/Microsoft.OpenApi.Readers/V2/OpenApiV2VersionService.cs @@ -130,6 +130,30 @@ private static string GetReferenceTypeV2Name(ReferenceType referenceType) } } + private static ReferenceType GetReferenceTypeV2FromName(string referenceType) + { + switch (referenceType) + { + case "definitions": + return ReferenceType.Schema; + + case "parameters": + return ReferenceType.Parameter; + + case "responses": + return ReferenceType.Response; + + case "tags": + return ReferenceType.Tag; + + case "securityDefinitions": + return ReferenceType.SecurityScheme; + + default: + throw new ArgumentException(); + } + } + /// /// Parse the string to a object. /// @@ -176,12 +200,34 @@ public OpenApiReference ConvertToOpenApiReference(string reference, ReferenceTyp } } + // Where fragments point into a non-OpenAPI document, the id will be the complete fragment identifier + string id = segments[1]; + // $ref: externalSource.yaml#/Pet + if (id.StartsWith("/definitions/")) + { + var localSegments = id.Split('/'); + var referencedType = GetReferenceTypeV2FromName(localSegments[1]); + if (type == null) + { + type = referencedType; + } + else + { + if (type != referencedType) + { + throw new OpenApiException("Referenced type mismatch"); + } + } + id = localSegments[2]; + } + + // $ref: externalSource.yaml#/Pet return new OpenApiReference { ExternalResource = segments[0], Type = type, - Id = segments[1].Substring(1) + Id = id }; } } diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs index 3ee8b8d4e..65acbc4e0 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; 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 086d80d75..7d346009e 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj +++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj @@ -247,7 +247,7 @@ - + diff --git a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs index ff6641f88..bd9600e4f 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV2Tests.cs @@ -17,14 +17,32 @@ public ConvertToOpenApiReferenceV2Tests() Diagnostic = new OpenApiDiagnostic(); } + [Fact] + public void ParseExternalReferenceToV2OpenApi() + { + // Arrange + var versionService = new OpenApiV2VersionService(Diagnostic); + var externalResource = "externalSchema.json"; + var id = "mySchema"; + var input = $"{externalResource}#/definitions/{id}"; + + // Act + var reference = versionService.ConvertToOpenApiReference(input, null); + + // Assert + reference.ExternalResource.Should().Be(externalResource); + reference.Type.Should().NotBeNull(); + reference.Id.Should().Be(id); + } + [Fact] public void ParseExternalReference() { // Arrange var versionService = new OpenApiV2VersionService(Diagnostic); var externalResource = "externalSchema.json"; - var id = "externalPathSegment1/externalPathSegment2/externalPathSegment3"; - var input = $"{externalResource}#/{id}"; + var id = "/externalPathSegment1/externalPathSegment2/externalPathSegment3"; + var input = $"{externalResource}#{id}"; // Act var reference = versionService.ConvertToOpenApiReference(input, null); diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index de827c62f..df3c736e2 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -17,11 +17,11 @@ - + - - - + + + all From caa87da7a117071f0038d9b7bff780ee2e8d8ebd Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sun, 27 Mar 2022 14:33:59 -0400 Subject: [PATCH 260/288] Fixed reporting collections with urls not in OpenAPI --- filteredGraph.yaml | 478 ++++++++++++++++++ .../Services/OpenApiFilterService.cs | 18 +- 2 files changed, 487 insertions(+), 9 deletions(-) create mode 100644 filteredGraph.yaml diff --git a/filteredGraph.yaml b/filteredGraph.yaml new file mode 100644 index 000000000..4dea96ea8 --- /dev/null +++ b/filteredGraph.yaml @@ -0,0 +1,478 @@ +openapi: 3.0.1 +info: + title: OData Service for namespace microsoft.graph - Subset + description: This OData service is located at https://graph.microsoft.com/v1.0 + version: 1.0.1 +servers: + - url: https://graph.microsoft.com/v1.0 +paths: + /admin/serviceAnnouncement: + get: + tags: + - admin.serviceAnnouncement + summary: Get serviceAnnouncement from admin + description: A container for service communications resources. Read-only. + operationId: admin.GetServiceAnnouncement + parameters: + - name: $select + in: query + description: Select properties to be returned + style: form + explode: false + schema: + uniqueItems: true + type: array + items: + enum: + - id + - healthOverviews + - issues + - messages + type: string + - name: $expand + in: query + description: Expand related entities + style: form + explode: false + schema: + uniqueItems: true + type: array + items: + enum: + - '*' + - healthOverviews + - issues + - messages + type: string + responses: + '200': + description: Retrieved navigation property + content: + application/json: + schema: + $ref: '#/components/schemas/microsoft.graph.serviceAnnouncement' + links: + healthOverviews: + operationId: admin.ServiceAnnouncement.ListHealthOverviews + issues: + operationId: admin.ServiceAnnouncement.ListIssues + messages: + operationId: admin.ServiceAnnouncement.ListMessages + 4XX: + $ref: '#/components/responses/error' + 5XX: + $ref: '#/components/responses/error' + x-ms-docs-operation-type: operation + patch: + tags: + - admin.serviceAnnouncement + summary: Update the navigation property serviceAnnouncement in admin + operationId: admin.UpdateServiceAnnouncement + requestBody: + description: New navigation property values + content: + application/json: + schema: + $ref: '#/components/schemas/microsoft.graph.serviceAnnouncement' + required: true + responses: + '204': + description: Success + 4XX: + $ref: '#/components/responses/error' + 5XX: + $ref: '#/components/responses/error' + x-ms-docs-operation-type: operation +components: + schemas: + microsoft.graph.serviceAnnouncement: + allOf: + - $ref: '#/components/schemas/microsoft.graph.entity' + - title: serviceAnnouncement + type: object + properties: + healthOverviews: + type: array + items: + $ref: '#/components/schemas/microsoft.graph.serviceHealth' + description: 'A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly.' + issues: + type: array + items: + $ref: '#/components/schemas/microsoft.graph.serviceHealthIssue' + description: 'A collection of service issues for tenant. This property is a contained navigation property, it is nullable and readonly.' + messages: + type: array + items: + $ref: '#/components/schemas/microsoft.graph.serviceUpdateMessage' + description: 'A collection of service messages for tenant. This property is a contained navigation property, it is nullable and readonly.' + microsoft.graph.entity: + title: entity + type: object + properties: + id: + type: string + description: Read-only. + microsoft.graph.serviceHealth: + allOf: + - $ref: '#/components/schemas/microsoft.graph.entity' + - title: serviceHealth + type: object + properties: + service: + type: string + description: The service name. Use the list healthOverviews operation to get exact string names for services subscribed by the tenant. + status: + anyOf: + - $ref: '#/components/schemas/microsoft.graph.serviceHealthStatus' + description: 'Show the overral service health status. Possible values are: serviceOperational, investigating, restoringService, verifyingService, serviceRestored, postIncidentReviewPublished, serviceDegradation, serviceInterruption, extendedRecovery, falsePositive, investigationSuspended, resolved, mitigatedExternal, mitigated, resolvedExternal, confirmed, reported, unknownFutureValue. For more details, see serviceHealthStatus values.' + issues: + type: array + items: + $ref: '#/components/schemas/microsoft.graph.serviceHealthIssue' + description: 'A collection of issues that happened on the service, with detailed information for each issue.' + microsoft.graph.serviceHealthIssue: + allOf: + - $ref: '#/components/schemas/microsoft.graph.serviceAnnouncementBase' + - title: serviceHealthIssue + type: object + properties: + classification: + anyOf: + - $ref: '#/components/schemas/microsoft.graph.serviceHealthClassificationType' + description: 'The type of service health issue. Possible values are: advisory, incident, unknownFutureValue.' + feature: + type: string + description: The feature name of the service issue. + nullable: true + featureGroup: + type: string + description: The feature group name of the service issue. + nullable: true + impactDescription: + type: string + description: The description of the service issue impact. + isResolved: + type: boolean + description: Indicates whether the issue is resolved. + origin: + anyOf: + - $ref: '#/components/schemas/microsoft.graph.serviceHealthOrigin' + description: 'Indicates the origin of the service issue. Possible values are: microsoft, thirdParty, customer, unknownFutureValue.' + posts: + type: array + items: + $ref: '#/components/schemas/microsoft.graph.serviceHealthIssuePost' + description: Collection of historical posts for the service issue. + service: + type: string + description: Indicates the service affected by the issue. + status: + anyOf: + - $ref: '#/components/schemas/microsoft.graph.serviceHealthStatus' + description: 'The status of the service issue. Possible values are: serviceOperational, investigating, restoringService, verifyingService, serviceRestored, postIncidentReviewPublished, serviceDegradation, serviceInterruption, extendedRecovery, falsePositive, investigationSuspended, resolved, mitigatedExternal, mitigated, resolvedExternal, confirmed, reported, unknownFutureValue. See more in the table below.' + microsoft.graph.serviceUpdateMessage: + allOf: + - $ref: '#/components/schemas/microsoft.graph.serviceAnnouncementBase' + - title: serviceUpdateMessage + type: object + properties: + actionRequiredByDateTime: + pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$' + type: string + description: The expected deadline of the action for the message. + format: date-time + nullable: true + attachmentsArchive: + type: string + description: The zip file that contains all attachments for a message. + format: base64url + nullable: true + body: + $ref: '#/components/schemas/microsoft.graph.itemBody' + category: + anyOf: + - $ref: '#/components/schemas/microsoft.graph.serviceUpdateCategory' + description: 'The service message category. Possible values are: preventOrFixIssue, planForChange, stayInformed, unknownFutureValue.' + hasAttachments: + type: boolean + description: Indicates whether the message has any attachment. + isMajorChange: + type: boolean + description: Indicates whether the message describes a major update for the service. + nullable: true + services: + type: array + items: + type: string + nullable: true + description: The affected services by the service message. + severity: + anyOf: + - $ref: '#/components/schemas/microsoft.graph.serviceUpdateSeverity' + description: 'The severity of the service message. Possible values are: normal, high, critical, unknownFutureValue.' + tags: + type: array + items: + type: string + nullable: true + description: 'A collection of tags for the service message. Tags are provided by the service team/support team who post the message to tell whether this message contains privacy data, or whether this message is for a service new feature update, and so on.' + viewPoint: + anyOf: + - $ref: '#/components/schemas/microsoft.graph.serviceUpdateMessageViewpoint' + description: 'Represents user viewpoints data of the service message. This data includes message status such as whether the user has archived, read, or marked the message as favorite. This property is null when accessed with application permissions.' + nullable: true + attachments: + type: array + items: + $ref: '#/components/schemas/microsoft.graph.serviceAnnouncementAttachment' + description: A collection of serviceAnnouncementAttachments. + microsoft.graph.ODataErrors.ODataError: + required: + - error + type: object + properties: + error: + $ref: '#/components/schemas/microsoft.graph.ODataErrors.MainError' + microsoft.graph.serviceHealthStatus: + title: serviceHealthStatus + enum: + - serviceOperational + - investigating + - restoringService + - verifyingService + - serviceRestored + - postIncidentReviewPublished + - serviceDegradation + - serviceInterruption + - extendedRecovery + - falsePositive + - investigationSuspended + - resolved + - mitigatedExternal + - mitigated + - resolvedExternal + - confirmed + - reported + - unknownFutureValue + type: string + microsoft.graph.serviceAnnouncementBase: + allOf: + - $ref: '#/components/schemas/microsoft.graph.entity' + - title: serviceAnnouncementBase + type: object + properties: + details: + type: array + items: + anyOf: + - $ref: '#/components/schemas/microsoft.graph.keyValuePair' + nullable: true + description: Additional details about service event. This property doesn't support filters. + endDateTime: + pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$' + type: string + description: The end time of the service event. + format: date-time + nullable: true + lastModifiedDateTime: + pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$' + type: string + description: The last modified time of the service event. + format: date-time + startDateTime: + pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$' + type: string + description: The start time of the service event. + format: date-time + title: + type: string + description: The title of the service event. + microsoft.graph.serviceHealthClassificationType: + title: serviceHealthClassificationType + enum: + - advisory + - incident + - unknownFutureValue + type: string + microsoft.graph.serviceHealthOrigin: + title: serviceHealthOrigin + enum: + - microsoft + - thirdParty + - customer + - unknownFutureValue + type: string + microsoft.graph.serviceHealthIssuePost: + title: serviceHealthIssuePost + type: object + properties: + createdDateTime: + pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$' + type: string + description: The published time of the post. + format: date-time + description: + anyOf: + - $ref: '#/components/schemas/microsoft.graph.itemBody' + description: The content of the service issue post. + nullable: true + postType: + anyOf: + - $ref: '#/components/schemas/microsoft.graph.postType' + description: 'The post type of the service issue historical post. Possible values are: regular, quick, strategic, unknownFutureValue.' + nullable: true + microsoft.graph.itemBody: + title: itemBody + type: object + properties: + content: + type: string + description: The content of the item. + nullable: true + contentType: + anyOf: + - $ref: '#/components/schemas/microsoft.graph.bodyType' + description: The type of the content. Possible values are text and html. + nullable: true + microsoft.graph.serviceUpdateCategory: + title: serviceUpdateCategory + enum: + - preventOrFixIssue + - planForChange + - stayInformed + - unknownFutureValue + type: string + microsoft.graph.serviceUpdateSeverity: + title: serviceUpdateSeverity + enum: + - normal + - high + - critical + - unknownFutureValue + type: string + microsoft.graph.serviceUpdateMessageViewpoint: + title: serviceUpdateMessageViewpoint + type: object + properties: + isArchived: + type: boolean + description: Indicates whether the user archived the message. + nullable: true + isFavorited: + type: boolean + description: Indicates whether the user marked the message as favorite. + nullable: true + isRead: + type: boolean + description: Indicates whether the user read the message. + nullable: true + microsoft.graph.serviceAnnouncementAttachment: + allOf: + - $ref: '#/components/schemas/microsoft.graph.entity' + - title: serviceAnnouncementAttachment + type: object + properties: + content: + type: string + description: The attachment content. + format: base64url + nullable: true + contentType: + type: string + nullable: true + lastModifiedDateTime: + pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$' + type: string + format: date-time + nullable: true + name: + type: string + nullable: true + size: + maximum: 2147483647 + minimum: -2147483648 + type: integer + format: int32 + microsoft.graph.ODataErrors.MainError: + required: + - code + - message + type: object + properties: + code: + type: string + message: + type: string + target: + type: string + nullable: true + details: + type: array + items: + $ref: '#/components/schemas/microsoft.graph.ODataErrors.ErrorDetails' + innererror: + $ref: '#/components/schemas/microsoft.graph.ODataErrors.InnerError' + microsoft.graph.keyValuePair: + title: keyValuePair + type: object + properties: + name: + type: string + description: Name for this key-value pair + value: + type: string + description: Value for this key-value pair + nullable: true + microsoft.graph.postType: + title: postType + enum: + - regular + - quick + - strategic + - unknownFutureValue + type: string + microsoft.graph.bodyType: + title: bodyType + enum: + - text + - html + type: string + microsoft.graph.ODataErrors.ErrorDetails: + required: + - code + - message + type: object + properties: + code: + type: string + message: + type: string + target: + type: string + nullable: true + microsoft.graph.ODataErrors.InnerError: + title: InnerError + type: object + properties: + request-id: + type: string + description: Request Id as tracked internally by the service + nullable: true + client-request-id: + type: string + description: Client request Id as sent by the client application. + nullable: true + Date: + pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$' + type: string + description: Date when the error occured. + format: date-time + nullable: true + responses: + error: + description: error + content: + application/json: + schema: + $ref: '#/components/schemas/microsoft.graph.ODataErrors.ODataError' \ No newline at end of file diff --git a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs index 57c5fef09..11dcaec14 100644 --- a/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs +++ b/src/Microsoft.OpenApi/Services/OpenApiFilterService.cs @@ -73,24 +73,24 @@ public static class OpenApiFilterService var rootNode = CreateOpenApiUrlTreeNode(sources); // Iterate through urls dictionary and fetch operations for each url - foreach (var path in requestUrls) + foreach (var url in requestUrls) { var serverList = source.Servers; - var url = FormatUrlString(path.Key, serverList); + var path = ExtractPath(url.Key, serverList); - var openApiOperations = GetOpenApiOperations(rootNode, url, apiVersion); + var openApiOperations = GetOpenApiOperations(rootNode, path, apiVersion); if (openApiOperations == null) { - Console.WriteLine($"The url {url} could not be found in the OpenApi description"); + Console.WriteLine($"The url {url.Key} could not be found in the OpenApi description"); continue; } // Add the available ops if they are in the postman collection. See path.Value foreach (var ops in openApiOperations) { - if (path.Value.Contains(ops.Key.ToString().ToUpper())) + if (url.Value.Contains(ops.Key.ToString().ToUpper())) { - operationTypes.Add(ops.Key + url); + operationTypes.Add(ops.Key + path); } } } @@ -323,7 +323,7 @@ private static bool AddReferences(OpenApiComponents newComponents, OpenApiCompon return moreStuff; } - private static string FormatUrlString(string url, IList serverList) + private static string ExtractPath(string url, IList serverList) { var queryPath = string.Empty; foreach (var server in serverList) @@ -334,8 +334,8 @@ private static string FormatUrlString(string url, IList serverLis continue; } - var querySegments = url.Split(new[]{ serverUrl }, StringSplitOptions.None); - queryPath = querySegments[1]; + var urlComponents = url.Split(new[]{ serverUrl }, StringSplitOptions.None); + queryPath = urlComponents[1]; } return queryPath; From 53c56f7dc2cfa3824c738d9ca133a05c9ceb544e Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sun, 27 Mar 2022 14:37:00 -0400 Subject: [PATCH 261/288] Removed openapi file that snook in. --- filteredGraph.yaml | 478 --------------------------------------------- 1 file changed, 478 deletions(-) delete mode 100644 filteredGraph.yaml diff --git a/filteredGraph.yaml b/filteredGraph.yaml deleted file mode 100644 index 4dea96ea8..000000000 --- a/filteredGraph.yaml +++ /dev/null @@ -1,478 +0,0 @@ -openapi: 3.0.1 -info: - title: OData Service for namespace microsoft.graph - Subset - description: This OData service is located at https://graph.microsoft.com/v1.0 - version: 1.0.1 -servers: - - url: https://graph.microsoft.com/v1.0 -paths: - /admin/serviceAnnouncement: - get: - tags: - - admin.serviceAnnouncement - summary: Get serviceAnnouncement from admin - description: A container for service communications resources. Read-only. - operationId: admin.GetServiceAnnouncement - parameters: - - name: $select - in: query - description: Select properties to be returned - style: form - explode: false - schema: - uniqueItems: true - type: array - items: - enum: - - id - - healthOverviews - - issues - - messages - type: string - - name: $expand - in: query - description: Expand related entities - style: form - explode: false - schema: - uniqueItems: true - type: array - items: - enum: - - '*' - - healthOverviews - - issues - - messages - type: string - responses: - '200': - description: Retrieved navigation property - content: - application/json: - schema: - $ref: '#/components/schemas/microsoft.graph.serviceAnnouncement' - links: - healthOverviews: - operationId: admin.ServiceAnnouncement.ListHealthOverviews - issues: - operationId: admin.ServiceAnnouncement.ListIssues - messages: - operationId: admin.ServiceAnnouncement.ListMessages - 4XX: - $ref: '#/components/responses/error' - 5XX: - $ref: '#/components/responses/error' - x-ms-docs-operation-type: operation - patch: - tags: - - admin.serviceAnnouncement - summary: Update the navigation property serviceAnnouncement in admin - operationId: admin.UpdateServiceAnnouncement - requestBody: - description: New navigation property values - content: - application/json: - schema: - $ref: '#/components/schemas/microsoft.graph.serviceAnnouncement' - required: true - responses: - '204': - description: Success - 4XX: - $ref: '#/components/responses/error' - 5XX: - $ref: '#/components/responses/error' - x-ms-docs-operation-type: operation -components: - schemas: - microsoft.graph.serviceAnnouncement: - allOf: - - $ref: '#/components/schemas/microsoft.graph.entity' - - title: serviceAnnouncement - type: object - properties: - healthOverviews: - type: array - items: - $ref: '#/components/schemas/microsoft.graph.serviceHealth' - description: 'A collection of service health information for tenant. This property is a contained navigation property, it is nullable and readonly.' - issues: - type: array - items: - $ref: '#/components/schemas/microsoft.graph.serviceHealthIssue' - description: 'A collection of service issues for tenant. This property is a contained navigation property, it is nullable and readonly.' - messages: - type: array - items: - $ref: '#/components/schemas/microsoft.graph.serviceUpdateMessage' - description: 'A collection of service messages for tenant. This property is a contained navigation property, it is nullable and readonly.' - microsoft.graph.entity: - title: entity - type: object - properties: - id: - type: string - description: Read-only. - microsoft.graph.serviceHealth: - allOf: - - $ref: '#/components/schemas/microsoft.graph.entity' - - title: serviceHealth - type: object - properties: - service: - type: string - description: The service name. Use the list healthOverviews operation to get exact string names for services subscribed by the tenant. - status: - anyOf: - - $ref: '#/components/schemas/microsoft.graph.serviceHealthStatus' - description: 'Show the overral service health status. Possible values are: serviceOperational, investigating, restoringService, verifyingService, serviceRestored, postIncidentReviewPublished, serviceDegradation, serviceInterruption, extendedRecovery, falsePositive, investigationSuspended, resolved, mitigatedExternal, mitigated, resolvedExternal, confirmed, reported, unknownFutureValue. For more details, see serviceHealthStatus values.' - issues: - type: array - items: - $ref: '#/components/schemas/microsoft.graph.serviceHealthIssue' - description: 'A collection of issues that happened on the service, with detailed information for each issue.' - microsoft.graph.serviceHealthIssue: - allOf: - - $ref: '#/components/schemas/microsoft.graph.serviceAnnouncementBase' - - title: serviceHealthIssue - type: object - properties: - classification: - anyOf: - - $ref: '#/components/schemas/microsoft.graph.serviceHealthClassificationType' - description: 'The type of service health issue. Possible values are: advisory, incident, unknownFutureValue.' - feature: - type: string - description: The feature name of the service issue. - nullable: true - featureGroup: - type: string - description: The feature group name of the service issue. - nullable: true - impactDescription: - type: string - description: The description of the service issue impact. - isResolved: - type: boolean - description: Indicates whether the issue is resolved. - origin: - anyOf: - - $ref: '#/components/schemas/microsoft.graph.serviceHealthOrigin' - description: 'Indicates the origin of the service issue. Possible values are: microsoft, thirdParty, customer, unknownFutureValue.' - posts: - type: array - items: - $ref: '#/components/schemas/microsoft.graph.serviceHealthIssuePost' - description: Collection of historical posts for the service issue. - service: - type: string - description: Indicates the service affected by the issue. - status: - anyOf: - - $ref: '#/components/schemas/microsoft.graph.serviceHealthStatus' - description: 'The status of the service issue. Possible values are: serviceOperational, investigating, restoringService, verifyingService, serviceRestored, postIncidentReviewPublished, serviceDegradation, serviceInterruption, extendedRecovery, falsePositive, investigationSuspended, resolved, mitigatedExternal, mitigated, resolvedExternal, confirmed, reported, unknownFutureValue. See more in the table below.' - microsoft.graph.serviceUpdateMessage: - allOf: - - $ref: '#/components/schemas/microsoft.graph.serviceAnnouncementBase' - - title: serviceUpdateMessage - type: object - properties: - actionRequiredByDateTime: - pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$' - type: string - description: The expected deadline of the action for the message. - format: date-time - nullable: true - attachmentsArchive: - type: string - description: The zip file that contains all attachments for a message. - format: base64url - nullable: true - body: - $ref: '#/components/schemas/microsoft.graph.itemBody' - category: - anyOf: - - $ref: '#/components/schemas/microsoft.graph.serviceUpdateCategory' - description: 'The service message category. Possible values are: preventOrFixIssue, planForChange, stayInformed, unknownFutureValue.' - hasAttachments: - type: boolean - description: Indicates whether the message has any attachment. - isMajorChange: - type: boolean - description: Indicates whether the message describes a major update for the service. - nullable: true - services: - type: array - items: - type: string - nullable: true - description: The affected services by the service message. - severity: - anyOf: - - $ref: '#/components/schemas/microsoft.graph.serviceUpdateSeverity' - description: 'The severity of the service message. Possible values are: normal, high, critical, unknownFutureValue.' - tags: - type: array - items: - type: string - nullable: true - description: 'A collection of tags for the service message. Tags are provided by the service team/support team who post the message to tell whether this message contains privacy data, or whether this message is for a service new feature update, and so on.' - viewPoint: - anyOf: - - $ref: '#/components/schemas/microsoft.graph.serviceUpdateMessageViewpoint' - description: 'Represents user viewpoints data of the service message. This data includes message status such as whether the user has archived, read, or marked the message as favorite. This property is null when accessed with application permissions.' - nullable: true - attachments: - type: array - items: - $ref: '#/components/schemas/microsoft.graph.serviceAnnouncementAttachment' - description: A collection of serviceAnnouncementAttachments. - microsoft.graph.ODataErrors.ODataError: - required: - - error - type: object - properties: - error: - $ref: '#/components/schemas/microsoft.graph.ODataErrors.MainError' - microsoft.graph.serviceHealthStatus: - title: serviceHealthStatus - enum: - - serviceOperational - - investigating - - restoringService - - verifyingService - - serviceRestored - - postIncidentReviewPublished - - serviceDegradation - - serviceInterruption - - extendedRecovery - - falsePositive - - investigationSuspended - - resolved - - mitigatedExternal - - mitigated - - resolvedExternal - - confirmed - - reported - - unknownFutureValue - type: string - microsoft.graph.serviceAnnouncementBase: - allOf: - - $ref: '#/components/schemas/microsoft.graph.entity' - - title: serviceAnnouncementBase - type: object - properties: - details: - type: array - items: - anyOf: - - $ref: '#/components/schemas/microsoft.graph.keyValuePair' - nullable: true - description: Additional details about service event. This property doesn't support filters. - endDateTime: - pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$' - type: string - description: The end time of the service event. - format: date-time - nullable: true - lastModifiedDateTime: - pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$' - type: string - description: The last modified time of the service event. - format: date-time - startDateTime: - pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$' - type: string - description: The start time of the service event. - format: date-time - title: - type: string - description: The title of the service event. - microsoft.graph.serviceHealthClassificationType: - title: serviceHealthClassificationType - enum: - - advisory - - incident - - unknownFutureValue - type: string - microsoft.graph.serviceHealthOrigin: - title: serviceHealthOrigin - enum: - - microsoft - - thirdParty - - customer - - unknownFutureValue - type: string - microsoft.graph.serviceHealthIssuePost: - title: serviceHealthIssuePost - type: object - properties: - createdDateTime: - pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$' - type: string - description: The published time of the post. - format: date-time - description: - anyOf: - - $ref: '#/components/schemas/microsoft.graph.itemBody' - description: The content of the service issue post. - nullable: true - postType: - anyOf: - - $ref: '#/components/schemas/microsoft.graph.postType' - description: 'The post type of the service issue historical post. Possible values are: regular, quick, strategic, unknownFutureValue.' - nullable: true - microsoft.graph.itemBody: - title: itemBody - type: object - properties: - content: - type: string - description: The content of the item. - nullable: true - contentType: - anyOf: - - $ref: '#/components/schemas/microsoft.graph.bodyType' - description: The type of the content. Possible values are text and html. - nullable: true - microsoft.graph.serviceUpdateCategory: - title: serviceUpdateCategory - enum: - - preventOrFixIssue - - planForChange - - stayInformed - - unknownFutureValue - type: string - microsoft.graph.serviceUpdateSeverity: - title: serviceUpdateSeverity - enum: - - normal - - high - - critical - - unknownFutureValue - type: string - microsoft.graph.serviceUpdateMessageViewpoint: - title: serviceUpdateMessageViewpoint - type: object - properties: - isArchived: - type: boolean - description: Indicates whether the user archived the message. - nullable: true - isFavorited: - type: boolean - description: Indicates whether the user marked the message as favorite. - nullable: true - isRead: - type: boolean - description: Indicates whether the user read the message. - nullable: true - microsoft.graph.serviceAnnouncementAttachment: - allOf: - - $ref: '#/components/schemas/microsoft.graph.entity' - - title: serviceAnnouncementAttachment - type: object - properties: - content: - type: string - description: The attachment content. - format: base64url - nullable: true - contentType: - type: string - nullable: true - lastModifiedDateTime: - pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$' - type: string - format: date-time - nullable: true - name: - type: string - nullable: true - size: - maximum: 2147483647 - minimum: -2147483648 - type: integer - format: int32 - microsoft.graph.ODataErrors.MainError: - required: - - code - - message - type: object - properties: - code: - type: string - message: - type: string - target: - type: string - nullable: true - details: - type: array - items: - $ref: '#/components/schemas/microsoft.graph.ODataErrors.ErrorDetails' - innererror: - $ref: '#/components/schemas/microsoft.graph.ODataErrors.InnerError' - microsoft.graph.keyValuePair: - title: keyValuePair - type: object - properties: - name: - type: string - description: Name for this key-value pair - value: - type: string - description: Value for this key-value pair - nullable: true - microsoft.graph.postType: - title: postType - enum: - - regular - - quick - - strategic - - unknownFutureValue - type: string - microsoft.graph.bodyType: - title: bodyType - enum: - - text - - html - type: string - microsoft.graph.ODataErrors.ErrorDetails: - required: - - code - - message - type: object - properties: - code: - type: string - message: - type: string - target: - type: string - nullable: true - microsoft.graph.ODataErrors.InnerError: - title: InnerError - type: object - properties: - request-id: - type: string - description: Request Id as tracked internally by the service - nullable: true - client-request-id: - type: string - description: Client request Id as sent by the client application. - nullable: true - Date: - pattern: '^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$' - type: string - description: Date when the error occured. - format: date-time - nullable: true - responses: - error: - description: error - content: - application/json: - schema: - $ref: '#/components/schemas/microsoft.graph.ODataErrors.ODataError' \ No newline at end of file From 988496a0ea0266cd400f985ef9aa161168e2e47e Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sun, 27 Mar 2022 16:49:34 -0400 Subject: [PATCH 262/288] Fixed command alias and some descriptions --- src/Microsoft.OpenApi.Hidi/Program.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 0eab5a693..8b466913c 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -24,8 +24,8 @@ static async Task Main(string[] args) var csdlOption = new Option("--csdl", "Input CSDL file path or URL"); csdlOption.AddAlias("-cs"); - var csdlFilterOption = new Option("--csdlFilter", "Name of EntitySet or Singleton to filter CSDL on"); - csdlOption.AddAlias("-csf"); + var csdlFilterOption = new Option("--csdl-filter", "Comma delimited list of EntitySets or Singletons to filter CSDL on. e.g. tasks,accounts"); + csdlFilterOption.AddAlias("-csf"); var outputOption = new Option("--output", () => new FileInfo("./output"), "The output directory path for the generated file.") { Arity = ArgumentArity.ZeroOrOne }; outputOption.AddAlias("-o"); @@ -42,13 +42,13 @@ static async Task Main(string[] args) var logLevelOption = new Option("--loglevel", () => LogLevel.Information, "The log level to use when logging messages to the main output."); logLevelOption.AddAlias("-ll"); - var filterByOperationIdsOption = new Option("--filter-by-operationids", "Filters OpenApiDocument by OperationId(s) provided"); + var filterByOperationIdsOption = new Option("--filter-by-operationids", "Filters OpenApiDocument by comma delimited list of OperationId(s) provided"); filterByOperationIdsOption.AddAlias("-op"); - var filterByTagsOption = new Option("--filter-by-tags", "Filters OpenApiDocument by Tag(s) provided"); + var filterByTagsOption = new Option("--filter-by-tags", "Filters OpenApiDocument by comma delimited list of Tag(s) provided. Also accepts a single regex."); filterByTagsOption.AddAlias("-t"); - var filterByCollectionOption = new Option("--filter-by-collection", "Filters OpenApiDocument by Postman collection provided"); + var filterByCollectionOption = new Option("--filter-by-collection", "Filters OpenApiDocument by Postman collection provided. Provide path to collection file."); filterByCollectionOption.AddAlias("-c"); var inlineLocalOption = new Option("--inlineLocal", "Inline local $ref instances"); From 17e738691844fee2f35c5475b64899452a84d566 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sun, 27 Mar 2022 17:09:34 -0400 Subject: [PATCH 263/288] Updated Verify nupkg --- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj index 066d20658..5ae43a371 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -20,8 +20,8 @@ - - + + all From 271e1aa66af24548f93b999a91b609d80bc2c90a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 29 Mar 2022 21:13:35 +0000 Subject: [PATCH 264/288] Bump Microsoft.OpenApi.OData from 1.0.10-preview2 to 1.0.10-preview3 Bumps [Microsoft.OpenApi.OData](https://github.com/Microsoft/OpenAPI.NET.OData) from 1.0.10-preview2 to 1.0.10-preview3. - [Release notes](https://github.com/Microsoft/OpenAPI.NET.OData/releases) - [Commits](https://github.com/Microsoft/OpenAPI.NET.OData/commits) --- updated-dependencies: - dependency-name: Microsoft.OpenApi.OData dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- 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 98def8818..128521424 100644 --- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj +++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj @@ -46,7 +46,7 @@ - + From 0ecaed80638ebf6de212e0324895873191b6ee3e Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sun, 3 Apr 2022 20:40:05 -0400 Subject: [PATCH 265/288] Convert anyOf/oneOf to allOf with first schema when writing v2 --- src/Microsoft.OpenApi/Models/OpenApiSchema.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs index 74aed7da1..036222261 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiSchema.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiSchema.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System.Collections.Generic; +using System.Linq; using Microsoft.OpenApi.Any; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Writers; @@ -260,7 +261,7 @@ public void SerializeAsV3(IOpenApiWriter writer) { Reference.SerializeAsV3(writer); return; - } + } else { if (Reference.IsExternal) // Temporary until v2 @@ -644,6 +645,20 @@ internal void WriteAsSchemaProperties( // allOf writer.WriteOptionalCollection(OpenApiConstants.AllOf, AllOf, (w, s) => s.SerializeAsV2(w)); + // If there isn't already an AllOf, and the schema contains a oneOf or anyOf write an allOf with the first + // schema in the list as an attempt to guess at a graceful downgrade situation. + if (AllOf == null || AllOf.Count == 0) + { + // anyOf (Not Supported in V2) - Write the first schema only as an allOf. + writer.WriteOptionalCollection(OpenApiConstants.AllOf, AnyOf.Take(1), (w, s) => s.SerializeAsV2(w)); + + if (AnyOf == null || AnyOf.Count == 0) + { + // oneOf (Not Supported in V2) - Write the first schema only as an allOf. + writer.WriteOptionalCollection(OpenApiConstants.AllOf, OneOf.Take(1), (w, s) => s.SerializeAsV2(w)); + } + } + // properties writer.WriteOptionalMap(OpenApiConstants.Properties, Properties, (w, key, s) => s.SerializeAsV2(w, Required, key)); From 172c4538e2a8e35192de2a95f005a443c678448f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Apr 2022 21:10:39 +0000 Subject: [PATCH 266/288] Bump Verify from 16.4.4 to 16.5.4 Bumps [Verify](https://github.com/VerifyTests/Verify) from 16.4.4 to 16.5.4. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/commits) --- 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 5ae43a371..d67a655cc 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -20,7 +20,7 @@ - + From c3e898038367b6f1662d7f94249a0faa37ebc322 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 Apr 2022 21:10:44 +0000 Subject: [PATCH 267/288] Bump FluentAssertions from 6.5.1 to 6.6.0 Bumps [FluentAssertions](https://github.com/fluentassertions/fluentassertions) from 6.5.1 to 6.6.0. - [Release notes](https://github.com/fluentassertions/fluentassertions/releases) - [Changelog](https://github.com/fluentassertions/fluentassertions/blob/develop/AcceptApiChanges.ps1) - [Commits](https://github.com/fluentassertions/fluentassertions/compare/6.5.1...6.6.0) --- updated-dependencies: - dependency-name: FluentAssertions dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- .../Microsoft.OpenApi.Readers.Tests.csproj | 2 +- test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj | 2 +- 2 files changed, 2 insertions(+), 2 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 7d346009e..bfcba0163 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 5ae43a371..9ba4c4501 100644 --- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj +++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj @@ -15,7 +15,7 @@ - + From d0f41afa89031a0093b8ea1ab4c40e330574eb8c Mon Sep 17 00:00:00 2001 From: Dmitrii Korolev Date: Fri, 8 Apr 2022 20:00:43 +0200 Subject: [PATCH 268/288] resolve local file reference with Schema type properly --- .../V3/OpenApiV3VersionService.cs | 20 ++++++++----------- .../ConvertToOpenApiReferenceV3Tests.cs | 16 +++++++++++++++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs index 65acbc4e0..c967cde55 100644 --- a/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs +++ b/src/Microsoft.OpenApi.Readers/V3/OpenApiV3VersionService.cs @@ -75,18 +75,6 @@ public OpenApiReference ConvertToOpenApiReference( var segments = reference.Split('#'); if (segments.Length == 1) { - // Either this is an external reference as an entire file - // or a simple string-style reference for tag and security scheme. - if (type == null) - { - // "$ref": "Pet.json" - return new OpenApiReference - { - Type = type, - ExternalResource = segments[0] - }; - } - if (type == ReferenceType.Tag || type == ReferenceType.SecurityScheme) { return new OpenApiReference @@ -95,6 +83,14 @@ public OpenApiReference ConvertToOpenApiReference( Id = reference }; } + + // Either this is an external reference as an entire file + // or a simple string-style reference for tag and security scheme. + return new OpenApiReference + { + Type = type, + ExternalResource = segments[0] + }; } else if (segments.Length == 2) { diff --git a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs index c4e88998e..f7368b09b 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/ConvertToOpenApiReferenceV3Tests.cs @@ -108,5 +108,21 @@ public void ParseSecuritySchemeReference() reference.ExternalResource.Should().BeNull(); reference.Id.Should().Be(id); } + + [Fact] + public void ParseLocalFileReference() + { + // Arrange + var versionService = new OpenApiV3VersionService(Diagnostic); + var referenceType = ReferenceType.Schema; + var input = $"../schemas/collection.json"; + + // Act + var reference = versionService.ConvertToOpenApiReference(input, referenceType); + + // Assert + reference.Type.Should().Be(referenceType); + reference.ExternalResource.Should().Be(input); + } } } From decde9db830ecd5ddc5d0d7c49cd2d626c324fd0 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sat, 9 Apr 2022 14:57:09 -0400 Subject: [PATCH 269/288] Added support for Validation to produce warnings as well as errors --- .../OpenApiDiagnostic.cs | 5 +++ .../OpenApiYamlDocumentReader.cs | 11 ++++- .../Extensions/OpenApiElementExtensions.cs | 3 +- .../Validations/IValidationContext.cs | 6 +++ .../Validations/OpenApiValidatiorWarning.cs | 28 +++++++++++++ .../Validations/OpenApiValidator.cs | 25 ++++++++++++ .../Validations/Rules/OpenApiHeaderRules.cs | 1 + .../Rules/OpenApiMediaTypeRules.cs | 2 +- .../Validations/Rules/OpenApiSchemaRules.cs | 1 + .../Validations/Rules/RuleHelpers.cs | 28 ++++++------- .../Validations/ValidationExtensions.cs | 10 +++++ .../PublicApi/PublicApi.approved.txt | 10 +++++ .../OpenApiHeaderValidationTests.cs | 17 ++++---- .../OpenApiMediaTypeValidationTests.cs | 22 +++++----- .../OpenApiParameterValidationTests.cs | 20 +++++----- .../OpenApiSchemaValidationTests.cs | 40 +++++++++---------- .../Validations/ValidationRuleSetTests.cs | 2 +- 17 files changed, 162 insertions(+), 69 deletions(-) create mode 100644 src/Microsoft.OpenApi/Validations/OpenApiValidatiorWarning.cs diff --git a/src/Microsoft.OpenApi.Readers/OpenApiDiagnostic.cs b/src/Microsoft.OpenApi.Readers/OpenApiDiagnostic.cs index ea11c7939..c3178ccfb 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiDiagnostic.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiDiagnostic.cs @@ -17,6 +17,11 @@ public class OpenApiDiagnostic : IDiagnostic /// public IList Errors { get; set; } = new List(); + /// + /// List of all warnings + /// + public IList Warnings { get; set; } = new List(); + /// /// Open API specification version of the document parsed. /// diff --git a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs index 6cf64a5bb..aae09ec86 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiYamlDocumentReader.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Threading.Tasks; using Microsoft.OpenApi.Exceptions; using Microsoft.OpenApi.Extensions; @@ -12,6 +13,7 @@ using Microsoft.OpenApi.Readers.Interface; using Microsoft.OpenApi.Readers.Services; using Microsoft.OpenApi.Services; +using Microsoft.OpenApi.Validations; using SharpYaml.Serialization; namespace Microsoft.OpenApi.Readers @@ -68,11 +70,16 @@ public OpenApiDocument Read(YamlDocument input, out OpenApiDiagnostic diagnostic // Validate the document if (_settings.RuleSet != null && _settings.RuleSet.Rules.Count > 0) { - var errors = document.Validate(_settings.RuleSet); - foreach (var item in errors) + var openApiErrors = document.Validate(_settings.RuleSet); + foreach (var item in openApiErrors.Where(e => e is OpenApiValidatorError)) { diagnostic.Errors.Add(item); } + foreach (var item in openApiErrors.Where(e => e is OpenApiValidatorWarning)) + { + diagnostic.Warnings.Add(item); + } + } return document; diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiElementExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiElementExtensions.cs index 81893a3b2..a047c066d 100644 --- a/src/Microsoft.OpenApi/Extensions/OpenApiElementExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiElementExtensions.cs @@ -2,6 +2,7 @@ // Licensed under the MIT license. using System.Collections.Generic; +using System.Linq; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Services; @@ -25,7 +26,7 @@ public static IEnumerable Validate(this IOpenApiElement element, V var validator = new OpenApiValidator(ruleSet); var walker = new OpenApiWalker(validator); walker.Walk(element); - return validator.Errors; + return validator.Errors.Cast().Union(validator.Warnings); } } } diff --git a/src/Microsoft.OpenApi/Validations/IValidationContext.cs b/src/Microsoft.OpenApi/Validations/IValidationContext.cs index 58f324bab..7ab4d08e7 100644 --- a/src/Microsoft.OpenApi/Validations/IValidationContext.cs +++ b/src/Microsoft.OpenApi/Validations/IValidationContext.cs @@ -14,6 +14,12 @@ public interface IValidationContext /// Error to register. void AddError(OpenApiValidatorError error); + /// + /// Register a warning with the validation context. + /// + /// Warning to register. + void AddWarning(OpenApiValidatorWarning warning); + /// /// Allow Rule to indicate validation error occured at a deeper context level. /// diff --git a/src/Microsoft.OpenApi/Validations/OpenApiValidatiorWarning.cs b/src/Microsoft.OpenApi/Validations/OpenApiValidatiorWarning.cs new file mode 100644 index 000000000..77480584d --- /dev/null +++ b/src/Microsoft.OpenApi/Validations/OpenApiValidatiorWarning.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Microsoft.OpenApi.Exceptions; +using Microsoft.OpenApi.Models; + +namespace Microsoft.OpenApi.Validations +{ + /// + /// Warnings detected when validating an OpenAPI Element + /// + public class OpenApiValidatorWarning : OpenApiError + { + /// + /// Initializes the class. + /// + public OpenApiValidatorWarning(string ruleName, string pointer, string message) : base(pointer, message) + { + RuleName = ruleName; + } + + /// + /// Name of rule that detected the error. + /// + public string RuleName { get; set; } + } + +} diff --git a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs index 69bcda93d..ba2ed4129 100644 --- a/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs +++ b/src/Microsoft.OpenApi/Validations/OpenApiValidator.cs @@ -17,6 +17,7 @@ public class OpenApiValidator : OpenApiVisitorBase, IValidationContext { private readonly ValidationRuleSet _ruleSet; private readonly IList _errors = new List(); + private readonly IList _warnings = new List(); /// /// Create a vistor that will validate an OpenAPIDocument @@ -38,6 +39,17 @@ public IEnumerable Errors } } + /// + /// Gets the validation warnings. + /// + public IEnumerable Warnings + { + get + { + return _warnings; + } + } + /// /// Register an error with the validation context. /// @@ -52,6 +64,19 @@ public void AddError(OpenApiValidatorError error) _errors.Add(error); } + /// + /// Register an error with the validation context. + /// + /// Error to register. + public void AddWarning(OpenApiValidatorWarning warning) + { + if (warning == null) + { + throw Error.ArgumentNull(nameof(warning)); + } + + _warnings.Add(warning); + } /// /// Execute validation rules against an diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs index f2b036457..9ffbc38f4 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiHeaderRules.cs @@ -10,6 +10,7 @@ namespace Microsoft.OpenApi.Validations.Rules /// /// The validation rules for . /// + //Removed from Default Rules as this is not a MUST in OpenAPI [OpenApiRule] public static class OpenApiHeaderRules { diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs index c86b5e79e..21ad4ef72 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiMediaTypeRules.cs @@ -17,7 +17,7 @@ namespace Microsoft.OpenApi.Validations.Rules /// Future versions of the example parsers should not try an infer types. /// Example validation should be done as a separate post reading step so all schemas can be fully available. /// - //[OpenApiRule] + [OpenApiRule] public static class OpenApiMediaTypeRules { /// diff --git a/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs b/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs index 8c45c8ff9..1639e6248 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/OpenApiSchemaRules.cs @@ -11,6 +11,7 @@ namespace Microsoft.OpenApi.Validations.Rules /// /// The validation rules for . /// + [OpenApiRule] public static class OpenApiSchemaRules { diff --git a/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs b/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs index 05cce7fbc..630dc8e65 100644 --- a/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs +++ b/src/Microsoft.OpenApi/Validations/Rules/RuleHelpers.cs @@ -77,7 +77,7 @@ public static void ValidateDataTypeMismatch( // If value is not a string and also not an object, there is a data mismatch. if (!(value is OpenApiObject)) { - context.CreateError( + context.CreateWarning( ruleName, DataTypeMismatchedErrorMessage); return; @@ -117,7 +117,7 @@ public static void ValidateDataTypeMismatch( // If value is not a string and also not an array, there is a data mismatch. if (!(value is OpenApiArray)) { - context.CreateError( + context.CreateWarning( ruleName, DataTypeMismatchedErrorMessage); return; @@ -141,7 +141,7 @@ public static void ValidateDataTypeMismatch( { if (!(value is OpenApiInteger)) { - context.CreateError( + context.CreateWarning( ruleName, DataTypeMismatchedErrorMessage); } @@ -153,7 +153,7 @@ public static void ValidateDataTypeMismatch( { if (!(value is OpenApiLong)) { - context.CreateError( + context.CreateWarning( ruleName, DataTypeMismatchedErrorMessage); } @@ -165,7 +165,7 @@ public static void ValidateDataTypeMismatch( { if (!(value is OpenApiInteger)) { - context.CreateError( + context.CreateWarning( ruleName, DataTypeMismatchedErrorMessage); } @@ -177,7 +177,7 @@ public static void ValidateDataTypeMismatch( { if (!(value is OpenApiFloat)) { - context.CreateError( + context.CreateWarning( ruleName, DataTypeMismatchedErrorMessage); } @@ -189,7 +189,7 @@ public static void ValidateDataTypeMismatch( { if (!(value is OpenApiDouble)) { - context.CreateError( + context.CreateWarning( ruleName, DataTypeMismatchedErrorMessage); } @@ -201,7 +201,7 @@ public static void ValidateDataTypeMismatch( { if (!(value is OpenApiDouble)) { - context.CreateError( + context.CreateWarning( ruleName, DataTypeMismatchedErrorMessage); } @@ -213,7 +213,7 @@ public static void ValidateDataTypeMismatch( { if (!(value is OpenApiByte)) { - context.CreateError( + context.CreateWarning( ruleName, DataTypeMismatchedErrorMessage); } @@ -225,7 +225,7 @@ public static void ValidateDataTypeMismatch( { if (!(value is OpenApiDate)) { - context.CreateError( + context.CreateWarning( ruleName, DataTypeMismatchedErrorMessage); } @@ -237,7 +237,7 @@ public static void ValidateDataTypeMismatch( { if (!(value is OpenApiDateTime)) { - context.CreateError( + context.CreateWarning( ruleName, DataTypeMismatchedErrorMessage); } @@ -249,7 +249,7 @@ public static void ValidateDataTypeMismatch( { if (!(value is OpenApiPassword)) { - context.CreateError( + context.CreateWarning( ruleName, DataTypeMismatchedErrorMessage); } @@ -261,7 +261,7 @@ public static void ValidateDataTypeMismatch( { if (!(value is OpenApiString)) { - context.CreateError( + context.CreateWarning( ruleName, DataTypeMismatchedErrorMessage); } @@ -273,7 +273,7 @@ public static void ValidateDataTypeMismatch( { if (!(value is OpenApiBoolean)) { - context.CreateError( + context.CreateWarning( ruleName, DataTypeMismatchedErrorMessage); } diff --git a/src/Microsoft.OpenApi/Validations/ValidationExtensions.cs b/src/Microsoft.OpenApi/Validations/ValidationExtensions.cs index a66d085c3..195df89cd 100644 --- a/src/Microsoft.OpenApi/Validations/ValidationExtensions.cs +++ b/src/Microsoft.OpenApi/Validations/ValidationExtensions.cs @@ -23,5 +23,15 @@ public static void CreateError(this IValidationContext context, string ruleName, OpenApiValidatorError error = new OpenApiValidatorError(ruleName, context.PathString, message); context.AddError(error); } + + /// + /// Helper method to simplify validation rules + /// + public static void CreateWarning(this IValidationContext context, string ruleName, string message) + { + OpenApiValidatorWarning warning = new OpenApiValidatorWarning(ruleName, context.PathString, message); + context.AddWarning(warning); + } + } } diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 0b1dc1a11..a6299a644 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -1085,6 +1085,7 @@ namespace Microsoft.OpenApi.Validations { string PathString { get; } void AddError(Microsoft.OpenApi.Validations.OpenApiValidatorError error); + void AddWarning(Microsoft.OpenApi.Validations.OpenApiValidatorWarning warning); void Enter(string segment); void Exit(); } @@ -1092,7 +1093,9 @@ namespace Microsoft.OpenApi.Validations { public OpenApiValidator(Microsoft.OpenApi.Validations.ValidationRuleSet ruleSet) { } public System.Collections.Generic.IEnumerable Errors { get; } + public System.Collections.Generic.IEnumerable Warnings { get; } public void AddError(Microsoft.OpenApi.Validations.OpenApiValidatorError error) { } + public void AddWarning(Microsoft.OpenApi.Validations.OpenApiValidatorWarning warning) { } public override void Visit(Microsoft.OpenApi.Interfaces.IOpenApiExtensible item) { } public override void Visit(Microsoft.OpenApi.Interfaces.IOpenApiExtension item) { } public override void Visit(Microsoft.OpenApi.Models.OpenApiCallback item) { } @@ -1119,9 +1122,15 @@ namespace Microsoft.OpenApi.Validations public OpenApiValidatorError(string ruleName, string pointer, string message) { } public string RuleName { get; set; } } + public class OpenApiValidatorWarning : Microsoft.OpenApi.Models.OpenApiError + { + public OpenApiValidatorWarning(string ruleName, string pointer, string message) { } + public string RuleName { get; set; } + } public static class ValidationContextExtensions { public static void CreateError(this Microsoft.OpenApi.Validations.IValidationContext context, string ruleName, string message) { } + public static void CreateWarning(this Microsoft.OpenApi.Validations.IValidationContext context, string ruleName, string message) { } } public abstract class ValidationRule { @@ -1188,6 +1197,7 @@ namespace Microsoft.OpenApi.Validations.Rules { public static Microsoft.OpenApi.Validations.ValidationRule LicenseRequiredFields { get; } } + [Microsoft.OpenApi.Validations.Rules.OpenApiRule] public static class OpenApiMediaTypeRules { public static Microsoft.OpenApi.Validations.ValidationRule MediaTypeMismatchedDataType { get; } diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs index 62fc2d1ce..6a082ec0f 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiHeaderValidationTests.cs @@ -38,15 +38,16 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() walker.Walk(header); errors = validator.Errors; - bool result = !errors.Any(); + var warnings = validator.Warnings; + bool result = !warnings.Any(); // Assert result.Should().BeFalse(); - errors.Select(e => e.Message).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] { RuleHelpers.DataTypeMismatchedErrorMessage }); - errors.Select(e => e.Pointer).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] { "#/example", }); @@ -56,7 +57,7 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange - IEnumerable errors; + IEnumerable warnings; var header = new OpenApiHeader() { @@ -108,18 +109,18 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() var walker = new OpenApiWalker(validator); walker.Walk(header); - errors = validator.Errors; - bool result = !errors.Any(); + warnings = validator.Warnings; + bool result = !warnings.Any(); // Assert result.Should().BeFalse(); - errors.Select(e => e.Message).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] { RuleHelpers.DataTypeMismatchedErrorMessage, RuleHelpers.DataTypeMismatchedErrorMessage, RuleHelpers.DataTypeMismatchedErrorMessage, }); - errors.Select(e => e.Pointer).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] { // #enum/0 is not an error since the spec allows // representing an object using a string. diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs index fe36bb8c2..bdffaff28 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiMediaTypeValidationTests.cs @@ -21,7 +21,7 @@ public class OpenApiMediaTypeValidationTests public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange - IEnumerable errors; + IEnumerable warnings; var mediaType = new OpenApiMediaType() { Example = new OpenApiInteger(55), @@ -33,21 +33,20 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() // Act var ruleset = ValidationRuleSet.GetDefaultRuleSet(); - ruleset.Add(OpenApiMediaTypeRules.MediaTypeMismatchedDataType); var validator = new OpenApiValidator(ruleset); var walker = new OpenApiWalker(validator); walker.Walk(mediaType); - errors = validator.Errors; - bool result = !errors.Any(); + warnings = validator.Warnings; + bool result = !warnings.Any(); // Assert result.Should().BeFalse(); - errors.Select(e => e.Message).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] { RuleHelpers.DataTypeMismatchedErrorMessage }); - errors.Select(e => e.Pointer).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] { "#/example", }); @@ -57,7 +56,7 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange - IEnumerable errors; + IEnumerable warnings; var mediaType = new OpenApiMediaType() { @@ -105,23 +104,22 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() // Act var ruleset = ValidationRuleSet.GetDefaultRuleSet(); - ruleset.Add(OpenApiMediaTypeRules.MediaTypeMismatchedDataType); var validator = new OpenApiValidator(ruleset); var walker = new OpenApiWalker(validator); walker.Walk(mediaType); - errors = validator.Errors; - bool result = !errors.Any(); + warnings = validator.Warnings; + bool result = !warnings.Any(); // Assert result.Should().BeFalse(); - errors.Select(e => e.Message).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] { RuleHelpers.DataTypeMismatchedErrorMessage, RuleHelpers.DataTypeMismatchedErrorMessage, RuleHelpers.DataTypeMismatchedErrorMessage, }); - errors.Select(e => e.Pointer).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] { // #enum/0 is not an error since the spec allows // representing an object using a string. diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs index a7abfd9d8..89be676c5 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiParameterValidationTests.cs @@ -65,7 +65,7 @@ public void ValidateRequiredIsTrueWhenInIsPathInParameter() public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange - IEnumerable errors; + IEnumerable warnings; var parameter = new OpenApiParameter() { Name = "parameter1", @@ -84,16 +84,16 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() var walker = new OpenApiWalker(validator); walker.Walk(parameter); - errors = validator.Errors; - bool result = !errors.Any(); + warnings = validator.Warnings; + bool result = !warnings.Any(); // Assert result.Should().BeFalse(); - errors.Select(e => e.Message).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] { RuleHelpers.DataTypeMismatchedErrorMessage }); - errors.Select(e => e.Pointer).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] { "#/{parameter1}/example", }); @@ -103,7 +103,7 @@ public void ValidateExampleShouldNotHaveDataTypeMismatchForSimpleSchema() public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange - IEnumerable errors; + IEnumerable warnings; var parameter = new OpenApiParameter() { @@ -158,18 +158,18 @@ public void ValidateExamplesShouldNotHaveDataTypeMismatchForSimpleSchema() var walker = new OpenApiWalker(validator); walker.Walk(parameter); - errors = validator.Errors; - bool result = !errors.Any(); + warnings = validator.Warnings; + bool result = !warnings.Any(); // Assert result.Should().BeFalse(); - errors.Select(e => e.Message).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] { RuleHelpers.DataTypeMismatchedErrorMessage, RuleHelpers.DataTypeMismatchedErrorMessage, RuleHelpers.DataTypeMismatchedErrorMessage, }); - errors.Select(e => e.Pointer).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] { // #enum/0 is not an error since the spec allows // representing an object using a string. diff --git a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs index 91b1643fa..d239e15a1 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/OpenApiSchemaValidationTests.cs @@ -21,7 +21,7 @@ public class OpenApiSchemaValidationTests public void ValidateDefaultShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange - IEnumerable errors; + IEnumerable warnings; var schema = new OpenApiSchema() { Default = new OpenApiInteger(55), @@ -33,16 +33,16 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForSimpleSchema() var walker = new OpenApiWalker(validator); walker.Walk(schema); - errors = validator.Errors; - bool result = !errors.Any(); + warnings = validator.Warnings; + bool result = !warnings.Any(); // Assert result.Should().BeFalse(); - errors.Select(e => e.Message).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] { RuleHelpers.DataTypeMismatchedErrorMessage }); - errors.Select(e => e.Pointer).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] { "#/default", }); @@ -52,7 +52,7 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForSimpleSchema() public void ValidateExampleAndDefaultShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange - IEnumerable errors; + IEnumerable warnings; var schema = new OpenApiSchema() { Example = new OpenApiLong(55), @@ -65,17 +65,17 @@ public void ValidateExampleAndDefaultShouldNotHaveDataTypeMismatchForSimpleSchem var walker = new OpenApiWalker(validator); walker.Walk(schema); - errors = validator.Errors; - bool result = !errors.Any(); + warnings = validator.Warnings; + bool result = !warnings.Any(); // Assert result.Should().BeFalse(); - errors.Select(e => e.Message).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] { RuleHelpers.DataTypeMismatchedErrorMessage, RuleHelpers.DataTypeMismatchedErrorMessage }); - errors.Select(e => e.Pointer).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] { "#/default", "#/example", @@ -86,7 +86,7 @@ public void ValidateExampleAndDefaultShouldNotHaveDataTypeMismatchForSimpleSchem public void ValidateEnumShouldNotHaveDataTypeMismatchForSimpleSchema() { // Arrange - IEnumerable errors; + IEnumerable warnings; var schema = new OpenApiSchema() { Enum = @@ -120,18 +120,18 @@ public void ValidateEnumShouldNotHaveDataTypeMismatchForSimpleSchema() var walker = new OpenApiWalker(validator); walker.Walk(schema); - errors = validator.Errors; - bool result = !errors.Any(); + warnings = validator.Warnings; + bool result = !warnings.Any(); // Assert result.Should().BeFalse(); - errors.Select(e => e.Message).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] { RuleHelpers.DataTypeMismatchedErrorMessage, RuleHelpers.DataTypeMismatchedErrorMessage, RuleHelpers.DataTypeMismatchedErrorMessage, }); - errors.Select(e => e.Pointer).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] { // #enum/0 is not an error since the spec allows // representing an object using a string. @@ -145,7 +145,7 @@ public void ValidateEnumShouldNotHaveDataTypeMismatchForSimpleSchema() public void ValidateDefaultShouldNotHaveDataTypeMismatchForComplexSchema() { // Arrange - IEnumerable errors; + IEnumerable warnings; var schema = new OpenApiSchema() { Type = "object", @@ -210,12 +210,12 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForComplexSchema() var walker = new OpenApiWalker(validator); walker.Walk(schema); - errors = validator.Errors; - bool result = !errors.Any(); + warnings = validator.Warnings; + bool result = !warnings.Any(); // Assert result.Should().BeFalse(); - errors.Select(e => e.Message).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Message).Should().BeEquivalentTo(new[] { RuleHelpers.DataTypeMismatchedErrorMessage, RuleHelpers.DataTypeMismatchedErrorMessage, @@ -223,7 +223,7 @@ public void ValidateDefaultShouldNotHaveDataTypeMismatchForComplexSchema() RuleHelpers.DataTypeMismatchedErrorMessage, RuleHelpers.DataTypeMismatchedErrorMessage, }); - errors.Select(e => e.Pointer).Should().BeEquivalentTo(new[] + warnings.Select(e => e.Pointer).Should().BeEquivalentTo(new[] { "#/default/property1/0", "#/default/property1/2", diff --git a/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs b/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs index af259cf1b..8153e6054 100644 --- a/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs +++ b/test/Microsoft.OpenApi.Tests/Validations/ValidationRuleSetTests.cs @@ -43,7 +43,7 @@ public void DefaultRuleSetPropertyReturnsTheCorrectRules() Assert.NotEmpty(rules); // Update the number if you add new default rule(s). - Assert.Equal(21, rules.Count); + Assert.Equal(22, rules.Count); } } } From f1b1be1e739091bee88b9619df3c84b621adc155 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 9 Apr 2022 19:19:16 +0000 Subject: [PATCH 270/288] Bump Verify.Xunit from 16.4.4 to 16.5.4 Bumps [Verify.Xunit](https://github.com/VerifyTests/Verify) from 16.4.4 to 16.5.4. - [Release notes](https://github.com/VerifyTests/Verify/releases) - [Commits](https://github.com/VerifyTests/Verify/commits) --- 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 2766de246..39026a9f7 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 c9835c243a07703e2e4b3e47332da0781975cab4 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sat, 9 Apr 2022 16:57:03 -0400 Subject: [PATCH 271/288] Updated package version to preview6 --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 128521424..72ec16c0b 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.5.0-preview5 + 0.5.0-preview6 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 77b9cad26..62da19f40 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -10,7 +10,7 @@ Microsoft Microsoft.OpenApi.Readers Microsoft.OpenApi.Readers - 1.3.1-preview5 + 1.3.1-preview6 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 7f3671942..b6f960daa 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-preview5 + 1.3.1-preview6 .NET models with JSON and YAML writers for OpenAPI specification © Microsoft Corporation. All rights reserved. OpenAPI .NET From e990ca537b0da1547841b407a09fb369a54dc75f Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sun, 10 Apr 2022 16:55:19 -0400 Subject: [PATCH 272/288] Made ResolveReference public again as it is used by Swashbuckle --- src/Microsoft.OpenApi/Models/OpenApiDocument.cs | 2 +- test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 6ffc260d1..317cdab25 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -351,7 +351,7 @@ internal T ResolveReferenceTo(OpenApiReference reference) where T : class, IO /// /// Load the referenced object from a object /// - internal IOpenApiReferenceable ResolveReference(OpenApiReference reference, bool useExternal) + public IOpenApiReferenceable ResolveReference(OpenApiReference reference, bool useExternal) { if (reference == null) { diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 0b1dc1a11..90e9d8f1a 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -508,6 +508,7 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.IList Servers { get; set; } public System.Collections.Generic.IList Tags { get; set; } public Microsoft.OpenApi.Services.OpenApiWorkspace Workspace { get; set; } + public Microsoft.OpenApi.Interfaces.IOpenApiReferenceable ResolveReference(Microsoft.OpenApi.Models.OpenApiReference reference, bool useExternal) { } public System.Collections.Generic.IEnumerable ResolveReferences() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } From eb2189d08502574741dd997be06a09c8033a63fa Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sun, 10 Apr 2022 16:58:25 -0400 Subject: [PATCH 273/288] Made ResolveReference public again as it is used by Swashbuckle --- src/Microsoft.OpenApi/Models/OpenApiDocument.cs | 2 +- test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 6ffc260d1..317cdab25 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -351,7 +351,7 @@ internal T ResolveReferenceTo(OpenApiReference reference) where T : class, IO /// /// Load the referenced object from a object /// - internal IOpenApiReferenceable ResolveReference(OpenApiReference reference, bool useExternal) + public IOpenApiReferenceable ResolveReference(OpenApiReference reference, bool useExternal) { if (reference == null) { diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 0b1dc1a11..90e9d8f1a 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -508,6 +508,7 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.IList Servers { get; set; } public System.Collections.Generic.IList Tags { get; set; } public Microsoft.OpenApi.Services.OpenApiWorkspace Workspace { get; set; } + public Microsoft.OpenApi.Interfaces.IOpenApiReferenceable ResolveReference(Microsoft.OpenApi.Models.OpenApiReference reference, bool useExternal) { } public System.Collections.Generic.IEnumerable ResolveReferences() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } From 3f19293f23bee4c2c2c674f5314e42b8eb8866f6 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sun, 10 Apr 2022 17:03:38 -0400 Subject: [PATCH 274/288] Revert "Made ResolveReference public again as it is used by Swashbuckle" This reverts commit e990ca537b0da1547841b407a09fb369a54dc75f. --- src/Microsoft.OpenApi/Models/OpenApiDocument.cs | 2 +- test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 317cdab25..6ffc260d1 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -351,7 +351,7 @@ internal T ResolveReferenceTo(OpenApiReference reference) where T : class, IO /// /// Load the referenced object from a object /// - public IOpenApiReferenceable ResolveReference(OpenApiReference reference, bool useExternal) + internal IOpenApiReferenceable ResolveReference(OpenApiReference reference, bool useExternal) { if (reference == null) { diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 90e9d8f1a..0b1dc1a11 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -508,7 +508,6 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.IList Servers { get; set; } public System.Collections.Generic.IList Tags { get; set; } public Microsoft.OpenApi.Services.OpenApiWorkspace Workspace { get; set; } - public Microsoft.OpenApi.Interfaces.IOpenApiReferenceable ResolveReference(Microsoft.OpenApi.Models.OpenApiReference reference, bool useExternal) { } public System.Collections.Generic.IEnumerable ResolveReferences() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } From 7e99738c2417f8af6957afebd414e57175408d2b Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sun, 10 Apr 2022 18:17:26 -0400 Subject: [PATCH 275/288] Remove unnecessary reference that made netcoreapp2.1 incompatible --- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj index 7f3671942..4f7775d87 100644 --- a/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj +++ b/src/Microsoft.OpenApi/Microsoft.OpenApi.csproj @@ -38,7 +38,6 @@ - From 85367f539870658015110f8d42f6f52a66a51d40 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Sun, 10 Apr 2022 20:12:20 -0400 Subject: [PATCH 276/288] Fixed resolveReference properly this time --- src/Microsoft.OpenApi/Models/OpenApiDocument.cs | 10 +++++++++- .../PublicApi/PublicApi.approved.txt | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs index 317cdab25..59b8da16c 100644 --- a/src/Microsoft.OpenApi/Models/OpenApiDocument.cs +++ b/src/Microsoft.OpenApi/Models/OpenApiDocument.cs @@ -351,7 +351,15 @@ internal T ResolveReferenceTo(OpenApiReference reference) where T : class, IO /// /// Load the referenced object from a object /// - public IOpenApiReferenceable ResolveReference(OpenApiReference reference, bool useExternal) + public IOpenApiReferenceable ResolveReference(OpenApiReference reference) + { + return ResolveReference(reference, false); + } + + /// + /// Load the referenced object from a object + /// + internal IOpenApiReferenceable ResolveReference(OpenApiReference reference, bool useExternal) { if (reference == null) { diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index 90e9d8f1a..e7ba33dca 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -508,7 +508,7 @@ namespace Microsoft.OpenApi.Models public System.Collections.Generic.IList Servers { get; set; } public System.Collections.Generic.IList Tags { get; set; } public Microsoft.OpenApi.Services.OpenApiWorkspace Workspace { get; set; } - public Microsoft.OpenApi.Interfaces.IOpenApiReferenceable ResolveReference(Microsoft.OpenApi.Models.OpenApiReference reference, bool useExternal) { } + public Microsoft.OpenApi.Interfaces.IOpenApiReferenceable ResolveReference(Microsoft.OpenApi.Models.OpenApiReference reference) { } public System.Collections.Generic.IEnumerable ResolveReferences() { } public void SerializeAsV2(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } public void SerializeAsV3(Microsoft.OpenApi.Writers.IOpenApiWriter writer) { } From fce10efa2efa1917aeeeb7425c7588ef0c36fef4 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 11 Apr 2022 15:19:49 +0300 Subject: [PATCH 277/288] Update ci-build.yml for Azure Pipelines --- .azure-pipelines/ci-build.yml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 31af5bd24..1cb35abe1 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -270,11 +270,13 @@ stages: inputs: source: current - pwsh: | - $artifactName = Get-ChildItem -Path $(Pipeline.Workspace) -Filter Microsoft.OpenApi.Hidi-* -recurse | select -First 1 - $artifactVersion= $artifactName -replace "Microsoft.OpenApi.Hidi-", "" + $artifactName = Get-ChildItem -Path $(Pipeline.Workspace)\Nugets -Filter Microsoft.OpenApi.*.nupkg -recurse | select -First 1 + $artifactVersion= $artifactName -replace "Microsoft.OpenApi.", "" -replace ".nupkg", "" #Set Variable $artifactName and $artifactVersion Write-Host "##vso[task.setvariable variable=artifactVersion; isSecret=false; isOutput=true]$artifactVersion" Write-Host "##vso[task.setvariable variable=artifactName; isSecret=false; isOutput=true]$artifactName.FullName" + echo $artifactName + echo $artifactVersion displayName: 'Fetch Artifact Name' - task: NuGetCommand@2 @@ -290,7 +292,7 @@ stages: gitHubConnection: 'Github-MaggieKimani1' tagSource: userSpecifiedTag tag: '$(artifactVersion)' - title: '$(artifactName)' + title: '$(artifactVersion)' releaseNotesSource: inline assets: '$(Pipeline.Workspace)\**\*.exe' changeLogType: issueBased From 2fa91a81bc01bfeac0e66e3fa0b76f2852f6ffbf Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 11 Apr 2022 15:50:23 +0300 Subject: [PATCH 278/288] Update ci-build.yml for Azure Pipelines --- .azure-pipelines/ci-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines/ci-build.yml b/.azure-pipelines/ci-build.yml index 1cb35abe1..9c163ea17 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -275,8 +275,8 @@ stages: #Set Variable $artifactName and $artifactVersion Write-Host "##vso[task.setvariable variable=artifactVersion; isSecret=false; isOutput=true]$artifactVersion" Write-Host "##vso[task.setvariable variable=artifactName; isSecret=false; isOutput=true]$artifactName.FullName" - echo $artifactName - echo $artifactVersion + echo "$artifactName" + echo "$artifactVersion" displayName: 'Fetch Artifact Name' - task: NuGetCommand@2 From 27dd1e9b0fcc73ee1bbcd28efbe060a104014967 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Mon, 11 Apr 2022 15:59:38 +0300 Subject: [PATCH 279/288] Update ci-build.yml for Azure Pipelines --- .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 9c163ea17..616776585 100644 --- a/.azure-pipelines/ci-build.yml +++ b/.azure-pipelines/ci-build.yml @@ -271,7 +271,7 @@ stages: source: current - pwsh: | $artifactName = Get-ChildItem -Path $(Pipeline.Workspace)\Nugets -Filter Microsoft.OpenApi.*.nupkg -recurse | select -First 1 - $artifactVersion= $artifactName -replace "Microsoft.OpenApi.", "" -replace ".nupkg", "" + $artifactVersion= $artifactName.Name -replace "Microsoft.OpenApi.", "" -replace ".nupkg", "" #Set Variable $artifactName and $artifactVersion Write-Host "##vso[task.setvariable variable=artifactVersion; isSecret=false; isOutput=true]$artifactVersion" Write-Host "##vso[task.setvariable variable=artifactName; isSecret=false; isOutput=true]$artifactName.FullName" From 274acb583a7d04f90ae66410ef0fdbd967e745d7 Mon Sep 17 00:00:00 2001 From: Darrel Miller Date: Mon, 11 Apr 2022 22:45:23 -0400 Subject: [PATCH 280/288] Updated version numbers --- src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj | 2 +- src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj | 2 +- src/Microsoft.OpenApi/Microsoft.OpenApi.csproj | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj index 72ec16c0b..52d0b3c1e 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.5.0-preview6 + 1.0.0-preview1 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 62da19f40..440180d88 100644 --- a/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj +++ b/src/Microsoft.OpenApi.Readers/Microsoft.OpenApi.Readers.csproj @@ -10,7 +10,7 @@ Microsoft Microsoft.OpenApi.Readers Microsoft.OpenApi.Readers - 1.3.1-preview6 + 1.3.1 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 8c699e023..cbdcde393 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-preview6 + 1.3.1 .NET models with JSON and YAML writers for OpenAPI specification © Microsoft Corporation. All rights reserved. OpenAPI .NET From 2c64dad7e22336720bae38a226bc3e4d8510aadf Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 13 Apr 2022 11:45:59 +0300 Subject: [PATCH 281/288] Add an optional --terse output commandline option --- src/Microsoft.OpenApi.Hidi/Program.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/Program.cs b/src/Microsoft.OpenApi.Hidi/Program.cs index 8b466913c..6d06a6986 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -39,6 +39,9 @@ static async Task Main(string[] args) var formatOption = new Option("--format", "File format"); formatOption.AddAlias("-f"); + var terseOutputOption = new Option("--terseOutput", "Produce terse json output"); + terseOutputOption.AddAlias("-to"); + var logLevelOption = new Option("--loglevel", () => LogLevel.Information, "The log level to use when logging messages to the main output."); logLevelOption.AddAlias("-ll"); @@ -74,6 +77,7 @@ static async Task Main(string[] args) cleanOutputOption, versionOption, formatOption, + terseOutputOption, logLevelOption, filterByOperationIdsOption, filterByTagsOption, @@ -82,8 +86,8 @@ static async Task Main(string[] args) inlineExternalOption }; - transformCommand.SetHandler ( - OpenApiService.TransformOpenApiDocument, descriptionOption, csdlOption, csdlFilterOption, outputOption, cleanOutputOption, versionOption, formatOption, logLevelOption, inlineLocalOption, inlineExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); + transformCommand.SetHandler ( + OpenApiService.TransformOpenApiDocument, descriptionOption, csdlOption, csdlFilterOption, outputOption, cleanOutputOption, versionOption, formatOption, terseOutputOption, logLevelOption, inlineLocalOption, inlineExternalOption, filterByOperationIdsOption, filterByTagsOption, filterByCollectionOption); rootCommand.Add(transformCommand); rootCommand.Add(validateCommand); From 2bf6b366afb4d3eb488bc2ceb6b8ac026ee63824 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 13 Apr 2022 11:46:52 +0300 Subject: [PATCH 282/288] Add a terse object to the OpenApiWriterSettings --- src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs index 458d8f4a3..05237bc47 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs @@ -69,6 +69,11 @@ public ReferenceInlineSetting ReferenceInline { /// public bool InlineExternalReferences { get; set; } = false; + /// + /// Indicates whether or not the produced document will be written in a compact or pretty fashion. + /// + public bool Terse { get; set; } = false; + internal bool ShouldInlineReference(OpenApiReference reference) { From afba9d87050ffd67722f755a0ce2d7b23362a747 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 13 Apr 2022 11:47:57 +0300 Subject: [PATCH 283/288] Pass the terseOutput option provided to the OpenApiWriter settings for serializing JSON in a terse format --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 11 +++++++---- src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index feb62042b..3a333b89f 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -44,6 +44,7 @@ public static async Task TransformOpenApiDocument( bool cleanoutput, string? version, OpenApiFormat? format, + bool terseOutput, LogLevel loglevel, bool inlineLocal, bool inlineExternal, @@ -188,11 +189,13 @@ CancellationToken cancellationToken using var outputStream = output?.Create(); var textWriter = outputStream != null ? new StreamWriter(outputStream) : Console.Out; - var settings = new OpenApiWriterSettings() + var settings = new OpenApiWriterSettings(); + if (terseOutput) { - InlineLocalReferences = inlineLocal, - InlineExternalReferences = inlineExternal - }; + settings.Terse = terseOutput; + } + settings.InlineLocalReferences = inlineLocal; + settings.InlineExternalReferences = inlineExternal; IOpenApiWriter writer = openApiFormat switch { diff --git a/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs b/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs index 5454e8da8..7c786fccb 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs @@ -35,6 +35,7 @@ public OpenApiJsonWriter(TextWriter textWriter, OpenApiJsonWriterSettings settin /// Settings for controlling how the OpenAPI document will be written out. public OpenApiJsonWriter(TextWriter textWriter, OpenApiWriterSettings settings) : base(textWriter, settings) { + _produceTerseOutput = settings.Terse; } /// From de72343b31fb5cd9f4e959ef7f745d5c6bb1710f Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Wed, 13 Apr 2022 11:49:52 +0300 Subject: [PATCH 284/288] Update the command format to kebab case --- 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 6d06a6986..80a4c2e14 100644 --- a/src/Microsoft.OpenApi.Hidi/Program.cs +++ b/src/Microsoft.OpenApi.Hidi/Program.cs @@ -39,7 +39,7 @@ static async Task Main(string[] args) var formatOption = new Option("--format", "File format"); formatOption.AddAlias("-f"); - var terseOutputOption = new Option("--terseOutput", "Produce terse json output"); + var terseOutputOption = new Option("--terse-output", "Produce terse json output"); terseOutputOption.AddAlias("-to"); var logLevelOption = new Option("--loglevel", () => LogLevel.Information, "The log level to use when logging messages to the main output."); From 11c346692fff56d10e6ec76536452e60fa494100 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 14 Apr 2022 13:57:27 +0300 Subject: [PATCH 285/288] Add check to prevent null reference exceptions when settings are null --- src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs b/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs index 7c786fccb..41712636b 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs @@ -35,7 +35,10 @@ public OpenApiJsonWriter(TextWriter textWriter, OpenApiJsonWriterSettings settin /// Settings for controlling how the OpenAPI document will be written out. public OpenApiJsonWriter(TextWriter textWriter, OpenApiWriterSettings settings) : base(textWriter, settings) { - _produceTerseOutput = settings.Terse; + if (settings != null) + { + _produceTerseOutput = settings.Terse; + } } /// From 41c198338fecfac12eefc50c15c9670df4ce6f44 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 14 Apr 2022 13:57:47 +0300 Subject: [PATCH 286/288] Update public api interface --- test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index f589fa032..cadd68963 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -1297,7 +1297,7 @@ namespace Microsoft.OpenApi.Writers public class OpenApiJsonWriterSettings : Microsoft.OpenApi.Writers.OpenApiWriterSettings { public OpenApiJsonWriterSettings() { } - public bool Terse { get; set; } + public new bool Terse { get; set; } } public static class OpenApiWriterAnyExtensions { @@ -1379,6 +1379,7 @@ namespace Microsoft.OpenApi.Writers public bool InlineLocalReferences { get; set; } [System.Obsolete("Use InlineLocalReference and InlineExternalReference settings instead")] public Microsoft.OpenApi.Writers.ReferenceInlineSetting ReferenceInline { get; set; } + public bool Terse { get; set; } } public class OpenApiYamlWriter : Microsoft.OpenApi.Writers.OpenApiWriterBase { From 540b624a8efa0c93052ac0e37307dae739b7a5d0 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 14 Apr 2022 17:52:07 +0300 Subject: [PATCH 287/288] Add a terseOutput parameter to the OpenApiJsonWriter and refactor code --- src/Microsoft.OpenApi.Hidi/OpenApiService.cs | 12 +++++------- .../OpenApiSerializableExtensions.cs | 18 ++++++------------ .../Writers/OpenApiJsonWriter.cs | 8 +++----- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs index 3a333b89f..584087ea7 100644 --- a/src/Microsoft.OpenApi.Hidi/OpenApiService.cs +++ b/src/Microsoft.OpenApi.Hidi/OpenApiService.cs @@ -189,17 +189,15 @@ CancellationToken cancellationToken using var outputStream = output?.Create(); var textWriter = outputStream != null ? new StreamWriter(outputStream) : Console.Out; - var settings = new OpenApiWriterSettings(); - if (terseOutput) + var settings = new OpenApiWriterSettings() { - settings.Terse = terseOutput; - } - settings.InlineLocalReferences = inlineLocal; - settings.InlineExternalReferences = inlineExternal; + InlineLocalReferences = inlineLocal, + InlineExternalReferences = inlineExternal + }; IOpenApiWriter writer = openApiFormat switch { - OpenApiFormat.Json => new OpenApiJsonWriter(textWriter, settings), + OpenApiFormat.Json => terseOutput ? new OpenApiJsonWriter(textWriter, settings, terseOutput) : new OpenApiJsonWriter(textWriter, settings, false), OpenApiFormat.Yaml => new OpenApiYamlWriter(textWriter, settings), _ => throw new ArgumentException("Unknown format"), }; diff --git a/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs b/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs index 4694692ad..f60c5483b 100755 --- a/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs +++ b/src/Microsoft.OpenApi/Extensions/OpenApiSerializableExtensions.cs @@ -83,20 +83,14 @@ public static void Serialize( throw Error.ArgumentNull(nameof(stream)); } - IOpenApiWriter writer; var streamWriter = new FormattingStreamWriter(stream, CultureInfo.InvariantCulture); - switch (format) - { - case OpenApiFormat.Json: - writer = new OpenApiJsonWriter(streamWriter,settings); - break; - case OpenApiFormat.Yaml: - writer = new OpenApiYamlWriter(streamWriter, settings); - break; - default: - throw new OpenApiException(string.Format(SRResource.OpenApiFormatNotSupported, format)); - } + IOpenApiWriter writer = format switch + { + OpenApiFormat.Json => new OpenApiJsonWriter(streamWriter, settings, false), + OpenApiFormat.Yaml => new OpenApiYamlWriter(streamWriter, settings), + _ => throw new OpenApiException(string.Format(SRResource.OpenApiFormatNotSupported, format)), + }; element.Serialize(writer, specVersion); } diff --git a/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs b/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs index 41712636b..10049974b 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiJsonWriter.cs @@ -33,12 +33,10 @@ public OpenApiJsonWriter(TextWriter textWriter, OpenApiJsonWriterSettings settin /// /// The text writer. /// Settings for controlling how the OpenAPI document will be written out. - public OpenApiJsonWriter(TextWriter textWriter, OpenApiWriterSettings settings) : base(textWriter, settings) + /// Setting for allowing the JSON emitted to be in terse format. + public OpenApiJsonWriter(TextWriter textWriter, OpenApiWriterSettings settings, bool terseOutput = false) : base(textWriter, settings) { - if (settings != null) - { - _produceTerseOutput = settings.Terse; - } + _produceTerseOutput = terseOutput; } /// From 13e888881c627e8d512ee6e72a7af54941ade424 Mon Sep 17 00:00:00 2001 From: Maggie Kimani Date: Thu, 14 Apr 2022 17:55:06 +0300 Subject: [PATCH 288/288] Clean up --- src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs | 6 ------ .../PublicApi/PublicApi.approved.txt | 5 ++--- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs b/src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs index 05237bc47..cf00c1339 100644 --- a/src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs +++ b/src/Microsoft.OpenApi/Writers/OpenApiWriterSettings.cs @@ -69,12 +69,6 @@ public ReferenceInlineSetting ReferenceInline { /// public bool InlineExternalReferences { get; set; } = false; - /// - /// Indicates whether or not the produced document will be written in a compact or pretty fashion. - /// - public bool Terse { get; set; } = false; - - internal bool ShouldInlineReference(OpenApiReference reference) { return (reference.IsLocal && InlineLocalReferences) diff --git a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt index cadd68963..02400ddd7 100755 --- a/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt +++ b/test/Microsoft.OpenApi.Tests/PublicApi/PublicApi.approved.txt @@ -1281,7 +1281,7 @@ namespace Microsoft.OpenApi.Writers { public OpenApiJsonWriter(System.IO.TextWriter textWriter) { } public OpenApiJsonWriter(System.IO.TextWriter textWriter, Microsoft.OpenApi.Writers.OpenApiJsonWriterSettings settings) { } - public OpenApiJsonWriter(System.IO.TextWriter textWriter, Microsoft.OpenApi.Writers.OpenApiWriterSettings settings) { } + public OpenApiJsonWriter(System.IO.TextWriter textWriter, Microsoft.OpenApi.Writers.OpenApiWriterSettings settings, bool terseOutput = false) { } protected override int BaseIndentation { get; } public override void WriteEndArray() { } public override void WriteEndObject() { } @@ -1297,7 +1297,7 @@ namespace Microsoft.OpenApi.Writers public class OpenApiJsonWriterSettings : Microsoft.OpenApi.Writers.OpenApiWriterSettings { public OpenApiJsonWriterSettings() { } - public new bool Terse { get; set; } + public bool Terse { get; set; } } public static class OpenApiWriterAnyExtensions { @@ -1379,7 +1379,6 @@ namespace Microsoft.OpenApi.Writers public bool InlineLocalReferences { get; set; } [System.Obsolete("Use InlineLocalReference and InlineExternalReference settings instead")] public Microsoft.OpenApi.Writers.ReferenceInlineSetting ReferenceInline { get; set; } - public bool Terse { get; set; } } public class OpenApiYamlWriter : Microsoft.OpenApi.Writers.OpenApiWriterBase {