diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs index b4c331830..6659d3a42 100644 --- a/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiSchemaTests.cs @@ -1,15 +1,18 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // 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.Extensions; using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; +using Microsoft.OpenApi.Services; using Microsoft.OpenApi.Writers; using VerifyXunit; using Xunit; @@ -506,5 +509,56 @@ public void CloningSchemaExtensionsWorks() }; Assert.NotEqual(schema.Extensions, schemaCopy.Extensions); } + + [Fact] + public void OpenApiWalkerVisitsOpenApiSchemaNot() + { + var outerSchema = new OpenApiSchema() + { + Title = "Outer Schema", + Not = new OpenApiSchema() + { + Title = "Inner Schema", + Type = "string", + } + }; + + var document = new OpenApiDocument() + { + Paths = new OpenApiPaths() + { + ["/foo"] = new OpenApiPathItem() + { + Parameters = new[] + { + new OpenApiParameter() + { + Name = "foo", + In = ParameterLocation.Query, + Schema = outerSchema, + } + } + } + } + }; + + // Act + var visitor = new SchemaVisitor(); + var walker = new OpenApiWalker(visitor); + walker.Walk(document); + + // Assert + visitor.Titles.Count.Should().Be(2); + } + } + + internal class SchemaVisitor : OpenApiVisitorBase + { + public List Titles = new(); + + public override void Visit(OpenApiSchema schema) + { + Titles.Add(schema.Title); + } } }