diff --git a/.vscode/settings.json b/.vscode/settings.json
index 186b10bea..619467ff3 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -6,6 +6,7 @@
},
"cSpell.words": [
"csdl",
- "Hidi"
+ "Hidi",
+ "Xunit"
]
}
\ No newline at end of file
diff --git a/performance/resultsComparer/resultsComparer.csproj b/performance/resultsComparer/resultsComparer.csproj
index c409872f6..80a964ca2 100644
--- a/performance/resultsComparer/resultsComparer.csproj
+++ b/performance/resultsComparer/resultsComparer.csproj
@@ -8,12 +8,12 @@
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
index 5ebf5bb4a..f21ca3bbe 100644
--- a/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
+++ b/src/Microsoft.OpenApi.Hidi/Microsoft.OpenApi.Hidi.csproj
@@ -37,8 +37,8 @@
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
-
+
+
diff --git a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj
index 1ab76c96e..a686a0de4 100644
--- a/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj
+++ b/src/Microsoft.OpenApi.Workbench/Microsoft.OpenApi.Workbench.csproj
@@ -1,5 +1,7 @@
-
+
+
+
net8.0-windows
WinExe
false
@@ -8,29 +10,56 @@
true
NU1903
-
+
+
+
+ net8.0
+ Library
+ false
+ NU1903
+
+
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
all
-
+
+
-
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
-
+
+
+
+
\ No newline at end of file
diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj
index 8288bb084..aa951724a 100644
--- a/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj
+++ b/test/Microsoft.OpenApi.Hidi.Tests/Microsoft.OpenApi.Hidi.Tests.csproj
@@ -16,7 +16,7 @@
-
+
diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs
index 483deaf25..9499f3a3c 100644
--- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs
+++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiFilterServiceTests.cs
@@ -51,7 +51,7 @@ public void ReturnFilteredOpenApiDocumentBasedOnOperationIdsAndTags(string? oper
public void ReturnFilteredOpenApiDocumentBasedOnPostmanCollection()
{
// Arrange
- var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "postmanCollection_ver2.json");
+ var filePath = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "postmanCollection_ver2.json");
var fileInput = new FileInfo(filePath);
var stream = fileInput.OpenRead();
@@ -158,7 +158,7 @@ public void CreateFilteredDocumentUsingPredicateFromRequestUrl()
public void ShouldParseNestedPostmanCollection()
{
// Arrange
- var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "postmanCollection_ver3.json");
+ var filePath = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "postmanCollection_ver3.json");
var fileInput = new FileInfo(filePath);
var stream = fileInput.OpenRead();
@@ -175,7 +175,7 @@ public void ShouldParseNestedPostmanCollection()
public void ThrowsExceptionWhenUrlsInCollectionAreMissingFromSourceDocument()
{
// Arrange
- var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "postmanCollection_ver1.json");
+ var filePath = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "postmanCollection_ver1.json");
var fileInput = new FileInfo(filePath);
var stream = fileInput.OpenRead();
@@ -192,7 +192,7 @@ public void ThrowsExceptionWhenUrlsInCollectionAreMissingFromSourceDocument()
public void ContinueProcessingWhenUrlsInCollectionAreMissingFromSourceDocument()
{
// Arrange
- var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "postmanCollection_ver4.json");
+ var filePath = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "postmanCollection_ver4.json");
var fileInput = new FileInfo(filePath);
var stream = fileInput.OpenRead();
@@ -225,14 +225,14 @@ public void ThrowsInvalidOperationExceptionInCreatePredicateWhenInvalidArguments
public async Task CopiesOverAllReferencedComponentsToTheSubsetDocumentCorrectly()
{
// Arrange
- var filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "docWithReusableHeadersAndExamples.yaml");
+ var filePath = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "docWithReusableHeadersAndExamples.yaml");
var operationIds = "getItems";
// Act
using var stream = File.OpenRead(filePath);
var settings = new OpenApiReaderSettings();
settings.AddYamlReader();
- var doc = (await OpenApiDocument.LoadAsync(stream, "yaml", settings)).Document;
+ var doc = (await OpenApiDocument.LoadAsync(stream, "yaml", settings, TestContext.Current.CancellationToken)).Document;
// validated the tags are read as references
var openApiOperationTags = doc?.Paths["/items"].Operations?[HttpMethod.Get].Tags?.ToArray();
@@ -278,7 +278,7 @@ public async Task CopiesOverAllReferencedComponentsToTheSubsetDocumentCorrectly(
}
};
subsetOpenApiDocument.SerializeAsV3(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
var result = outputStringWriter.ToString();
Assert.NotEmpty(result);
}
diff --git a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs
index 6342f6703..981a00558 100644
--- a/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs
+++ b/test/Microsoft.OpenApi.Hidi.Tests/Services/OpenApiServiceTests.cs
@@ -134,13 +134,13 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagramAsync
// create a dummy ILogger instance for testing
var options = new HidiOptions
{
- OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"),
- Output = new("sample.md")
+ OpenApi = Path.Join("UtilityFiles", "SampleOpenApi.yml"),
+ Output = new($"{nameof(ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagramAsync)}.md")
};
- await OpenApiService.ShowOpenApiDocumentAsync(options, _logger);
+ await OpenApiService.ShowOpenApiDocumentAsync(options, _logger, TestContext.Current.CancellationToken);
- var output = await File.ReadAllTextAsync(options.Output.FullName);
+ var output = await File.ReadAllTextAsync(options.Output.FullName, TestContext.Current.CancellationToken);
Assert.Contains("graph LR", output, StringComparison.Ordinal);
}
@@ -149,9 +149,9 @@ public async Task ShowCommandGeneratesMermaidHtmlFileWithMermaidDiagramAsync()
{
var options = new HidiOptions
{
- OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml")
+ OpenApi = Path.Join("UtilityFiles", "SampleOpenApi.yml")
};
- var filePath = await OpenApiService.ShowOpenApiDocumentAsync(options, _logger);
+ var filePath = await OpenApiService.ShowOpenApiDocumentAsync(options, _logger, TestContext.Current.CancellationToken);
Assert.True(File.Exists(filePath));
}
@@ -159,28 +159,28 @@ public async Task ShowCommandGeneratesMermaidHtmlFileWithMermaidDiagramAsync()
public Task ThrowIfOpenApiUrlIsNotProvidedWhenValidatingAsync()
{
return Assert.ThrowsAsync(() =>
- OpenApiService.ValidateOpenApiDocumentAsync("", _logger));
+ OpenApiService.ValidateOpenApiDocumentAsync("", _logger, TestContext.Current.CancellationToken));
}
[Fact]
public Task ThrowIfURLIsNotResolvableWhenValidatingAsync()
{
return Assert.ThrowsAsync(() =>
- OpenApiService.ValidateOpenApiDocumentAsync("https://example.org926F4F21-88E7-4DC5-BF88-6C529BB77844/itdoesnmatter", _logger));
+ OpenApiService.ValidateOpenApiDocumentAsync("https://example.org926F4F21-88E7-4DC5-BF88-6C529BB77844/itdoesnmatter", _logger, TestContext.Current.CancellationToken));
}
[Fact]
public Task ThrowIfFileDoesNotExistWhenValidatingAsync()
{
return Assert.ThrowsAsync(() =>
- OpenApiService.ValidateOpenApiDocumentAsync("aFileThatBetterNotExist.fake", _logger));
+ OpenApiService.ValidateOpenApiDocumentAsync("aFileThatBetterNotExist.fake", _logger, TestContext.Current.CancellationToken));
}
[Fact]
public async Task ValidateCommandProcessesOpenApiAsync()
{
// create a dummy ILogger instance for testing
- await OpenApiService.ValidateOpenApiDocumentAsync(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger);
+ await OpenApiService.ValidateOpenApiDocumentAsync(Path.Join("UtilityFiles", "SampleOpenApi.yml"), _logger, TestContext.Current.CancellationToken);
Assert.True(true);
}
@@ -188,7 +188,7 @@ public async Task ValidateCommandProcessesOpenApiAsync()
[Fact]
public async Task ValidFileReturnsTrueAsync()
{
- var isValid = await OpenApiService.ValidateOpenApiDocumentAsync(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger);
+ var isValid = await OpenApiService.ValidateOpenApiDocumentAsync(Path.Join("UtilityFiles", "SampleOpenApi.yml"), _logger, TestContext.Current.CancellationToken);
Assert.True(isValid);
}
@@ -196,7 +196,7 @@ public async Task ValidFileReturnsTrueAsync()
[Fact]
public async Task InvalidFileReturnsFalseAsync()
{
- var isValid = await OpenApiService.ValidateOpenApiDocumentAsync(Path.Combine("UtilityFiles", "InvalidSampleOpenApi.yml"), _logger);
+ var isValid = await OpenApiService.ValidateOpenApiDocumentAsync(Path.Join("UtilityFiles", "InvalidSampleOpenApi.yml"), _logger, TestContext.Current.CancellationToken);
Assert.False(isValid);
}
@@ -206,7 +206,7 @@ public async Task CancellingValidationReturnsNullAsync()
{
using var cts = new CancellationTokenSource();
await cts.CancelAsync();
- var isValid = await OpenApiService.ValidateOpenApiDocumentAsync(Path.Combine("UtilityFiles", "SampleOpenApi.yml"), _logger, cts.Token);
+ var isValid = await OpenApiService.ValidateOpenApiDocumentAsync(Path.Join("UtilityFiles", "SampleOpenApi.yml"), _logger, cts.Token);
Assert.Null(isValid);
}
@@ -216,17 +216,17 @@ public async Task TransformCommandConvertsOpenApiAsync()
{
var options = new HidiOptions
{
- OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"),
- Output = new("sample.json"),
+ OpenApi = Path.Join("UtilityFiles", "SampleOpenApi.yml"),
+ Output = new($"{nameof(TransformCommandConvertsOpenApiAsync)}.json"),
CleanOutput = true,
TerseOutput = false,
InlineLocal = false,
InlineExternal = false,
};
// create a dummy ILogger instance for testing
- await OpenApiService.TransformOpenApiDocumentAsync(options, _logger);
+ await OpenApiService.TransformOpenApiDocumentAsync(options, _logger, TestContext.Current.CancellationToken);
- var output = await File.ReadAllTextAsync("sample.json");
+ var output = await File.ReadAllTextAsync(options.Output.FullName, TestContext.Current.CancellationToken);
Assert.NotEmpty(output);
}
@@ -236,16 +236,17 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAsync()
{
var options = new HidiOptions
{
- OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"),
+ OpenApi = Path.Join("UtilityFiles", "SampleOpenApi.yml"),
CleanOutput = true,
TerseOutput = false,
InlineLocal = false,
InlineExternal = false,
+ Output = new FileInfo($"{nameof(TransformCommandConvertsOpenApiWithDefaultOutputNameAsync)}.yml")
};
// create a dummy ILogger instance for testing
- await OpenApiService.TransformOpenApiDocumentAsync(options, _logger);
+ await OpenApiService.TransformOpenApiDocumentAsync(options, _logger, TestContext.Current.CancellationToken);
- var output = await File.ReadAllTextAsync("output.yml");
+ var output = await File.ReadAllTextAsync(options.Output.FullName, TestContext.Current.CancellationToken);
Assert.NotEmpty(output);
}
@@ -254,7 +255,8 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchF
{
var options = new HidiOptions
{
- OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"),
+ OpenApi = Path.Join("UtilityFiles", "SampleOpenApi.yml"),
+ Output = new($"{nameof(TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchFormatAsync)}.yml"),
CleanOutput = true,
Version = "3.0",
OpenApiFormat = OpenApiConstants.Yaml,
@@ -263,9 +265,9 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchF
InlineExternal = false,
};
// create a dummy ILogger instance for testing
- await OpenApiService.TransformOpenApiDocumentAsync(options, _logger);
+ await OpenApiService.TransformOpenApiDocumentAsync(options, _logger, TestContext.Current.CancellationToken);
- var output = await File.ReadAllTextAsync("output.yml");
+ var output = await File.ReadAllTextAsync(options.Output.FullName, TestContext.Current.CancellationToken);
Assert.NotEmpty(output);
}
@@ -280,16 +282,17 @@ public Task ThrowTransformCommandIfOpenApiAndCsdlAreEmptyAsync()
InlineExternal = false,
};
return Assert.ThrowsAsync(() =>
- OpenApiService.TransformOpenApiDocumentAsync(options, _logger));
+ OpenApiService.TransformOpenApiDocumentAsync(options, _logger, TestContext.Current.CancellationToken));
}
[Fact]
public async Task TransformToPowerShellCompliantOpenApiAsync()
{
- var settingsPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "examplepowershellsettings.json");
+ var settingsPath = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "UtilityFiles", "examplepowershellsettings.json");
var options = new HidiOptions
{
- OpenApi = Path.Combine("UtilityFiles", "SampleOpenApi.yml"),
+ OpenApi = Path.Join("UtilityFiles", "SampleOpenApi.yml"),
+ Output = new($"{nameof(TransformToPowerShellCompliantOpenApiAsync)}.yaml"),
CleanOutput = true,
Version = "3.0",
OpenApiFormat = OpenApiConstants.Yaml,
@@ -299,9 +302,9 @@ public async Task TransformToPowerShellCompliantOpenApiAsync()
SettingsConfig = SettingsUtilities.GetConfiguration(settingsPath)
};
// create a dummy ILogger instance for testing
- await OpenApiService.TransformOpenApiDocumentAsync(options, _logger);
+ await OpenApiService.TransformOpenApiDocumentAsync(options, _logger, TestContext.Current.CancellationToken);
- var output = await File.ReadAllTextAsync("output.yaml");
+ var output = await File.ReadAllTextAsync(options.Output.FullName, TestContext.Current.CancellationToken);
Assert.NotEmpty(output);
}
@@ -309,14 +312,15 @@ public async Task TransformToPowerShellCompliantOpenApiAsync()
public async Task InvokeTransformCommandAsync()
{
var rootCommand = Program.CreateRootCommand();
- var openapi = Path.Combine(".", "UtilityFiles", "SampleOpenApi.yml");
- var args = new[] { "transform", "-d", openapi, "-o", "sample.json", "--co" };
+ var openapi = Path.Join(".", "UtilityFiles", "SampleOpenApi.yml");
+ var outputPath = $"{nameof(InvokeTransformCommandAsync)}.json";
+ var args = new[] { "transform", "-d", openapi, "-o", outputPath, "--co" };
var parseResult = rootCommand.Parse(args);
var handler = Assert.IsType(rootCommand.Subcommands.First(c => c.Name == "transform").Action, exactMatch: false);
- await handler.InvokeAsync(parseResult);
+ await handler.InvokeAsync(parseResult, TestContext.Current.CancellationToken);
- var output = await File.ReadAllTextAsync("sample.json");
+ var output = await File.ReadAllTextAsync(outputPath, TestContext.Current.CancellationToken);
Assert.NotEmpty(output);
}
@@ -325,14 +329,15 @@ public async Task InvokeTransformCommandAsync()
public async Task InvokeShowCommandAsync()
{
var rootCommand = Program.CreateRootCommand();
- var openApi = Path.Combine(".", "UtilityFiles", "SampleOpenApi.yml");
- var args = new[] { "show", "-d", openApi, "-o", "sample.md" };
+ var openApi = Path.Join(".", "UtilityFiles", "SampleOpenApi.yml");
+ var outputPath = $"{nameof(InvokeShowCommandAsync)}.md";
+ var args = new[] { "show", "-d", openApi, "-o", outputPath };
var parseResult = rootCommand.Parse(args);
var handler = Assert.IsType(rootCommand.Subcommands.First(c => c.Name == "show").Action, exactMatch: false);
- await handler.InvokeAsync(parseResult);
+ await handler.InvokeAsync(parseResult, TestContext.Current.CancellationToken);
- var output = await File.ReadAllTextAsync("sample.md");
+ var output = await File.ReadAllTextAsync(outputPath, TestContext.Current.CancellationToken);
Assert.Contains("graph LR", output, StringComparison.Ordinal);
}
@@ -340,14 +345,15 @@ public async Task InvokeShowCommandAsync()
public async Task InvokePluginCommandAsync()
{
var rootCommand = Program.CreateRootCommand();
- var manifest = Path.Combine(".", "UtilityFiles", "exampleapimanifest.json");
- var args = new[] { "plugin", "-m", manifest, "--of", AppDomain.CurrentDomain.BaseDirectory };
+ var manifest = Path.Join(".", "UtilityFiles", "exampleapimanifest.json");
+ var outputPath = Path.Join(AppDomain.CurrentDomain.BaseDirectory, nameof(InvokePluginCommandAsync));
+ var args = new[] { "plugin", "-m", manifest, "--of", outputPath };
var parseResult = rootCommand.Parse(args);
var handler = Assert.IsType(rootCommand.Subcommands.First(c => c.Name == "plugin").Action, exactMatch: false);
- await handler.InvokeAsync(parseResult);
+ await handler.InvokeAsync(parseResult, TestContext.Current.CancellationToken);
- using var jsDoc = JsonDocument.Parse(await File.ReadAllTextAsync("ai-plugin.json"));
+ using var jsDoc = JsonDocument.Parse(await File.ReadAllTextAsync(Path.Join(outputPath, "ai-plugin.json"), TestContext.Current.CancellationToken));
var openAiManifest = OpenAIPluginManifest.Load(jsDoc.RootElement);
Assert.NotNull(openAiManifest);
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 2f931c53e..d640c144b 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
+++ b/test/Microsoft.OpenApi.Readers.Tests/Microsoft.OpenApi.Readers.Tests.csproj
@@ -19,7 +19,7 @@
-
+
diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs
index 86adcdd5b..bb631927b 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiDiagnosticTests.cs
@@ -16,7 +16,7 @@ public class OpenApiDiagnosticTests
[Fact]
public async Task DetectedSpecificationVersionShouldBeV2_0()
{
- var actual = await OpenApiDocument.LoadAsync("V2Tests/Samples/basic.v2.yaml", SettingsFixture.ReaderSettings);
+ var actual = await OpenApiDocument.LoadAsync("V2Tests/Samples/basic.v2.yaml", SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
Assert.NotNull(actual.Diagnostic);
Assert.Equal(OpenApiSpecVersion.OpenApi2_0, actual.Diagnostic.SpecificationVersion);
@@ -25,7 +25,7 @@ public async Task DetectedSpecificationVersionShouldBeV2_0()
[Fact]
public async Task DetectedSpecificationVersionShouldBeV3_0()
{
- var actual = await OpenApiDocument.LoadAsync("V3Tests/Samples/OpenApiDocument/minimalDocument.yaml", SettingsFixture.ReaderSettings);
+ var actual = await OpenApiDocument.LoadAsync("V3Tests/Samples/OpenApiDocument/minimalDocument.yaml", SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
Assert.NotNull(actual.Diagnostic);
Assert.Equal(OpenApiSpecVersion.OpenApi3_0, actual.Diagnostic.SpecificationVersion);
@@ -44,7 +44,7 @@ public async Task DiagnosticReportMergedForExternalReferenceAsync()
settings.AddYamlReader();
ReadResult result;
- result = await OpenApiDocument.LoadAsync("OpenApiReaderTests/Samples/OpenApiDiagnosticReportMerged/TodoMain.yaml", settings);
+ result = await OpenApiDocument.LoadAsync("OpenApiReaderTests/Samples/OpenApiDiagnosticReportMerged/TodoMain.yaml", settings, token: TestContext.Current.CancellationToken);
Assert.NotNull(result);
Assert.NotNull(result.Document.Workspace);
diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs
index d2da0d7a4..61fc12e5b 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/OpenApiStreamReaderTests.cs
@@ -17,10 +17,10 @@ public class OpenApiStreamReaderTests
[Fact]
public async Task StreamShouldCloseIfLeaveStreamOpenSettingEqualsFalse()
{
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "petStore.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "petStore.yaml"));
var settings = new OpenApiReaderSettings { LeaveStreamOpen = false };
settings.AddYamlReader();
- (_, var diagnostic) = await OpenApiDocument.LoadAsync(stream, settings: settings);
+ (_, var diagnostic) = await OpenApiDocument.LoadAsync(stream, settings: settings, cancellationToken: TestContext.Current.CancellationToken);
Assert.False(stream.CanRead);
Assert.Equal(OpenApiConstants.Yaml, diagnostic.Format);
}
@@ -28,10 +28,10 @@ public async Task StreamShouldCloseIfLeaveStreamOpenSettingEqualsFalse()
[Fact]
public async Task StreamShouldNotCloseIfLeaveStreamOpenSettingEqualsTrue()
{
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "petStore.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "petStore.yaml"));
var settings = new OpenApiReaderSettings { LeaveStreamOpen = true };
settings.AddYamlReader();
- _ = await OpenApiDocument.LoadAsync(stream, settings: settings);
+ _ = await OpenApiDocument.LoadAsync(stream, settings: settings, cancellationToken: TestContext.Current.CancellationToken);
Assert.True(stream.CanRead);
}
@@ -39,15 +39,15 @@ public async Task StreamShouldNotCloseIfLeaveStreamOpenSettingEqualsTrue()
public async Task StreamShouldNotBeDisposedIfLeaveStreamOpenSettingIsTrueAsync()
{
var memoryStream = new MemoryStream();
- using var fileStream = Resources.GetStream(Path.Combine(SampleFolderPath, "petStore.yaml"));
+ using var fileStream = Resources.GetStream(Path.Join(SampleFolderPath, "petStore.yaml"));
- await fileStream.CopyToAsync(memoryStream);
+ await fileStream.CopyToAsync(memoryStream, TestContext.Current.CancellationToken);
memoryStream.Position = 0;
var stream = memoryStream;
var settings = new OpenApiReaderSettings { LeaveStreamOpen = true };
settings.AddYamlReader();
- _ = await OpenApiDocument.LoadAsync(stream, settings: settings);
+ _ = await OpenApiDocument.LoadAsync(stream, settings: settings, cancellationToken: TestContext.Current.CancellationToken);
stream.Seek(0, SeekOrigin.Begin); // does not throw an object disposed exception
Assert.True(stream.CanRead);
}
@@ -60,12 +60,12 @@ public async Task StreamShouldReadWhenInitializedAsync()
BaseAddress = new Uri("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/")
};
- var stream = await httpClient.GetStreamAsync("20fe7a7b720a0e48e5842d002ac418b12a8201df/tests/v3.0/pass/petstore.yaml");
+ var stream = await httpClient.GetStreamAsync("20fe7a7b720a0e48e5842d002ac418b12a8201df/tests/v3.0/pass/petstore.yaml", TestContext.Current.CancellationToken);
// Read V3 as YAML
var settings = new OpenApiReaderSettings();
settings.AddYamlReader();
- var result = await OpenApiDocument.LoadAsync(stream, settings: settings);
+ var result = await OpenApiDocument.LoadAsync(stream, settings: settings, cancellationToken: TestContext.Current.CancellationToken);
Assert.NotNull(result.Document);
}
}
diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/UnsupportedSpecVersionTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/UnsupportedSpecVersionTests.cs
index 6c66b9d00..e695c25a4 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/UnsupportedSpecVersionTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiReaderTests/UnsupportedSpecVersionTests.cs
@@ -14,7 +14,7 @@ public async Task ThrowOpenApiUnsupportedSpecVersionException()
{
try
{
- _ = await OpenApiDocument.LoadAsync("OpenApiReaderTests/Samples/unsupported.v1.yaml", SettingsFixture.ReaderSettings);
+ _ = await OpenApiDocument.LoadAsync("OpenApiReaderTests/Samples/unsupported.v1.yaml", SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
}
catch (OpenApiUnsupportedSpecVersionException exception)
{
diff --git a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs
index 6d5530e3a..34f4f2d45 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/OpenApiWorkspaceTests/OpenApiWorkspaceStreamTests.cs
@@ -35,10 +35,10 @@ public async Task LoadingDocumentWithResolveAllReferencesShouldLoadDocumentIntoW
""";
var wr = new StreamWriter(stream);
await wr.WriteAsync(doc);
- await wr.FlushAsync();
+ await wr.FlushAsync(TestContext.Current.CancellationToken);
stream.Position = 0;
- var result = await OpenApiDocument.LoadAsync(stream, OpenApiConstants.Yaml, settings: settings);
+ var result = await OpenApiDocument.LoadAsync(stream, OpenApiConstants.Yaml, settings: settings, cancellationToken: TestContext.Current.CancellationToken);
Assert.NotNull(result.Document.Workspace);
}
@@ -56,7 +56,7 @@ public async Task LoadDocumentWithExternalReferenceShouldLoadBothDocumentsIntoWo
settings.AddYamlReader();
ReadResult result;
- result = await OpenApiDocument.LoadAsync("V3Tests/Samples/OpenApiWorkspace/TodoMain.yaml", settings);
+ result = await OpenApiDocument.LoadAsync("V3Tests/Samples/OpenApiWorkspace/TodoMain.yaml", settings, token: TestContext.Current.CancellationToken);
var externalDocBaseUri = result.Document.Workspace.GetDocumentId("./TodoComponents.yaml");
var schemasPath = "#/components/schemas/";
@@ -82,14 +82,14 @@ public async Task LoadDocumentWithExternalReferencesInSubDirectories()
settings.AddYamlReader();
// Act
- var result = await OpenApiDocument.LoadAsync($"{sampleFolderPath}/Root.yaml", settings);
+ var result = await OpenApiDocument.LoadAsync($"{sampleFolderPath}/Root.yaml", settings, token: TestContext.Current.CancellationToken);
var document = result.Document;
var workspace = result.Document.Workspace;
// Assert
- Assert.True(workspace.Contains($"{Path.Combine(referenceBaseUri, "Directory", "PetsPage.yaml")}#/components/schemas/PetsPage"));
- Assert.True(workspace.Contains($"{Path.Combine(referenceBaseUri, "Directory", "Pets.yaml")}#/components/schemas/Pets"));
- Assert.True(workspace.Contains($"{Path.Combine(referenceBaseUri, "Directory", "Pets.yaml")}#/components/schemas/Pet"));
+ Assert.True(workspace.Contains($"{Path.Join(referenceBaseUri, "Directory", "PetsPage.yaml")}#/components/schemas/PetsPage"));
+ Assert.True(workspace.Contains($"{Path.Join(referenceBaseUri, "Directory", "Pets.yaml")}#/components/schemas/Pets"));
+ Assert.True(workspace.Contains($"{Path.Join(referenceBaseUri, "Directory", "Pets.yaml")}#/components/schemas/Pet"));
var operationResponseSchema = document.Paths["/pets"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema;
Assert.IsType(operationResponseSchema);
diff --git a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs
index b20f72e9a..3bda5fb29 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/ReferenceService/TryLoadReferenceV2Tests.cs
@@ -16,7 +16,7 @@ public class TryLoadReferenceV2Tests
public async Task LoadParameterReference()
{
// Arrange
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "multipleReferences.v2.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "multipleReferences.v2.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var reference = new OpenApiParameterReference("skipParam", result.Document);
// Assert
@@ -41,7 +41,7 @@ public async Task LoadParameterReference()
[Fact]
public async Task LoadSecuritySchemeReference()
{
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "multipleReferences.v2.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "multipleReferences.v2.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var reference = new OpenApiSecuritySchemeReference("api_key_sample", result.Document);
@@ -59,7 +59,7 @@ public async Task LoadSecuritySchemeReference()
[Fact]
public async Task LoadResponseReference()
{
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "multipleReferences.v2.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "multipleReferences.v2.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var reference = new OpenApiResponseReference("NotFound", result.Document);
@@ -79,7 +79,7 @@ public async Task LoadResponseReference()
[Fact]
public async Task LoadResponseAndSchemaReference()
{
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "multipleReferences.v2.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "multipleReferences.v2.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var reference = new OpenApiResponseReference("GeneralError", result.Document);
var expected = new OpenApiResponse
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/ComparisonTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/ComparisonTests.cs
index 32b8a4475..7016965a3 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/ComparisonTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/ComparisonTests.cs
@@ -22,10 +22,10 @@ public async Task EquivalentV2AndV3DocumentsShouldProduceEquivalentObjects(strin
{
var settings = new OpenApiReaderSettings();
settings.AddYamlReader();
- using var streamV2 = Resources.GetStream(Path.Combine(SampleFolderPath, $"{fileName}.v2.yaml"));
- using var streamV3 = Resources.GetStream(Path.Combine(SampleFolderPath, $"{fileName}.v3.yaml"));
- var result1 = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, $"{fileName}.v2.yaml"), SettingsFixture.ReaderSettings);
- var result2 = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, $"{fileName}.v3.yaml"), SettingsFixture.ReaderSettings);
+ using var streamV2 = Resources.GetStream(Path.Join(SampleFolderPath, $"{fileName}.v2.yaml"));
+ using var streamV3 = Resources.GetStream(Path.Join(SampleFolderPath, $"{fileName}.v3.yaml"));
+ var result1 = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, $"{fileName}.v2.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
+ var result2 = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, $"{fileName}.v3.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
result2.Document.Should().BeEquivalentTo(result1.Document,
options => options.Excluding(x => x.Workspace).Excluding(y => y.BaseUri));
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs
index 36ecdc849..49b9e3b04 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiDocumentTests.cs
@@ -67,7 +67,7 @@ public void ParseDocumentWithDifferentCultureShouldSucceed(string culture)
[Fact]
public async Task ShouldParseProducesInAnyOrder()
{
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "twoResponses.json"));
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "twoResponses.json"), token: TestContext.Current.CancellationToken);
var okSchema = new OpenApiSchema
{
@@ -226,8 +226,8 @@ public async Task ShouldParseProducesInAnyOrder()
[Fact]
public async Task ShouldAssignSchemaToAllResponses()
{
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "multipleProduces.json"));
- var result = await OpenApiDocument.LoadAsync(stream, OpenApiConstants.Json);
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "multipleProduces.json"));
+ var result = await OpenApiDocument.LoadAsync(stream, OpenApiConstants.Json, cancellationToken: TestContext.Current.CancellationToken);
Assert.Equal(OpenApiSpecVersion.OpenApi2_0, result.Diagnostic.SpecificationVersion);
@@ -257,7 +257,7 @@ public async Task ShouldAssignSchemaToAllResponses()
public async Task ShouldAllowComponentsThatJustContainAReference()
{
// Act
- var actual = (await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "ComponentRootReference.json"))).Document;
+ var actual = (await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "ComponentRootReference.json"), token: TestContext.Current.CancellationToken)).Document;
var schema1 = actual.Components.Schemas["AllPets"];
var schema1Reference = Assert.IsType(schema1);
Assert.False(schema1Reference.UnresolvedReference);
@@ -279,7 +279,7 @@ public async Task ParseDocumentWithDefaultContentTypeSettingShouldSucceed()
};
settings.AddYamlReader();
- var actual = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "docWithEmptyProduces.yaml"), settings);
+ var actual = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "docWithEmptyProduces.yaml"), settings, token: TestContext.Current.CancellationToken);
var mediaType = actual.Document.Paths["/example"].Operations[HttpMethod.Get].Responses["200"].Content;
Assert.Contains("application/json", mediaType);
}
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs
index b35344a55..789047939 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiHeaderTests.cs
@@ -21,7 +21,7 @@ public void ParseHeaderWithDefaultShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "headerWithDefault.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "headerWithDefault.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -50,7 +50,7 @@ public void ParseHeaderWithEnumShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "headerWithEnum.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "headerWithEnum.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs
index 5e69f5da5..f2bf3fb22 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiOperationTests.cs
@@ -121,7 +121,7 @@ public void ParseBasicOperationShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicOperation.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "basicOperation.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -139,7 +139,7 @@ public async Task ParseBasicOperationTwiceShouldYieldSameObject()
// Arrange
JsonNode node;
using (var stream = new MemoryStream(
- Encoding.Default.GetBytes(await _basicOperation.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0))))
+ Encoding.Default.GetBytes(await _basicOperation.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0, TestContext.Current.CancellationToken))))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -156,7 +156,7 @@ public void ParseOperationWithBodyShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "operationWithBody.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "operationWithBody.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -174,7 +174,7 @@ public async Task ParseOperationWithBodyTwiceShouldYieldSameObject()
// Arrange
JsonNode node;
using (var stream = new MemoryStream(
- Encoding.Default.GetBytes(await _operationWithBody.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0))))
+ Encoding.Default.GetBytes(await _operationWithBody.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0, TestContext.Current.CancellationToken))))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -191,7 +191,7 @@ public void ParseOperationWithResponseExamplesShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "operationWithResponseExamples.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "operationWithResponseExamples.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -257,7 +257,7 @@ public void ParseOperationWithEmptyProducesArraySetsResponseSchemaIfExists()
{
// Arrange
JsonNode node;
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "operationWithEmptyProducesArrayInResponse.json"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "operationWithEmptyProducesArrayInResponse.json"));
node = TestHelper.CreateYamlJsonNode(stream);
// Act
@@ -293,7 +293,7 @@ public void ParseOperationWithBodyAndEmptyConsumesSetsRequestBodySchemaIfExists(
{
// Arrange
JsonNode node;
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "operationWithBodyAndEmptyConsumes.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "operationWithBodyAndEmptyConsumes.yaml"));
node = TestHelper.CreateYamlJsonNode(stream);
// Act
@@ -308,14 +308,14 @@ public async Task ParseV2ResponseWithExamplesExtensionWorks()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "opWithResponseExamplesExtension.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "opWithResponseExamplesExtension.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
// Act
var operation = OpenApiV2Deserializer.LoadOperation(node, new(), new ParsingContext(new()));
- var actual = await operation.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await operation.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
var expected = @"summary: Get all pets
@@ -358,14 +358,14 @@ public async Task LoadV3ExamplesInResponseAsExtensionsWorks()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "v3OperationWithResponseExamples.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "v3OperationWithResponseExamples.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
// Act
var operation = OpenApiV3Deserializer.LoadOperation(node, new(), new ParsingContext(new()));
- var actual = await operation.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0);
+ var actual = await operation.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0, TestContext.Current.CancellationToken);
// Assert
var expected = @"summary: Get all pets
@@ -408,14 +408,14 @@ public async Task LoadV2OperationWithBodyParameterExamplesWorks()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "opWithBodyParameterExamples.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "opWithBodyParameterExamples.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
// Act
var operation = OpenApiV2Deserializer.LoadOperation(node, new(), new ParsingContext(new()));
- var actual = await operation.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await operation.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
var expected = @"summary: Get all pets
@@ -459,14 +459,14 @@ public async Task LoadV3ExamplesInRequestBodyParameterAsExtensionsWorks()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "v3OperationWithBodyParameterExamples.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "v3OperationWithBodyParameterExamples.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
// Act
var operation = OpenApiV3Deserializer.LoadOperation(node, new(), new ParsingContext(new()));
- var actual = await operation.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0);
+ var actual = await operation.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0, TestContext.Current.CancellationToken);
// Assert
var expected = @"summary: Get all pets
@@ -551,7 +551,7 @@ public async Task SerializesBodyReferencesWorks()
}
});
- var actual = await openApiDocument.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi2_0);
+ var actual = await openApiDocument.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi2_0, TestContext.Current.CancellationToken);
var expected =
"""
{
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs
index 43eefc5c0..c4b8f81bf 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiParameterTests.cs
@@ -22,7 +22,7 @@ public void ParseBodyParameterShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "bodyParameter.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "bodyParameter.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -41,7 +41,7 @@ public void ParsePathParameterShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "pathParameter.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "pathParameter.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -70,7 +70,7 @@ public void ParseQueryParameterShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "queryParameter.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "queryParameter.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -105,7 +105,7 @@ public void ParseParameterWithNullLocationShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "parameterWithNullLocation.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "parameterWithNullLocation.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -134,7 +134,7 @@ public void ParseParameterWithNoLocationShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "parameterWithNoLocation.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "parameterWithNoLocation.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -163,7 +163,7 @@ public void ParseParameterWithNoSchemaShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "parameterWithNoSchema.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "parameterWithNoSchema.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -188,7 +188,7 @@ public void ParseParameterWithUnknownLocationShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "parameterWithUnknownLocation.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "parameterWithUnknownLocation.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -217,7 +217,7 @@ public void ParseParameterWithDefaultShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "parameterWithDefault.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "parameterWithDefault.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -247,7 +247,7 @@ public void ParseParameterWithEnumShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "parameterWithEnum.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "parameterWithEnum.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -290,7 +290,7 @@ public void ParseFormDataParameterShouldSucceed()
""format"": ""binary""
}";
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "formDataParameter.json")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "formDataParameter.json")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs
index d064d971a..26222eb7b 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiPathItemTests.cs
@@ -250,7 +250,7 @@ public class OpenApiPathItemTests
public void ParseBasicPathItemWithFormDataShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicPathItemWithFormData.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "basicPathItemWithFormData.yaml"));
var node = TestHelper.CreateYamlJsonNode(stream);
// Act
@@ -265,7 +265,7 @@ public void ParsePathItemWithFormDataPathParameterShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "pathItemWithFormDataPathParameter.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "pathItemWithFormDataPathParameter.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -284,7 +284,7 @@ public void ParsePathItemBodyDataPathParameterShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "pathItemWithBodyPathParameter.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "pathItemWithBodyPathParameter.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs
index 5afea3cb4..ee5e4a25f 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSchemaTests.cs
@@ -26,7 +26,7 @@ public void ParseSchemaWithDefaultShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "schemaWithDefault.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "schemaWithDefault.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -48,7 +48,7 @@ public void ParseSchemaWithExampleShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "schemaWithExample.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "schemaWithExample.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -71,7 +71,7 @@ public void ParseSchemaWithEnumShouldSucceed()
{
// Arrange
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "schemaWithEnum.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "schemaWithEnum.yaml")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
@@ -160,10 +160,10 @@ public async Task SerializeSchemaWithNullableShouldSucceed()
var expected = @"type: string
x-nullable: true";
- var path = Path.Combine(SampleFolderPath, "schemaWithNullableExtension.yaml");
+ var path = Path.Join(SampleFolderPath, "schemaWithNullableExtension.yaml");
// Act
- var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi2_0, new(), SettingsFixture.ReaderSettings);
+ var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi2_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var writer = new StringWriter();
schema.SerializeAsV2(new OpenApiYamlWriter(writer));
@@ -180,10 +180,10 @@ public async Task SerializeSchemaWithOnlyNullableShouldSucceed()
// Arrange
var expected = @"{ }";
- var path = Path.Combine(SampleFolderPath, "schemaWithOnlyNullableExtension.yaml");
+ var path = Path.Join(SampleFolderPath, "schemaWithOnlyNullableExtension.yaml");
// Act
- var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi2_0, new(), SettingsFixture.ReaderSettings);
+ var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi2_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var writer = new StringWriter();
schema.SerializeAsV2(new OpenApiYamlWriter(writer));
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs
index e108774f1..9826d90ea 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V2Tests/OpenApiSecuritySchemeTests.cs
@@ -21,7 +21,7 @@ public class OpenApiSecuritySchemeTests
public void ParseHttpSecuritySchemeShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicSecurityScheme.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "basicSecurityScheme.yaml"));
var document = LoadYamlDocument(stream);
var diagnostic = new OpenApiDiagnostic();
@@ -46,7 +46,7 @@ public void ParseHttpSecuritySchemeShouldSucceed()
public void ParseApiKeySecuritySchemeShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "apiKeySecurityScheme.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "apiKeySecurityScheme.yaml"));
var document = LoadYamlDocument(stream);
var diagnostic = new OpenApiDiagnostic();
var context = new ParsingContext(diagnostic);
@@ -71,7 +71,7 @@ public void ParseApiKeySecuritySchemeShouldSucceed()
[Fact]
public void ParseOAuth2ImplicitSecuritySchemeShouldSucceed()
{
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "oauth2ImplicitSecurityScheme.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "oauth2ImplicitSecurityScheme.yaml"));
var document = LoadYamlDocument(stream);
var diagnostic = new OpenApiDiagnostic();
var context = new ParsingContext(diagnostic);
@@ -107,7 +107,7 @@ public void ParseOAuth2ImplicitSecuritySchemeShouldSucceed()
public void ParseOAuth2PasswordSecuritySchemeShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "oauth2PasswordSecurityScheme.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "oauth2PasswordSecurityScheme.yaml"));
var document = LoadYamlDocument(stream);
var diagnostic = new OpenApiDiagnostic();
var context = new ParsingContext(diagnostic);
@@ -142,7 +142,7 @@ public void ParseOAuth2PasswordSecuritySchemeShouldSucceed()
public void ParseOAuth2ApplicationSecuritySchemeShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "oauth2ApplicationSecurityScheme.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "oauth2ApplicationSecurityScheme.yaml"));
var document = LoadYamlDocument(stream);
var diagnostic = new OpenApiDiagnostic();
var context = new ParsingContext(diagnostic);
@@ -177,7 +177,7 @@ public void ParseOAuth2ApplicationSecuritySchemeShouldSucceed()
public void ParseOAuth2AccessCodeSecuritySchemeShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "oauth2AccessCodeSecurityScheme.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "oauth2AccessCodeSecurityScheme.yaml"));
var document = LoadYamlDocument(stream);
var diagnostic = new OpenApiDiagnostic();
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDiscriminatorTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDiscriminatorTests.cs
new file mode 100644
index 000000000..3c74061ef
--- /dev/null
+++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDiscriminatorTests.cs
@@ -0,0 +1,45 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT license.
+
+using System.Collections.Generic;
+using System.IO;
+using System.Threading.Tasks;
+using Microsoft.OpenApi.Reader;
+using Xunit;
+
+namespace Microsoft.OpenApi.Readers.Tests.V31Tests
+{
+ [Collection("DefaultSettings")]
+ public class OpenApiDiscriminatorTests
+ {
+ private const string SampleFolderPath = "V31Tests/Samples/OpenApiDiscriminator/";
+
+ [Fact]
+ public async Task ParseBasicDiscriminatorShouldSucceed()
+ {
+ // Arrange
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "basicDiscriminator.yaml"));
+ // Copy stream to MemoryStream
+ using var memoryStream = new MemoryStream();
+ await stream.CopyToAsync(memoryStream, TestContext.Current.CancellationToken);
+ memoryStream.Position = 0;
+
+ // Act
+ var openApiDocument = new OpenApiDocument();
+ var discriminator = OpenApiModelFactory.Load(memoryStream, OpenApiSpecVersion.OpenApi3_1, OpenApiConstants.Yaml, openApiDocument, out var diagnostic, SettingsFixture.ReaderSettings);
+
+ // Assert
+ Assert.Equivalent(
+ new OpenApiDiscriminator
+ {
+ PropertyName = "pet_type",
+ Mapping = new Dictionary
+ {
+ ["puppy"] = new OpenApiSchemaReference("Dog", openApiDocument),
+ ["kitten"] = new OpenApiSchemaReference("Cat" , openApiDocument, "https://gigantic-server.com/schemas/animals.json"),
+ ["monster"] = new OpenApiSchemaReference("monster" , openApiDocument, "https://gigantic-server.com/schemas/Monster/schema.json")
+ },
+ }, discriminator);
+ }
+ }
+}
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests.cs
index 0e2155de3..afb27144c 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests.cs
@@ -21,8 +21,8 @@ public class OpenApiDocumentSerializationTests
public async Task Serialize_DoesNotMutateDom(OpenApiSpecVersion version)
{
// Arrange
- var filePath = Path.Combine(SampleFolderPath, "docWith31properties.json");
- var (doc, _) = await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings);
+ var filePath = Path.Join(SampleFolderPath, "docWith31properties.json");
+ var (doc, _) = await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Act: Serialize using System.Text.Json
var options = new JsonSerializerOptions
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs
index c1905d6a6..60c6907ae 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentTests.cs
@@ -56,7 +56,7 @@ public void ParseDocumentWithMalformedReferenceShouldYieldExpectedDiagnostic()
public async Task ParseDocumentWithWebhooksShouldSucceed()
{
// Arrange and Act
- var actual = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "documentWithWebhooks.yaml"), SettingsFixture.ReaderSettings);
+ var actual = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "documentWithWebhooks.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var petSchema = new OpenApiSchemaReference("petSchema", actual.Document);
var newPetSchema = new OpenApiSchemaReference("newPetSchema", actual.Document);
@@ -251,7 +251,7 @@ public async Task ParseDocumentWithWebhooksShouldSucceed()
public async Task ParseDocumentsWithReusablePathItemInWebhooksSucceeds()
{
// Arrange && Act
- var actual = await OpenApiDocument.LoadAsync("V31Tests/Samples/OpenApiDocument/documentWithReusablePaths.yaml", SettingsFixture.ReaderSettings);
+ var actual = await OpenApiDocument.LoadAsync("V31Tests/Samples/OpenApiDocument/documentWithReusablePaths.yaml", SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var components = new OpenApiComponents
{
@@ -461,7 +461,7 @@ public async Task ParseDocumentWithExampleInSchemaShouldSucceed()
var writer = new OpenApiJsonWriter(outputStringWriter, new OpenApiJsonWriterSettings { Terse = false });
// Act
- var actual = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "docWithExample.yaml"), SettingsFixture.ReaderSettings);
+ var actual = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "docWithExample.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
actual.Document.SerializeAsV31(writer);
// Assert
@@ -472,7 +472,7 @@ public async Task ParseDocumentWithExampleInSchemaShouldSucceed()
public async Task ParseDocumentWithPatternPropertiesInSchemaWorks()
{
// Arrange and Act
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "docWithPatternPropertiesInSchema.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "docWithPatternPropertiesInSchema.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var actualSchema = result.Document.Paths["/example"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema;
var expectedSchema = new OpenApiSchema
@@ -518,7 +518,7 @@ public async Task ParseDocumentWithPatternPropertiesInSchemaWorks()
prop3:
type: string";
- var actualMediaType = await mediaType.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_1);
+ var actualMediaType = await mediaType.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_1, TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(expectedSchema, actualSchema);
@@ -529,7 +529,7 @@ public async Task ParseDocumentWithPatternPropertiesInSchemaWorks()
public async Task ParseDocumentWithReferenceByIdGetsResolved()
{
// Arrange and Act
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "docWithReferenceById.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "docWithReferenceById.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var responseSchema = result.Document.Paths["/resource"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema;
var requestBodySchema = result.Document.Paths["/resource"].Operations[HttpMethod.Post].RequestBody.Content["application/json"].Schema;
@@ -546,7 +546,7 @@ public async Task ExternalDocumentDereferenceToOpenApiDocumentUsingJsonPointerWo
{
// Arrange
var documentName = "externalRefByJsonPointer.yaml";
- var path = Path.Combine(Directory.GetCurrentDirectory(), SampleFolderPath, documentName);
+ var path = Path.Join(Directory.GetCurrentDirectory(), SampleFolderPath, documentName);
var settings = new OpenApiReaderSettings
{
@@ -556,13 +556,13 @@ public async Task ExternalDocumentDereferenceToOpenApiDocumentUsingJsonPointerWo
settings.AddYamlReader();
// Act
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, documentName), settings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, documentName), settings, token: TestContext.Current.CancellationToken);
var responseSchema = result.Document.Paths["/resource"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema;
// Assert
var externalResourceUri = new Uri(
"file://" +
- Path.Combine(Path.GetFullPath(SampleFolderPath),
+ Path.Join(Path.GetFullPath(SampleFolderPath),
"externalResource.yaml#/components/schemas/todo")).AbsoluteUri;
Assert.True(result.Document.Workspace.Contains(externalResourceUri));
@@ -573,7 +573,7 @@ public async Task ExternalDocumentDereferenceToOpenApiDocumentUsingJsonPointerWo
public async Task ParseExternalDocumentDereferenceToOpenApiDocumentByIdWorks()
{
// Arrange
- var path = Path.Combine(Directory.GetCurrentDirectory(), SampleFolderPath);
+ var path = Path.Join(Directory.GetCurrentDirectory(), SampleFolderPath);
var settings = new OpenApiReaderSettings
{
@@ -583,8 +583,8 @@ public async Task ParseExternalDocumentDereferenceToOpenApiDocumentByIdWorks()
settings.AddYamlReader();
// Act
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "externalRefById.yaml"), settings);
- var doc2 = (await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "externalResource.yaml"), SettingsFixture.ReaderSettings)).Document;
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "externalRefById.yaml"), settings, token: TestContext.Current.CancellationToken);
+ var doc2 = (await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "externalResource.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;
var requestBodySchema = result.Document.Paths["/resource"].Operations[HttpMethod.Get].Parameters[0].Schema;
result.Document.Workspace.RegisterComponents(doc2);
@@ -596,8 +596,8 @@ public async Task ParseExternalDocumentDereferenceToOpenApiDocumentByIdWorks()
[Fact]
public async Task ParseDocumentWith31PropertiesWorks()
{
- var path = Path.Combine(SampleFolderPath, "documentWith31Properties.yaml");
- var doc = (await OpenApiDocument.LoadAsync(path, SettingsFixture.ReaderSettings)).Document;
+ var path = Path.Join(SampleFolderPath, "documentWith31Properties.yaml");
+ var doc = (await OpenApiDocument.LoadAsync(path, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;
var outputStringWriter = new StringWriter();
doc.SerializeAsV31(new OpenApiYamlWriter(outputStringWriter));
await outputStringWriter.FlushAsync();
@@ -610,16 +610,16 @@ public async Task ParseDocumentWith31PropertiesWorks()
[Fact]
public async Task ParseDocumentWithEmptyTagsWorks()
{
- var path = Path.Combine(SampleFolderPath, "documentWithEmptyTags.json");
- var doc = (await OpenApiDocument.LoadAsync(path, SettingsFixture.ReaderSettings)).Document;
+ var path = Path.Join(SampleFolderPath, "documentWithEmptyTags.json");
+ var doc = (await OpenApiDocument.LoadAsync(path, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;
doc.Paths["/groups"].Operations[HttpMethod.Get].Tags.Should().BeNull("Empty tags are ignored, so we should not have any tags");
}
[Fact]
public async Task DocumentWithSchemaResultsInWarning()
{
- var path = Path.Combine(SampleFolderPath, "documentWithSchema.json");
- var (doc, diag) = await OpenApiDocument.LoadAsync(path, SettingsFixture.ReaderSettings);
+ var path = Path.Join(SampleFolderPath, "documentWithSchema.json");
+ var (doc, diag) = await OpenApiDocument.LoadAsync(path, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
Assert.NotNull(doc);
Assert.NotNull(diag);
Assert.Empty(diag.Errors);
@@ -637,8 +637,8 @@ public void ParseEmptyMemoryStreamThrowsAnArgumentException()
public async Task ValidateReferencedExampleInSchemaWorks()
{
// Arrange && Act
- var path = Path.Combine(SampleFolderPath, "docWithReferencedExampleInSchemaWorks.yaml");
- var result = await OpenApiDocument.LoadAsync(path, SettingsFixture.ReaderSettings);
+ var path = Path.Join(SampleFolderPath, "docWithReferencedExampleInSchemaWorks.yaml");
+ var result = await OpenApiDocument.LoadAsync(path, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var actualSchemaExample = result.Document.Components.Schemas["DiffCreatedEvent"].Properties["updatedAt"].Example;
var targetSchemaExample = result.Document.Components.Schemas["Timestamp"].Example;
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDynamicRefTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDynamicRefTests.cs
index 49921034c..a862c971b 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDynamicRefTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDynamicRefTests.cs
@@ -626,8 +626,8 @@ public async Task AbsoluteDynamicRefResolvesAcrossDocuments()
using var streamA = new MemoryStream(Encoding.UTF8.GetBytes(yamlA));
using var streamB = new MemoryStream(Encoding.UTF8.GetBytes(yamlB));
- var resultA = await OpenApiDocument.LoadAsync(streamA, "yaml", SettingsFixture.ReaderSettings);
- var resultB = await OpenApiDocument.LoadAsync(streamB, "yaml", SettingsFixture.ReaderSettings);
+ var resultA = await OpenApiDocument.LoadAsync(streamA, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
+ var resultB = await OpenApiDocument.LoadAsync(streamB, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
var docA = resultA.Document;
var docB = resultB.Document;
@@ -1485,8 +1485,8 @@ public async Task ExternalDynamicRefResolvesToPlainAnchorInExternalDocument()
using var streamA = new MemoryStream(Encoding.UTF8.GetBytes(yamlA));
using var streamB = new MemoryStream(Encoding.UTF8.GetBytes(yamlB));
- var resultA = await OpenApiDocument.LoadAsync(streamA, "yaml", SettingsFixture.ReaderSettings);
- var resultB = await OpenApiDocument.LoadAsync(streamB, "yaml", SettingsFixture.ReaderSettings);
+ var resultA = await OpenApiDocument.LoadAsync(streamA, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
+ var resultB = await OpenApiDocument.LoadAsync(streamB, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
var docA = resultA.Document;
var docB = resultB.Document;
@@ -1545,8 +1545,8 @@ public async Task ExternalDynamicRefWithRelativeUriResolvesAcrossDocuments()
using var streamA = new MemoryStream(Encoding.UTF8.GetBytes(yamlA));
using var streamB = new MemoryStream(Encoding.UTF8.GetBytes(yamlB));
- var resultA = await OpenApiDocument.LoadAsync(streamA, "yaml", SettingsFixture.ReaderSettings);
- var resultB = await OpenApiDocument.LoadAsync(streamB, "yaml", SettingsFixture.ReaderSettings);
+ var resultA = await OpenApiDocument.LoadAsync(streamA, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
+ var resultB = await OpenApiDocument.LoadAsync(streamB, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
var docA = resultA.Document;
var docB = resultB.Document;
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiEncodingTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiEncodingTests.cs
index 6a03ea015..9ec9f9199 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiEncodingTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiEncodingTests.cs
@@ -17,7 +17,7 @@ public class OpenApiEncodingTests
public async Task ParseEncodingWithAllowReservedShouldSucceed()
{
// Act
- var encoding = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "encodingWithAllowReserved.yaml"), OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings);
+ var encoding = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "encodingWithAllowReserved.yaml"), OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiHeaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiHeaderTests.cs
index 60ec248a0..19cf48714 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiHeaderTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiHeaderTests.cs
@@ -19,10 +19,10 @@ public class OpenApiHeaderTests
public async Task ParseBasicHeaderShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicHeader.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "basicHeader.yaml"));
// Act
- var header = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_1, new(), settings: SettingsFixture.ReaderSettings);
+ var header = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_1, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -40,10 +40,10 @@ public async Task ParseBasicHeaderShouldSucceed()
public async Task ParseHeaderWithContentShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "headerWithContent.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "headerWithContent.yaml"));
// Act
- var header = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_1, new(), settings: SettingsFixture.ReaderSettings);
+ var header = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_1, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -79,10 +79,10 @@ public async Task ParseHeaderWithContentShouldSucceed()
public async Task ParseHeaderWithMultipleContentTypesShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "headerWithMultipleContentTypes.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "headerWithMultipleContentTypes.yaml"));
// Act
- var header = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_1, new(), settings: SettingsFixture.ReaderSettings);
+ var header = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_1, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -120,10 +120,10 @@ public async Task ParseHeaderWithMultipleContentTypesShouldSucceed()
public async Task ParseHeaderWithStyleAndContentShouldPreferContent()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "headerWithStyleAndContent.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "headerWithStyleAndContent.yaml"));
// Act
- var header = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_1, new(), settings: SettingsFixture.ReaderSettings);
+ var header = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_1, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
// Both content and style can be present, content takes precedence for serialization behavior
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiInfoTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiInfoTests.cs
index 1af2aca13..a1bcea365 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiInfoTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiInfoTests.cs
@@ -15,7 +15,7 @@ public class OpenApiInfoTests
[Fact]
public void ParseBasicInfoShouldSucceed()
{
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicInfo.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "basicInfo.yaml"));
var yamlStream = new YamlStream();
yamlStream.Load(new StreamReader(stream));
var yamlNode = yamlStream.Documents[0].RootNode;
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiLicenseTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiLicenseTests.cs
index 26d841811..33df2da48 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiLicenseTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiLicenseTests.cs
@@ -18,7 +18,7 @@ public class OpenApiLicenseTests
[Fact]
public void ParseLicenseWithSpdxIdentifierShouldSucceed()
{
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "licenseWithSpdxIdentifier.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "licenseWithSpdxIdentifier.yaml"));
var yamlStream = new YamlStream();
yamlStream.Load(new StreamReader(stream));
var yamlNode = yamlStream.Documents[0].RootNode;
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiMediaTypeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiMediaTypeTests.cs
index e469f8d53..c337a968f 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiMediaTypeTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiMediaTypeTests.cs
@@ -1,4 +1,4 @@
-using System.Text.Json.Nodes;
+using System.Text.Json.Nodes;
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
@@ -22,7 +22,7 @@ public class OpenApiMediaTypeTests
public async Task ParseMediaTypeWithExampleShouldSucceed()
{
// Act
- var mediaType = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "mediaTypeWithExample.yaml"), OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings);
+ var mediaType = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "mediaTypeWithExample.yaml"), OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
mediaType.Should().BeEquivalentTo(
@@ -43,7 +43,7 @@ public async Task ParseMediaTypeWithExampleShouldSucceed()
public async Task ParseMediaTypeWithExamplesShouldSucceed()
{
// Act
- var mediaType = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "mediaTypeWithExamples.yaml"), OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings);
+ var mediaType = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "mediaTypeWithExamples.yaml"), OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
mediaType.Should().BeEquivalentTo(
@@ -103,14 +103,14 @@ public async Task ParseMediaTypeWithEmptyArrayInExamplesWorks()
}
";
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "examplesWithEmptyArray.json")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "examplesWithEmptyArray.json")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
// Act
var mediaType = OpenApiV31Deserializer.LoadMediaType(node, new(), new ParsingContext(new()));
- var serialized = await mediaType.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_1);
+ var serialized = await mediaType.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_1, TestContext.Current.CancellationToken);
// Assert
Assert.Equal(expected.MakeLineBreaksEnvironmentNeutral(), serialized.MakeLineBreaksEnvironmentNeutral());
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs
index fe4c74ff5..8f86d8297 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs
@@ -25,7 +25,7 @@ public class OpenApiSchemaTests
public static MemoryStream GetMemoryStream(string fileName)
{
- var filePath = Path.Combine(SampleFolderPath, fileName);
+ var filePath = Path.Join(SampleFolderPath, fileName);
var fileBytes = File.ReadAllBytes(filePath);
return new MemoryStream(fileBytes);
}
@@ -108,7 +108,7 @@ public async Task ParseBasicV31SchemaShouldSucceed()
// Act
var schema = await OpenApiModelFactory.LoadAsync(
- Path.Combine(SampleFolderPath, "jsonSchema.json"), OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings);
+ Path.Join(SampleFolderPath, "jsonSchema.json"), OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(expectedObject, schema);
@@ -192,10 +192,10 @@ public void TestSchemaCopyConstructorWithTypeArrayWorks()
[Fact]
public async Task ParseV31SchemaShouldSucceed()
{
- var path = Path.Combine(SampleFolderPath, "schema.yaml");
+ var path = Path.Join(SampleFolderPath, "schema.yaml");
// Act
- var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings);
+ var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var expectedSchema = new OpenApiSchema
{
Type = JsonSchemaType.Object,
@@ -217,8 +217,8 @@ public async Task ParseV31SchemaShouldSucceed()
public async Task ParseAdvancedV31SchemaShouldSucceed()
{
// Arrange and Act
- var path = Path.Combine(SampleFolderPath, "advancedSchema.yaml");
- var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings);
+ var path = Path.Join(SampleFolderPath, "advancedSchema.yaml");
+ var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var expectedSchema = new OpenApiSchema
{
@@ -442,10 +442,10 @@ public async Task SerializeV31SchemaWithMultipleTypesAsV3Works()
var expected = @"type: string
nullable: true";
- var path = Path.Combine(SampleFolderPath, "schemaWithTypeArray.yaml");
+ var path = Path.Join(SampleFolderPath, "schemaWithTypeArray.yaml");
// Act
- var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings);
+ var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var writer = new StringWriter();
schema.SerializeAsV3(new OpenApiYamlWriter(writer));
@@ -461,10 +461,10 @@ public async Task SerializeV31SchemaWithMultipleTypesAsV2Works()
var expected = @"type: string
x-nullable: true";
- var path = Path.Combine(SampleFolderPath, "schemaWithTypeArray.yaml");
+ var path = Path.Join(SampleFolderPath, "schemaWithTypeArray.yaml");
// Act
- var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings);
+ var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var writer = new StringWriter();
schema.SerializeAsV2(new OpenApiYamlWriter(writer));
@@ -481,10 +481,10 @@ public async Task SerializeV3SchemaWithNullableAsV31Works()
- 'null'
- string";
- var path = Path.Combine(SampleFolderPath, "schemaWithNullable.yaml");
+ var path = Path.Join(SampleFolderPath, "schemaWithNullable.yaml");
// Act
- var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
+ var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var writer = new StringWriter();
schema.SerializeAsV31(new OpenApiYamlWriter(writer));
@@ -501,10 +501,10 @@ public async Task SerializeV2SchemaWithNullableExtensionAsV31Works()
- 'null'
- string";
- var path = Path.Combine(SampleFolderPath, "schemaWithNullableExtension.yaml");
+ var path = Path.Join(SampleFolderPath, "schemaWithNullableExtension.yaml");
// Act
- var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi2_0, new(), SettingsFixture.ReaderSettings);
+ var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi2_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var writer = new StringWriter();
schema.SerializeAsV31(new OpenApiYamlWriter(writer));
@@ -540,10 +540,10 @@ public async Task LoadSchemaWithNullableExtensionAsV31ShouldNotWork(string fileP
// "nullable" is only for 3.0.
// and "x-nullable" is only for 2.0.
// Arrange
- var path = Path.Combine(SampleFolderPath, filePath);
+ var path = Path.Join(SampleFolderPath, filePath);
// Act
- var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings);
+ var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equal(JsonSchemaType.String, schema.Type);
@@ -580,10 +580,10 @@ public async Task SerializeSchemaWithJsonSchemaKeywordsWorks()
$dynamicRef: '#addressDef'
description: Schema for a person object
";
- var path = Path.Combine(SampleFolderPath, "schemaWithJsonSchemaKeywords.yaml");
+ var path = Path.Join(SampleFolderPath, "schemaWithJsonSchemaKeywords.yaml");
// Act
- var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings);
+ var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// serialization
var writer = new StringWriter();
@@ -624,10 +624,10 @@ public async Task ParseSchemaWithConstWorks()
}
}";
- var path = Path.Combine(SampleFolderPath, "schemaWithConst.json");
+ var path = Path.Join(SampleFolderPath, "schemaWithConst.json");
// Act
- var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings);
+ var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
Assert.Equal("active", schema.Properties["status"].Const);
Assert.Equal("admin", schema.Properties["user"].Properties["role"].Const);
@@ -667,10 +667,10 @@ public async Task ParseSchemaWithConstNullWorks()
}
}";
- var path = Path.Combine(SampleFolderPath, "schemaWithConstNull.json");
+ var path = Path.Join(SampleFolderPath, "schemaWithConstNull.json");
// Act
- var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings);
+ var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_1, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var statusSchema = Assert.IsType(schema.Properties["status"]);
Assert.Null(statusSchema.Const);
@@ -1020,7 +1020,7 @@ public async Task ParseSchemaReferencePreservesJsonSchema2020KeywordSiblings()
// Act
using var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(yaml));
- var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
Assert.NotNull(result.Document.Components);
Assert.NotNull(result.Document.Components.Schemas);
var referencing = result.Document.Components.Schemas["Referencing"];
@@ -1062,14 +1062,14 @@ public async Task SerializeSchemaReferencePreservesJsonSchema2020KeywordSiblings
// Act — parse then serialize back
using var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(yaml));
- var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
var writer = new StringWriter();
result.Document.SerializeAsV31(new OpenApiYamlWriter(writer));
var output = writer.ToString();
// Assert — round-trip preserves $dynamicAnchor and $defs alongside $ref
using var roundTripStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(output));
- var roundTripResult = await OpenApiDocument.LoadAsync(roundTripStream, "yaml", SettingsFixture.ReaderSettings);
+ var roundTripResult = await OpenApiDocument.LoadAsync(roundTripStream, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
Assert.NotNull(roundTripResult.Document.Components);
Assert.NotNull(roundTripResult.Document.Components.Schemas);
var referencing = roundTripResult.Document.Components.Schemas["Referencing"];
@@ -1106,7 +1106,7 @@ public async Task ParseSchemaReferencePreservesScalarKeywordSiblings()
// Act
using var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(yaml));
- var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
Assert.NotNull(result.Document.Components);
Assert.NotNull(result.Document.Components.Schemas);
var referencing = result.Document.Components.Schemas["Referencing"];
@@ -1145,14 +1145,14 @@ public async Task SerializeSchemaReferencePreservesScalarKeywordSiblings()
// Act — parse then serialize back
using var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(yaml));
- var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
var writer = new StringWriter();
result.Document.SerializeAsV31(new OpenApiYamlWriter(writer));
var output = writer.ToString();
// Assert — round-trip preserves scalar siblings alongside $ref
using var roundTripStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(output));
- var roundTripResult = await OpenApiDocument.LoadAsync(roundTripStream, "yaml", SettingsFixture.ReaderSettings);
+ var roundTripResult = await OpenApiDocument.LoadAsync(roundTripStream, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
Assert.NotNull(roundTripResult.Document.Components);
Assert.NotNull(roundTripResult.Document.Components.Schemas);
var referencing = roundTripResult.Document.Components.Schemas["Referencing"];
@@ -1188,7 +1188,7 @@ public async Task ParseSchemaReferencePreservesVocabularySibling()
// Act
using var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(yaml));
- var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
Assert.NotNull(result.Document.Components);
Assert.NotNull(result.Document.Components.Schemas);
var referencing = result.Document.Components.Schemas["Referencing"];
@@ -1237,7 +1237,7 @@ public async Task ParseSchemaReferencePreservesDynamicAnchorInsideDefsInAllOf()
// Act
using var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(yaml));
- var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
Assert.NotNull(result.Document.Components);
Assert.NotNull(result.Document.Components.Schemas);
var assetPaged = result.Document.Components.Schemas["AssetPaged"];
@@ -1284,7 +1284,7 @@ public async Task EmptySiblingCollectionsFallThroughToTarget()
// Act
using var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(yaml));
- var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
Assert.NotNull(result.Document.Components);
Assert.NotNull(result.Document.Components.Schemas);
var referencing = result.Document.Components.Schemas["Referencing"];
@@ -1326,7 +1326,7 @@ public async Task SiblingsOnRefAreDroppedForOpenApi30()
// Act
using var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(yaml));
- var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
Assert.NotNull(result.Document.Components);
Assert.NotNull(result.Document.Components.Schemas);
var referencing = result.Document.Components.Schemas["Referencing"];
@@ -1360,14 +1360,14 @@ public async Task SerializeSchemaReferencePreservesVocabularySibling()
// Act — parse then serialize back
using var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(yaml));
- var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
var writer = new StringWriter();
result.Document.SerializeAsV31(new OpenApiYamlWriter(writer));
var output = writer.ToString();
// Assert — round-trip preserves $vocabulary alongside $ref
using var roundTripStream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(output));
- var roundTripResult = await OpenApiDocument.LoadAsync(roundTripStream, "yaml", SettingsFixture.ReaderSettings);
+ var roundTripResult = await OpenApiDocument.LoadAsync(roundTripStream, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
Assert.NotNull(roundTripResult.Document.Components);
Assert.NotNull(roundTripResult.Document.Components.Schemas);
var referencing = roundTripResult.Document.Components.Schemas["Referencing"];
@@ -1404,7 +1404,7 @@ public async Task CreateShallowCopyPreservesKeywordSiblings()
// Act
using var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(yaml));
- var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(stream, "yaml", SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
Assert.NotNull(result.Document.Components);
Assert.NotNull(result.Document.Components.Schemas);
var referencing = result.Document.Components.Schemas["Referencing"];
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/RelativeReferenceTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/RelativeReferenceTests.cs
index 0aa1cbb76..cb98d2a0f 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/RelativeReferenceTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/RelativeReferenceTests.cs
@@ -17,10 +17,10 @@ public class RelativeReferenceTests
public async Task ParseInlineLocalReferenceWorks()
{
// Arrange
- var filePath = Path.Combine(SampleFolderPath, "inlineLocalReference.yaml");
+ var filePath = Path.Join(SampleFolderPath, "inlineLocalReference.yaml");
// Act
- var actual = (await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings)).Document;
+ var actual = (await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;
var schemaType = actual.Paths["/item"].Operations[HttpMethod.Get].Parameters[0].Schema.Type;
// Assert
@@ -40,7 +40,7 @@ public async Task ParseInlineExternalReferenceWorks()
}
};
- var path = Path.Combine(Directory.GetCurrentDirectory(), SampleFolderPath);
+ var path = Path.Join(Directory.GetCurrentDirectory(), SampleFolderPath);
var settings = new OpenApiReaderSettings
{
@@ -50,7 +50,7 @@ public async Task ParseInlineExternalReferenceWorks()
settings.AddYamlReader();
// Act
- var actual = (await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "inlineExternalReference.yaml"), settings)).Document;
+ var actual = (await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "inlineExternalReference.yaml"), settings, token: TestContext.Current.CancellationToken)).Document;
var exampleValue = actual.Paths["/items"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Examples["item-list"].Value;
// Assert
@@ -63,7 +63,7 @@ public async Task ParseInlineExternalReferenceWorks()
public async Task ParseComponentExternalReferenceWorks()
{
// Arrange
- var path = Path.Combine(Directory.GetCurrentDirectory(), SampleFolderPath);
+ var path = Path.Join(Directory.GetCurrentDirectory(), SampleFolderPath);
var settings = new OpenApiReaderSettings
{
LoadExternalRefs = true,
@@ -72,7 +72,7 @@ public async Task ParseComponentExternalReferenceWorks()
settings.AddYamlReader();
// Act
- var actual = (await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "componentExternalReference.yaml"), settings)).Document;
+ var actual = (await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "componentExternalReference.yaml"), settings, token: TestContext.Current.CancellationToken)).Document;
var securitySchemeValue = actual.Components.SecuritySchemes["customapikey"];
// Assert
@@ -83,10 +83,10 @@ public async Task ParseComponentExternalReferenceWorks()
public async Task ParseRootInlineJsonSchemaReferenceWorks()
{
// Arrange
- var filePath = Path.Combine(SampleFolderPath, "rootInlineSchemaReference.yaml");
+ var filePath = Path.Join(SampleFolderPath, "rootInlineSchemaReference.yaml");
// Act
- var actual = (await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings)).Document;
+ var actual = (await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;
var schema = actual.Paths["/item"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema;
// Assert
@@ -97,10 +97,10 @@ public async Task ParseRootInlineJsonSchemaReferenceWorks()
public async Task ParseSubschemaInlineJsonSchemaReferenceWorks()
{
// Arrange
- var filePath = Path.Combine(SampleFolderPath, "subschemaInlineSchemaReference.yaml");
+ var filePath = Path.Join(SampleFolderPath, "subschemaInlineSchemaReference.yaml");
// Act
- var actual = (await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings)).Document;
+ var actual = (await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;
var schema = actual.Paths["/items"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema.Items;
// Assert
@@ -111,10 +111,10 @@ public async Task ParseSubschemaInlineJsonSchemaReferenceWorks()
public async Task ParseRootComponentJsonSchemaReferenceWorks()
{
// Arrange
- var filePath = Path.Combine(SampleFolderPath, "rootComponentSchemaReference.yaml");
+ var filePath = Path.Join(SampleFolderPath, "rootComponentSchemaReference.yaml");
// Act
- var actual = (await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings)).Document;
+ var actual = (await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;
var schema = actual.Components.Schemas["specialitem"];
// Assert
@@ -126,10 +126,10 @@ public async Task ParseRootComponentJsonSchemaReferenceWorks()
public async Task ParseSubschemaComponentJsonSchemaReferenceWorks()
{
// Arrange
- var filePath = Path.Combine(SampleFolderPath, "subschemaComponentSchemaReference.yaml");
+ var filePath = Path.Join(SampleFolderPath, "subschemaComponentSchemaReference.yaml");
// Act
- var actual = (await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings)).Document;
+ var actual = (await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;
var schema = actual.Components.Schemas["items"].Items;
// Assert
@@ -140,10 +140,10 @@ public async Task ParseSubschemaComponentJsonSchemaReferenceWorks()
public async Task ParseInternalComponentSubschemaJsonSchemaReferenceWorks()
{
// Arrange
- var filePath = Path.Combine(SampleFolderPath, "internalComponentsSubschemaReference.yaml");
+ var filePath = Path.Join(SampleFolderPath, "internalComponentsSubschemaReference.yaml");
// Act
- var actual = (await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings)).Document;
+ var actual = (await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;
var addressSchema = actual.Paths["/person/{id}/address"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema;
var itemsSchema = actual.Paths["/human"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema;
@@ -156,7 +156,7 @@ public async Task ParseInternalComponentSubschemaJsonSchemaReferenceWorks()
public async Task ParseExternalComponentSubschemaJsonSchemaReferenceWorks()
{
// Arrange
- var path = Path.Combine(Directory.GetCurrentDirectory(), SampleFolderPath);
+ var path = Path.Join(Directory.GetCurrentDirectory(), SampleFolderPath);
var settings = new OpenApiReaderSettings
{
LoadExternalRefs = true,
@@ -165,7 +165,7 @@ public async Task ParseExternalComponentSubschemaJsonSchemaReferenceWorks()
settings.AddYamlReader();
// Act
- var actual = (await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "externalComponentSubschemaReference.yaml"), settings)).Document;
+ var actual = (await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "externalComponentSubschemaReference.yaml"), settings, token: TestContext.Current.CancellationToken)).Document;
var schema = actual.Paths["/person/{id}"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema;
// Assert
@@ -196,7 +196,7 @@ await File.WriteAllTextAsync(rootPath,
application/json:
schema:
$ref: 'OAS-schemas.yaml#address'
-");
+", TestContext.Current.CancellationToken);
await File.WriteAllTextAsync(externalPath,
@"
openapi: 3.1.0
@@ -211,7 +211,7 @@ await File.WriteAllTextAsync(externalPath,
address:
$anchor: address
type: object
-");
+", TestContext.Current.CancellationToken);
try
{
@@ -222,7 +222,7 @@ await File.WriteAllTextAsync(externalPath,
};
settings.AddYamlReader();
- var result = await OpenApiDocument.LoadAsync(rootPath, settings);
+ var result = await OpenApiDocument.LoadAsync(rootPath, settings, token: TestContext.Current.CancellationToken);
var schema = result.Document.Paths["/person/{id}"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema;
Assert.Equal(JsonSchemaType.Object, schema.Type);
@@ -257,7 +257,7 @@ await File.WriteAllTextAsync(rootPath,
application/json:
schema:
$ref: 'OAS-schemas.yaml#/person/properties/address'
-");
+", TestContext.Current.CancellationToken);
await File.WriteAllTextAsync(externalPath,
@"
person:
@@ -265,7 +265,7 @@ await File.WriteAllTextAsync(externalPath,
properties:
address:
type: object
-");
+", TestContext.Current.CancellationToken);
try
{
@@ -276,7 +276,7 @@ await File.WriteAllTextAsync(externalPath,
};
settings.AddYamlReader();
- var result = await OpenApiDocument.LoadAsync(rootPath, settings);
+ var result = await OpenApiDocument.LoadAsync(rootPath, settings, token: TestContext.Current.CancellationToken);
var schema = result.Document.Paths["/person/{id}"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema;
var schemaReference = Assert.IsType(schema);
@@ -293,10 +293,10 @@ await File.WriteAllTextAsync(externalPath,
public async Task ParseReferenceToInternalComponentUsingDollarIdWorks()
{
// Arrange
- var filePath = Path.Combine(SampleFolderPath, "internalComponentReferenceUsingId.yaml");
+ var filePath = Path.Join(SampleFolderPath, "internalComponentReferenceUsingId.yaml");
// Act
- var actual = (await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings)).Document;
+ var actual = (await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;
var schema = actual.Paths["/person/{id}"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema;
// Assert
@@ -338,11 +338,11 @@ await File.WriteAllTextAsync(rootPath,
properties:
street:
type: string
-");
+", TestContext.Current.CancellationToken);
try
{
- var result = await OpenApiDocument.LoadAsync(rootPath, SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(rootPath, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var schema = result.Document.Paths["/person/{id}/address"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema;
Assert.Equal(JsonSchemaType.Object, schema.Type);
@@ -358,12 +358,12 @@ await File.WriteAllTextAsync(rootPath,
public async Task ParseLocalReferenceToJsonSchemaResourceWorks()
{
// Arrange
- var filePath = Path.Combine(SampleFolderPath, "localReferenceToJsonSchemaResource.yaml");
+ var filePath = Path.Join(SampleFolderPath, "localReferenceToJsonSchemaResource.yaml");
var stringWriter = new StringWriter();
var writer = new OpenApiYamlWriter(stringWriter);
// Act
- var actual = (await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings)).Document;
+ var actual = (await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;
var schema = actual.Components.Schemas["a"].Properties["b"].Properties["c"].Properties["b"];
schema.SerializeAsV31(writer);
@@ -402,7 +402,7 @@ await File.WriteAllTextAsync(rootPath,
schemas:
Leaf:
$ref: './shared.yaml#/Leaf'
-");
+", TestContext.Current.CancellationToken);
await File.WriteAllTextAsync(sharedPath,
@"Leaf:
@@ -412,7 +412,7 @@ await File.WriteAllTextAsync(sharedPath,
type: string
y:
type: integer
-");
+", TestContext.Current.CancellationToken);
try
{
@@ -423,7 +423,7 @@ await File.WriteAllTextAsync(sharedPath,
};
settings.AddYamlReader();
- var result = await OpenApiDocument.LoadAsync(rootPath, settings);
+ var result = await OpenApiDocument.LoadAsync(rootPath, settings, token: TestContext.Current.CancellationToken);
var responseSchema = result.Document.Paths["/a"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema;
var metaSchema = responseSchema.Properties["meta"];
var leafSchema = result.Document.Components.Schemas["Leaf"];
@@ -521,10 +521,10 @@ public void ResolveSubSchema_ShouldRecurseIntoAllOfComposition()
public async Task ShouldResolveRelativeSubReference()
{
// Arrange
- var filePath = Path.Combine(SampleFolderPath, "relativeSubschemaReference.json");
+ var filePath = Path.Join(SampleFolderPath, "relativeSubschemaReference.json");
// Act
- var (actual, _) = await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings);
+ var (actual, _) = await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var fooComponentSchema = actual.Components.Schemas["Foo"];
var seq1Property = fooComponentSchema.Properties["seq1"];
@@ -538,9 +538,9 @@ public async Task ShouldResolveRelativeSubReference()
public async Task ShouldResolveRelativeSubReferenceUsingParsingContext()
{
// Arrange
- var filePath = Path.Combine(SampleFolderPath, "relativeSubschemaReference.json");
+ var filePath = Path.Join(SampleFolderPath, "relativeSubschemaReference.json");
using var fs = new FileStream(filePath, FileMode.Open, FileAccess.Read);
- var jsonNode = await JsonNode.ParseAsync(fs);
+ var jsonNode = await JsonNode.ParseAsync(fs, cancellationToken: TestContext.Current.CancellationToken);
var schemaJsonNode = jsonNode["components"]?["schemas"]?["Foo"];
Assert.NotNull(schemaJsonNode);
var diagnostic = new OpenApiDiagnostic();
@@ -631,10 +631,10 @@ public void ShouldResolveAbsoluteSubReferenceFromTheObjectModel()
public async Task ShouldResolveRecursiveRelativeSubReference()
{
// Arrange
- var filePath = Path.Combine(SampleFolderPath, "recursiveRelativeSubschemaReference.json");
+ var filePath = Path.Join(SampleFolderPath, "recursiveRelativeSubschemaReference.json");
// Act
- var (actual, _) = await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings);
+ var (actual, _) = await OpenApiDocument.LoadAsync(filePath, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var fooComponentSchema = actual.Components.Schemas["Foo"];
var fooSchemaParentProperty = fooComponentSchema.Properties["parent"];
@@ -652,9 +652,9 @@ public async Task ShouldResolveRecursiveRelativeSubReference()
[Fact]
public async Task ShouldResolveReferencesInSchemasFromSystemTextJson()
{
- var filePath = Path.Combine(SampleFolderPath, "STJSchema.json");
+ var filePath = Path.Join(SampleFolderPath, "STJSchema.json");
using var fs = File.OpenRead(filePath);
- var jsonNode = await JsonNode.ParseAsync(fs);
+ var jsonNode = await JsonNode.ParseAsync(fs, cancellationToken: TestContext.Current.CancellationToken);
var parsingContext = new ParsingContext(new OpenApiDiagnostic());
var document = new OpenApiDocument();
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDiscriminator/basicDiscriminator.yaml b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDiscriminator/basicDiscriminator.yaml
new file mode 100644
index 000000000..f93798c9e
--- /dev/null
+++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/Samples/OpenApiDiscriminator/basicDiscriminator.yaml
@@ -0,0 +1,5 @@
+propertyName: pet_type
+mapping:
+ puppy: '#/components/schemas/Dog'
+ kitten: https://gigantic-server.com/schemas/animals.json#/components/schemas/Cat
+ monster: https://gigantic-server.com/schemas/Monster/schema.json#/components/schemas/monster
\ No newline at end of file
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs
index 1dee79059..c619dc599 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiCallbackTests.cs
@@ -19,7 +19,7 @@ public class OpenApiCallbackTests
public async Task ParseBasicCallbackShouldSucceed()
{
// Act
- var callback = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "basicCallback.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
+ var callback = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "basicCallback.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -59,10 +59,10 @@ public async Task ParseBasicCallbackShouldSucceed()
[Fact]
public async Task ParseCallbackWithReferenceShouldSucceed()
{
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "callbackWithReference.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "callbackWithReference.yaml"));
// Act
- var result = await OpenApiModelFactory.LoadAsync(stream, OpenApiConstants.Yaml, SettingsFixture.ReaderSettings);
+ var result = await OpenApiModelFactory.LoadAsync(stream, OpenApiConstants.Yaml, SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
// Assert
var path = result.Document.Paths.First().Value;
@@ -113,7 +113,7 @@ public async Task ParseCallbackWithReferenceShouldSucceed()
public async Task ParseMultipleCallbacksWithReferenceShouldSucceed()
{
// Act
- var result = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "multipleCallbacksWithReference.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "multipleCallbacksWithReference.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
var path = result.Document.Paths.First().Value;
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs
index 9c0a9c0b6..0bb339a08 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDiscriminatorTests.cs
@@ -18,10 +18,10 @@ public class OpenApiDiscriminatorTests
public async Task ParseBasicDiscriminatorShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicDiscriminator.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "basicDiscriminator.yaml"));
// Copy stream to MemoryStream
using var memoryStream = new MemoryStream();
- await stream.CopyToAsync(memoryStream);
+ await stream.CopyToAsync(memoryStream, TestContext.Current.CancellationToken);
memoryStream.Position = 0;
// Act
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs
index e34024b32..6cc8bb7a3 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiDocumentTests.cs
@@ -92,8 +92,8 @@ public void ParseInlineStringWithoutProvidingFormatSucceeds()
[Fact]
public async Task ParseBasicDocumentWithMultipleServersShouldSucceed()
{
- var path = Path.Combine(SampleFolderPath, "basicDocumentWithMultipleServers.yaml");
- var result = await OpenApiDocument.LoadAsync(path, SettingsFixture.ReaderSettings);
+ var path = Path.Join(SampleFolderPath, "basicDocumentWithMultipleServers.yaml");
+ var result = await OpenApiDocument.LoadAsync(path, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
Assert.Empty(result.Diagnostic.Errors);
result.Document.Should().BeEquivalentTo(
@@ -123,13 +123,13 @@ public async Task ParseBasicDocumentWithMultipleServersShouldSucceed()
[Fact]
public async Task ParseBrokenMinimalDocumentShouldYieldExpectedDiagnostic()
{
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "brokenMinimalDocument.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "brokenMinimalDocument.yaml"));
// Copy stream to MemoryStream
using var memoryStream = new MemoryStream();
- await stream.CopyToAsync(memoryStream);
+ await stream.CopyToAsync(memoryStream, TestContext.Current.CancellationToken);
memoryStream.Position = 0;
- var result = await OpenApiDocument.LoadAsync(memoryStream, settings: SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(memoryStream, settings: SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
result.Document.Should().BeEquivalentTo(
new OpenApiDocument
@@ -190,7 +190,7 @@ public void ParseDocumentWithMalformedReferenceShouldYieldExpectedDiagnostic()
[Fact]
public async Task ParseMinimalDocumentShouldSucceed()
{
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "minimalDocument.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "minimalDocument.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
result.Document.Should().BeEquivalentTo(
new OpenApiDocument
@@ -214,8 +214,8 @@ public async Task ParseMinimalDocumentShouldSucceed()
[Fact]
public async Task ParseStandardPetStoreDocumentShouldSucceed()
{
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "petStore.yaml"));
- var actual = await OpenApiDocument.LoadAsync(stream, OpenApiConstants.Yaml, SettingsFixture.ReaderSettings);
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "petStore.yaml"));
+ var actual = await OpenApiDocument.LoadAsync(stream, OpenApiConstants.Yaml, SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
var components = new OpenApiComponents
{
@@ -600,8 +600,8 @@ public async Task ParseStandardPetStoreDocumentShouldSucceed()
[Fact]
public async Task ParseModifiedPetStoreDocumentWithTagAndSecurityShouldSucceed()
{
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "petStoreWithTagAndSecurity.yaml"));
- var actual = await OpenApiDocument.LoadAsync(stream, OpenApiConstants.Yaml, SettingsFixture.ReaderSettings);
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "petStoreWithTagAndSecurity.yaml"));
+ var actual = await OpenApiDocument.LoadAsync(stream, OpenApiConstants.Yaml, SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
var components = new OpenApiComponents
{
@@ -1074,7 +1074,7 @@ [new OpenApiSecuritySchemeReference("securitySchemeName2")] =
[Fact]
public async Task ParsePetStoreExpandedShouldSucceed()
{
- var actual = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "petStoreExpanded.yaml"), SettingsFixture.ReaderSettings);
+ var actual = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "petStoreExpanded.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// TODO: Create the object in memory and compare with the one read from YAML file.
@@ -1085,7 +1085,7 @@ public async Task ParsePetStoreExpandedShouldSucceed()
[Fact]
public async Task GlobalSecurityRequirementShouldReferenceSecurityScheme()
{
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "securedApi.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "securedApi.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var securityRequirement = result.Document.Security[0];
@@ -1095,7 +1095,7 @@ public async Task GlobalSecurityRequirementShouldReferenceSecurityScheme()
[Fact]
public async Task HeaderParameterShouldAllowExample()
{
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "apiWithFullHeaderComponent.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "apiWithFullHeaderComponent.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var exampleHeader = result.Document.Components?.Headers?["example-header"];
Assert.NotNull(exampleHeader);
@@ -1157,7 +1157,7 @@ public async Task HeaderParameterShouldAllowExample()
public async Task ParseDocumentWithReferencedSecuritySchemeWorks()
{
// Act
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "docWithSecuritySchemeReference.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "docWithSecuritySchemeReference.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var securityScheme = result.Document.Components.SecuritySchemes["OAuth2"];
// Assert
@@ -1168,10 +1168,10 @@ public async Task ParseDocumentWithReferencedSecuritySchemeWorks()
public async Task ParseDocumentWithJsonSchemaReferencesWorks()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "docWithJsonSchema.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "docWithJsonSchema.yaml"));
// Act
- var result = await OpenApiDocument.LoadAsync(stream, OpenApiConstants.Yaml, SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(stream, OpenApiConstants.Yaml, SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken);
var actualSchema = result.Document.Paths["/users/{userId}"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema;
@@ -1184,7 +1184,7 @@ public async Task ParseDocumentWithJsonSchemaReferencesWorks()
public async Task ValidateExampleShouldNotHaveDataTypeMismatch()
{
// Act
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "documentWithDateExampleInSchema.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "documentWithDateExampleInSchema.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
var warnings = result.Diagnostic.Warnings;
@@ -1249,7 +1249,7 @@ public async Task ParsesDoubleHopReferences()
{
using var stream = new MemoryStream(Encoding.UTF8.GetBytes(DoubleHopReferenceSerializedDoc));
- var (document, _) = await OpenApiDocument.LoadAsync(stream);
+ var (document, _) = await OpenApiDocument.LoadAsync(stream, cancellationToken: TestContext.Current.CancellationToken);
Assert.NotNull(document);
var petReferenceInResponse = Assert.IsType(document.Paths["/pets"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema);
@@ -1331,7 +1331,7 @@ public async Task SerializesDoubleHopeReferences()
using var stringWriter = new StringWriter();
var writer = new OpenApiJsonWriter(stringWriter);
document.SerializeAsV31(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
var serializedDoc = stringWriter.ToString();
@@ -1418,12 +1418,12 @@ public async Task ParseDocWithRefsUsingProxyReferencesSucceeds()
default: 10
""";
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "minifiedPetStore.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "minifiedPetStore.yaml"));
// Act
- var doc = (await OpenApiDocument.LoadAsync(stream, settings: SettingsFixture.ReaderSettings)).Document;
+ var doc = (await OpenApiDocument.LoadAsync(stream, settings: SettingsFixture.ReaderSettings, cancellationToken: TestContext.Current.CancellationToken)).Document;
var actualParam = doc.Paths["/pets"].Operations[HttpMethod.Get].Parameters[0];
- var outputDoc = (await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0)).MakeLineBreaksEnvironmentNeutral();
+ var outputDoc = (await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken)).MakeLineBreaksEnvironmentNeutral();
var expectedParam = expected.Paths["/pets"].Operations[HttpMethod.Get].Parameters[0];
var expectedParamReference = Assert.IsType(expectedParam);
@@ -1513,7 +1513,7 @@ public void ParseBasicDocumentWithServerVariableAndNoDefaultShouldFail()
[Fact]
public async Task ParseDocumentWithEmptyPathsSucceeds()
{
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "docWithEmptyPaths.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "docWithEmptyPaths.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
Assert.Empty(result.Diagnostic.Errors);
}
@@ -1521,17 +1521,17 @@ public async Task ParseDocumentWithEmptyPathsSucceeds()
public async Task ParseDocumentWithExampleReferencesPasses()
{
// Act & Assert: Ensure no NullReferenceException is thrown
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "docWithExampleReferences.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "docWithExampleReferences.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
Assert.Empty(result.Diagnostic.Errors);
}
[Fact]
public async Task ParseDocumentWithNonStandardMIMETypePasses()
{
- var path = Path.Combine(SampleFolderPath, "basicDocumentWithMultipleServers.yaml");
+ var path = Path.Join(SampleFolderPath, "basicDocumentWithMultipleServers.yaml");
using var stream = Resources.GetStream(path);
using var streamReader = new StreamReader(stream);
- var contentAsString = await streamReader.ReadToEndAsync();
+ var contentAsString = await streamReader.ReadToEndAsync(TestContext.Current.CancellationToken);
var mockMessageHandler = new Mock();
mockMessageHandler.Protected()
.Setup>("SendAsync", ItExpr.IsAny(), ItExpr.IsAny())
@@ -1545,7 +1545,7 @@ public async Task ParseDocumentWithNonStandardMIMETypePasses()
};
settings.AddYamlReader();
// Act & Assert: Ensure NotSupportedException is not thrown for non-standard MIME type: text/x-yaml
- var result = await OpenApiDocument.LoadAsync("https://localhost/doesntmatter/foo.bar", settings);
+ var result = await OpenApiDocument.LoadAsync("https://localhost/doesntmatter/foo.bar", settings, token: TestContext.Current.CancellationToken);
Assert.NotNull(result.Document);
}
}
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs
index 0c0c4e96f..240a98f3d 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiEncodingTests.cs
@@ -18,7 +18,7 @@ public class OpenApiEncodingTests
public async Task ParseBasicEncodingShouldSucceed()
{
// Act
- var encoding = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "basicEncoding.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
+ var encoding = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "basicEncoding.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -31,10 +31,10 @@ public async Task ParseBasicEncodingShouldSucceed()
[Fact]
public async Task ParseAdvancedEncodingShouldSucceed()
{
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "advancedEncoding.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "advancedEncoding.yaml"));
// Act
- var encoding = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var encoding = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -60,7 +60,7 @@ public async Task ParseAdvancedEncodingShouldSucceed()
public async Task ParseEncodingWithAllowReservedShouldSucceed()
{
// Act
- var encoding = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "encodingWithAllowReserved.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
+ var encoding = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "encodingWithAllowReserved.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs
index ffd221d1a..6d52c4ff4 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiExampleTests.cs
@@ -18,7 +18,7 @@ public class OpenApiExampleTests
[Fact]
public async Task ParseAdvancedExampleShouldSucceed()
{
- var example = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "advancedExample.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
+ var example = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "advancedExample.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var expected = new OpenApiExample
{
Value = new JsonObject
@@ -70,7 +70,7 @@ public async Task ParseAdvancedExampleShouldSucceed()
[Fact]
public async Task ParseExampleForcedStringSucceed()
{
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "explicitString.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "explicitString.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
Assert.Empty(result.Diagnostic.Errors);
}
}
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiHeaderTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiHeaderTests.cs
index ba0ab49d3..1b728ffd6 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiHeaderTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiHeaderTests.cs
@@ -19,10 +19,10 @@ public class OpenApiHeaderTests
public async Task ParseBasicHeaderShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicHeader.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "basicHeader.yaml"));
// Act
- var header = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var header = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -40,10 +40,10 @@ public async Task ParseBasicHeaderShouldSucceed()
public async Task ParseHeaderWithContentShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "headerWithContent.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "headerWithContent.yaml"));
// Act
- var header = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var header = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -79,10 +79,10 @@ public async Task ParseHeaderWithContentShouldSucceed()
public async Task ParseHeaderWithMultipleContentTypesShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "headerWithMultipleContentTypes.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "headerWithMultipleContentTypes.yaml"));
// Act
- var header = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var header = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -120,10 +120,10 @@ public async Task ParseHeaderWithMultipleContentTypesShouldSucceed()
public async Task ParseHeaderWithStyleAndContentShouldPreferContent()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "headerWithStyleAndContent.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "headerWithStyleAndContent.yaml"));
// Act
- var header = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var header = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
// Both content and style can be present, content takes precedence for serialization behavior
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs
index 726f47e59..9379c38e8 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiInfoTests.cs
@@ -21,7 +21,7 @@ public class OpenApiInfoTests
public async Task ParseAdvancedInfoShouldSucceed()
{
// Act
- var openApiInfo = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "advancedInfo.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
+ var openApiInfo = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "advancedInfo.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
openApiInfo.Should().BeEquivalentTo(
@@ -81,7 +81,7 @@ public async Task ParseAdvancedInfoShouldSucceed()
public async Task ParseBasicInfoShouldSucceed()
{
// Act
- var openApiInfo = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "basicInfo.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
+ var openApiInfo = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "basicInfo.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -108,10 +108,10 @@ public async Task ParseBasicInfoShouldSucceed()
[Fact]
public async Task ParseMinimalInfoShouldSucceed()
{
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "minimalInfo.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "minimalInfo.yaml"));
// Act
- var openApiInfo = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var openApiInfo = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs
index 5e437b1bd..10c0fb9a9 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiMediaTypeTests.cs
@@ -1,4 +1,4 @@
-using System.Text.Json.Nodes;
+using System.Text.Json.Nodes;
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
@@ -22,7 +22,7 @@ public class OpenApiMediaTypeTests
public async Task ParseMediaTypeWithExampleShouldSucceed()
{
// Act
- var mediaType = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "mediaTypeWithExample.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
+ var mediaType = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "mediaTypeWithExample.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
mediaType.Should().BeEquivalentTo(
@@ -43,7 +43,7 @@ public async Task ParseMediaTypeWithExampleShouldSucceed()
public async Task ParseMediaTypeWithExamplesShouldSucceed()
{
// Act
- var mediaType = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "mediaTypeWithExamples.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
+ var mediaType = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "mediaTypeWithExamples.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
mediaType.Should().BeEquivalentTo(
@@ -103,14 +103,14 @@ public async Task ParseMediaTypeWithEmptyArrayInExamplesWorks()
}
";
JsonNode node;
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "examplesWithEmptyArray.json")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "examplesWithEmptyArray.json")))
{
node = TestHelper.CreateYamlJsonNode(stream);
}
// Act
var mediaType = OpenApiV3Deserializer.LoadMediaType(node, new(), new ParsingContext(new()));
- var serialized = await mediaType.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);
+ var serialized = await mediaType.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
Assert.Equal(expected.MakeLineBreaksEnvironmentNeutral(), serialized.MakeLineBreaksEnvironmentNeutral());
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs
index 7b0844a9b..8756e90f6 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiOperationTests.cs
@@ -20,7 +20,7 @@ public class OpenApiOperationTests
[Fact]
public async Task OperationWithSecurityRequirementShouldReferenceSecurityScheme()
{
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "securedOperation.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "securedOperation.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var securityScheme = result.Document.Paths["/"].Operations[HttpMethod.Get].Security[0].Keys.First();
Assert.Equivalent(result.Document.Components.SecuritySchemes.First().Value, securityScheme);
@@ -34,7 +34,7 @@ public async Task ParseOperationWithParameterWithNoLocationShouldSucceed()
Tags = new HashSet { new() { Name = "user" } }
};
// Act
- var operation = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "operationWithParameterWithNoLocation.json"), OpenApiSpecVersion.OpenApi3_0, openApiDocument, SettingsFixture.ReaderSettings);
+ var operation = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "operationWithParameterWithNoLocation.json"), OpenApiSpecVersion.OpenApi3_0, openApiDocument, SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var expectedOp = new OpenApiOperation
{
Tags = new HashSet()
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs
index fe585d969..9b28fbffe 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiParameterTests.cs
@@ -21,10 +21,10 @@ public class OpenApiParameterTests
public async Task ParsePathParameterShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "pathParameter.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "pathParameter.yaml"));
// Act
- var parameter = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var parameter = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -45,7 +45,7 @@ public async Task ParsePathParameterShouldSucceed()
public async Task ParseQueryParameterShouldSucceed()
{
// Act
- var parameter = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "queryParameter.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var parameter = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "queryParameter.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -72,7 +72,7 @@ public async Task ParseQueryParameterShouldSucceed()
public async Task ParseQueryParameterWithObjectTypeShouldSucceed()
{
// Act
- var parameter = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "queryParameterWithObjectType.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var parameter = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "queryParameterWithObjectType.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -96,10 +96,10 @@ public async Task ParseQueryParameterWithObjectTypeShouldSucceed()
public async Task ParseQueryParameterWithObjectTypeAndContentShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "queryParameterWithObjectTypeAndContent.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "queryParameterWithObjectTypeAndContent.yaml"));
// Act
- var parameter = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var parameter = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -140,7 +140,7 @@ public async Task ParseQueryParameterWithObjectTypeAndContentShouldSucceed()
public async Task ParseHeaderParameterShouldSucceed()
{
// Act
- var parameter = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "headerParameter.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var parameter = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "headerParameter.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -168,7 +168,7 @@ public async Task ParseHeaderParameterShouldSucceed()
public async Task ParseParameterWithNullLocationShouldSucceed()
{
// Act
- var parameter = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "parameterWithNullLocation.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var parameter = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "parameterWithNullLocation.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -189,10 +189,10 @@ public async Task ParseParameterWithNullLocationShouldSucceed()
public async Task ParseParameterWithNoLocationShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "parameterWithNoLocation.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "parameterWithNoLocation.yaml"));
// Act
- var parameter = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var parameter = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -213,10 +213,10 @@ public async Task ParseParameterWithNoLocationShouldSucceed()
public async Task ParseParameterWithUnknownLocationShouldSucceed()
{
// Arrange
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "parameterWithUnknownLocation.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "parameterWithUnknownLocation.yaml"));
// Act
- var parameter = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var parameter = await OpenApiModelFactory.LoadAsync(stream, OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -237,7 +237,7 @@ public async Task ParseParameterWithUnknownLocationShouldSucceed()
public async Task ParseParameterWithExampleShouldSucceed()
{
// Act
- var parameter = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "parameterWithExample.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var parameter = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "parameterWithExample.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
parameter.Should().BeEquivalentTo(
@@ -260,7 +260,7 @@ public async Task ParseParameterWithExampleShouldSucceed()
public async Task ParseParameterWithExamplesShouldSucceed()
{
// Act
- var parameter = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "parameterWithExamples.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var parameter = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "parameterWithExamples.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
parameter.Should().BeEquivalentTo(
@@ -353,7 +353,7 @@ public void ParseParameterWithReferenceWorks()
document.Workspace.RegisterComponents(document);
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "parameterWithRef.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "parameterWithRef.yaml"));
var node = TestHelper.CreateYamlJsonNode(stream);
var expected = document.Components.Parameters["tagsParameter"];
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiResponseTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiResponseTests.cs
index 0f98b40ce..f89ef938c 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiResponseTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiResponseTests.cs
@@ -16,7 +16,7 @@ public class OpenApiResponseTests
[Fact]
public async Task ResponseWithReferencedHeaderShouldReferenceComponent()
{
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "responseWithHeaderReference.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "responseWithHeaderReference.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var response = result.Document.Components.Responses["Test"];
var expected = response.Headers.First().Value;
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs
index fab39f674..85126723b 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs
@@ -27,7 +27,7 @@ public class OpenApiSchemaTests
[Fact]
public void ParsePrimitiveSchemaShouldSucceed()
{
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "primitiveSchema.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "primitiveSchema.yaml"));
var yamlStream = new YamlStream();
yamlStream.Load(new StreamReader(stream));
var yamlNode = yamlStream.Documents[0].RootNode;
@@ -150,7 +150,7 @@ public void ParseSchemaWithNullableBeforeOrAfterTypePreservesNullFlag(string sch
[Fact]
public void ParseDictionarySchemaShouldSucceed()
{
- using (var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "dictionarySchema.yaml")))
+ using (var stream = Resources.GetStream(Path.Join(SampleFolderPath, "dictionarySchema.yaml")))
{
var yamlStream = new YamlStream();
yamlStream.Load(new StreamReader(stream));
@@ -237,7 +237,7 @@ public void ParseSchemaWithOaiCompatibilityKeywordsShouldSucceed()
[Fact]
public void ParseBasicSchemaWithExampleShouldSucceed()
{
- using var stream = Resources.GetStream(Path.Combine(SampleFolderPath, "basicSchemaWithExample.yaml"));
+ using var stream = Resources.GetStream(Path.Join(SampleFolderPath, "basicSchemaWithExample.yaml"));
var yamlStream = new YamlStream();
yamlStream.Load(new StreamReader(stream));
var yamlNode = yamlStream.Documents[0].RootNode;
@@ -291,7 +291,7 @@ public void ParseBasicSchemaWithExampleShouldSucceed()
public async Task ParseBasicSchemaWithReferenceShouldSucceed()
{
// Act
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "basicSchemaWithReference.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "basicSchemaWithReference.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
var components = result.Document.Components;
@@ -358,7 +358,7 @@ public async Task ParseBasicSchemaWithReferenceShouldSucceed()
public async Task ParseAdvancedSchemaWithReferenceShouldSucceed()
{
// Act
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "advancedSchemaWithReference.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "advancedSchemaWithReference.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var expectedComponents = new OpenApiComponents
{
@@ -444,8 +444,8 @@ public async Task ParseAdvancedSchemaWithReferenceShouldSucceed()
};
// We serialize so that we can get rid of the schema BaseUri properties which show up as diffs
- var actual = await result.Document.Components.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0);
- var expected = await expectedComponents.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await result.Document.Components.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
+ var expected = await expectedComponents.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
Assert.Equal(expected, actual);
@@ -455,7 +455,7 @@ public async Task ParseAdvancedSchemaWithReferenceShouldSucceed()
public async Task ParseExternalReferenceSchemaShouldSucceed()
{
// Act
- var result = await OpenApiDocument.LoadAsync(Path.Combine(SampleFolderPath, "externalReferencesSchema.yaml"), SettingsFixture.ReaderSettings);
+ var result = await OpenApiDocument.LoadAsync(Path.Join(SampleFolderPath, "externalReferencesSchema.yaml"), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
var components = result.Document.Components;
@@ -519,10 +519,10 @@ public async Task SerializeSchemaWithNullableShouldSucceed()
var expected = @"type: string
nullable: true";
- var path = Path.Combine(SampleFolderPath, "schemaWithNullable.yaml");
+ var path = Path.Join(SampleFolderPath, "schemaWithNullable.yaml");
// Act
- var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
+ var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var writer = new StringWriter();
schema.SerializeAsV3(new OpenApiYamlWriter(writer));
@@ -538,10 +538,10 @@ public async Task SerializeSchemaWithOnlyNullableShouldSucceed()
// Arrange
var expected = @"{ }";
- var path = Path.Combine(SampleFolderPath, "schemaWithOnlyNullable.yaml");
+ var path = Path.Join(SampleFolderPath, "schemaWithOnlyNullable.yaml");
// Act
- var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
+ var schema = await OpenApiModelFactory.LoadAsync(path, OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
var writer = new StringWriter();
schema.SerializeAsV3(new OpenApiYamlWriter(writer));
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs
index 46f0088b1..909e95811 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSecuritySchemeTests.cs
@@ -17,7 +17,7 @@ public class OpenApiSecuritySchemeTests
public async Task ParseHttpSecuritySchemeShouldSucceed()
{
// Act
- var securityScheme = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "httpSecurityScheme.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
+ var securityScheme = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "httpSecurityScheme.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -32,7 +32,7 @@ public async Task ParseHttpSecuritySchemeShouldSucceed()
public async Task ParseApiKeySecuritySchemeShouldSucceed()
{
// Act
- var securityScheme = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "apiKeySecurityScheme.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
+ var securityScheme = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "apiKeySecurityScheme.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -48,7 +48,7 @@ public async Task ParseApiKeySecuritySchemeShouldSucceed()
public async Task ParseBearerSecuritySchemeShouldSucceed()
{
// Act
- var securityScheme = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "bearerSecurityScheme.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
+ var securityScheme = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "bearerSecurityScheme.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -64,7 +64,7 @@ public async Task ParseBearerSecuritySchemeShouldSucceed()
public async Task ParseOAuth2SecuritySchemeShouldSucceed()
{
// Act
- var securityScheme = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "oauth2SecurityScheme.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
+ var securityScheme = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "oauth2SecurityScheme.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
@@ -90,7 +90,7 @@ public async Task ParseOAuth2SecuritySchemeShouldSucceed()
public async Task ParseOpenIdConnectSecuritySchemeShouldSucceed()
{
// Act
- var securityScheme = await OpenApiModelFactory.LoadAsync(Path.Combine(SampleFolderPath, "openIdConnectSecurityScheme.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings);
+ var securityScheme = await OpenApiModelFactory.LoadAsync(Path.Join(SampleFolderPath, "openIdConnectSecurityScheme.yaml"), OpenApiSpecVersion.OpenApi3_0, new(), SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiXmlTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiXmlTests.cs
index 259400c90..7b1c67767 100644
--- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiXmlTests.cs
+++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiXmlTests.cs
@@ -18,7 +18,7 @@ public class OpenApiXmlTests
public async Task ParseBasicXmlShouldSucceed()
{
// Act
- var xml = await OpenApiModelFactory.LoadAsync(Resources.GetStream(Path.Combine(SampleFolderPath, "basicXml.yaml")), OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings);
+ var xml = await OpenApiModelFactory.LoadAsync(Resources.GetStream(Path.Join(SampleFolderPath, "basicXml.yaml")), OpenApiSpecVersion.OpenApi3_0, new(), settings: SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken);
// Assert
Assert.Equivalent(
diff --git a/test/Microsoft.OpenApi.Tests/Extensions/OpenApiSerializableExtensionsTests.cs b/test/Microsoft.OpenApi.Tests/Extensions/OpenApiSerializableExtensionsTests.cs
index a1e323ebf..470fb022b 100644
--- a/test/Microsoft.OpenApi.Tests/Extensions/OpenApiSerializableExtensionsTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Extensions/OpenApiSerializableExtensionsTests.cs
@@ -27,11 +27,11 @@ public async Task UsesTheTerseOutputInformationFromSettingsTrue()
};
using var stream = new MemoryStream();
- await parameter.SerializeAsync(stream, OpenApiSpecVersion.OpenApi3_1, OpenApiConstants.Json, settings);
+ await parameter.SerializeAsync(stream, OpenApiSpecVersion.OpenApi3_1, OpenApiConstants.Json, settings, TestContext.Current.CancellationToken);
stream.Position = 0;
using var reader = new StreamReader(stream);
- var output = await reader.ReadToEndAsync();
+ var output = await reader.ReadToEndAsync(TestContext.Current.CancellationToken);
Assert.Equal("{\"name\":\"param1\",\"in\":\"query\",\"description\":\"A sample parameter\",\"schema\":{\"type\":\"string\"}}", output);
}
@@ -57,11 +57,11 @@ public async Task UsesTheTerseOutputInformationFromSettingsFalse()
};
using var stream = new MemoryStream();
- await parameter.SerializeAsync(stream, OpenApiSpecVersion.OpenApi3_1, OpenApiConstants.Json, settings);
+ await parameter.SerializeAsync(stream, OpenApiSpecVersion.OpenApi3_1, OpenApiConstants.Json, settings, TestContext.Current.CancellationToken);
stream.Position = 0;
using var reader = new StreamReader(stream);
- var output = await reader.ReadToEndAsync();
+ var output = await reader.ReadToEndAsync(TestContext.Current.CancellationToken);
Assert.Equal("{\n \"name\": \"param1\",\n \"in\": \"query\",\n \"description\": \"A sample parameter\",\n \"schema\": {\n \"type\": \"string\"\n }\n}", output);
}
@@ -82,11 +82,11 @@ public async Task UsesTheTerseOutputInformationFromSettingsNoSettings()
};
using var stream = new MemoryStream();
- await parameter.SerializeAsync(stream, OpenApiSpecVersion.OpenApi3_1, OpenApiConstants.Json, null);
+ await parameter.SerializeAsync(stream, OpenApiSpecVersion.OpenApi3_1, OpenApiConstants.Json, null, TestContext.Current.CancellationToken);
stream.Position = 0;
using var reader = new StreamReader(stream);
- var output = await reader.ReadToEndAsync();
+ var output = await reader.ReadToEndAsync(TestContext.Current.CancellationToken);
Assert.Equal("{\n \"name\": \"param1\",\n \"in\": \"query\",\n \"description\": \"A sample parameter\",\n \"schema\": {\n \"type\": \"string\"\n }\n}", output);
}
diff --git a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
index d2c73b955..cff07adde 100644
--- a/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
+++ b/test/Microsoft.OpenApi.Tests/Microsoft.OpenApi.Tests.csproj
@@ -13,8 +13,8 @@
-
-
+
+
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs
index e6cfa8007..57019906f 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiCallbackTests.cs
@@ -103,7 +103,7 @@ public async Task SerializeAdvancedCallbackAsV3JsonWorksAsync(bool produceTerseO
// Act
AdvancedCallback.SerializeAsV3(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
@@ -120,7 +120,7 @@ public async Task SerializeReferencedCallbackAsV3JsonWorksAsync(bool produceTers
// Act
CallbackProxy.SerializeAsV3(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
@@ -137,7 +137,7 @@ public async Task SerializeReferencedCallbackAsV3JsonWithoutReferenceWorksAsync(
// Act
ReferencedCallback.SerializeAsV3(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs
index 3a1b9fa30..cf5204581 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiComponentsTests.cs
@@ -267,7 +267,7 @@ public async Task SerializeBasicComponentsAsJsonWorks()
var expected = @"{ }";
// Act
- var actual = await BasicComponents.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await BasicComponents.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -282,7 +282,7 @@ public async Task SerializeBasicComponentsAsYamlWorks()
var expected = @"{ }";
// Act
- var actual = await BasicComponents.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await BasicComponents.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -334,7 +334,7 @@ public async Task SerializeAdvancedComponentsAsJsonV3Works()
""";
// Act
- var actual = await AdvancedComponents.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await AdvancedComponents.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -392,7 +392,7 @@ public async Task SerializeAdvancedComponentsWithReferenceAsJsonV3Works()
""";
// Act
- var actual = await AdvancedComponentsWithReference.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await AdvancedComponentsWithReference.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -431,7 +431,7 @@ public async Task SerializeAdvancedComponentsAsYamlV3Works()
""";
// Act
- var actual = await AdvancedComponents.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await AdvancedComponents.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -473,7 +473,7 @@ public async Task SerializeAdvancedComponentsWithReferenceAsYamlV3Works()
""";
// Act
- var actual = await AdvancedComponentsWithReference.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await AdvancedComponentsWithReference.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -510,7 +510,7 @@ public async Task SerializeBrokenComponentsAsJsonV3Works()
""";
// Act
- var actual = await BrokenComponents.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await BrokenComponents.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -540,7 +540,7 @@ public async Task SerializeBrokenComponentsAsYamlV3Works()
""";
// Act
- var actual = await BrokenComponents.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await BrokenComponents.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -566,7 +566,7 @@ public async Task SerializeTopLevelReferencingComponentsAsYamlV3Works()
""";
// Act
- var actual = await TopLevelReferencingComponents.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await TopLevelReferencingComponents.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -591,7 +591,7 @@ public async Task SerializeTopLevelSelfReferencingWithOtherPropertiesComponentsA
type: string";
// Act
- var actual = await TopLevelSelfReferencingComponentsWithOtherProperties.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await TopLevelSelfReferencingComponentsWithOtherProperties.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -646,7 +646,7 @@ public async Task SerializeComponentsWithPathItemsAsJsonWorks()
}
}";
// Act
- var actual = await ComponentsWithPathItem.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_1);
+ var actual = await ComponentsWithPathItem.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_1, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -683,7 +683,7 @@ public async Task SerializeComponentsWithPathItemsAsYamlWorks()
type: integer";
// Act
- var actual = await ComponentsWithPathItem.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_1);
+ var actual = await ComponentsWithPathItem.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_1, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs
index f699b2f40..81050fcb4 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiContactTests.cs
@@ -34,7 +34,7 @@ public async Task SerializeBasicContactWorks(
string expected)
{
// Arrange & Act
- var actual = await BasicContact.SerializeAsync(version, format);
+ var actual = await BasicContact.SerializeAsync(version, format, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -59,7 +59,7 @@ public async Task SerializeAdvanceContactAsJsonWorks(OpenApiSpecVersion version)
""";
// Act
- var actual = await AdvanceContact.SerializeAsJsonAsync(version);
+ var actual = await AdvanceContact.SerializeAsJsonAsync(version, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -82,7 +82,7 @@ public async Task SerializeAdvanceContactAsYamlWorks(OpenApiSpecVersion version)
""";
// Act
- var actual = await AdvanceContact.SerializeAsYamlAsync(version);
+ var actual = await AdvanceContact.SerializeAsYamlAsync(version, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt
index b87f4acf5..479557a10 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.SerializeDuplicateExtensionsAsV3JsonWorksAsync_produceTerseOutput=True.verified.txt
@@ -1 +1 @@
-{"openapi":"3.0.4","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"}}}}}}}}}}},"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"}}}}}}
+{"openapi":"3.0.4","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"}}}}}}}}}}},"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.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs
index b4cfe2543..1d6cedfb7 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiDocumentTests.cs
@@ -1334,7 +1334,7 @@ public async Task SerializeAdvancedDocumentAsV3JsonWorksAsync(bool produceTerseO
// Act
AdvancedDocument.SerializeAsV3(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
@@ -1351,7 +1351,7 @@ public async Task SerializeAdvancedDocumentWithReferenceAsV3JsonWorksAsync(bool
// Act
AdvancedDocumentWithReference.SerializeAsV3(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
@@ -1368,7 +1368,7 @@ public async Task SerializeAdvancedDocumentWithServerVariableAsV2JsonWorksAsync(
// Act
AdvancedDocumentWithServerVariable.SerializeAsV2(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
@@ -1385,7 +1385,7 @@ public async Task SerializeAdvancedDocumentAsV2JsonWorksAsync(bool produceTerseO
// Act
AdvancedDocument.SerializeAsV2(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
@@ -1402,7 +1402,7 @@ public async Task SerializeDuplicateExtensionsAsV3JsonWorksAsync(bool produceTer
// Act
DuplicateExtensions.SerializeAsV3(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
@@ -1419,7 +1419,7 @@ public async Task SerializeDuplicateExtensionsAsV2JsonWorksAsync(bool produceTer
// Act
DuplicateExtensions.SerializeAsV2(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
@@ -1436,7 +1436,7 @@ public async Task SerializeAdvancedDocumentWithReferenceAsV2JsonWorksAsync(bool
// Act
AdvancedDocumentWithReference.SerializeAsV2(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
@@ -1460,7 +1460,7 @@ public async Task SerializeSimpleDocumentWithTopLevelReferencingComponentsAsYaml
type: string";
// Act
- var actual = await SimpleDocumentWithTopLevelReferencingComponents.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0);
+ var actual = await SimpleDocumentWithTopLevelReferencingComponents.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -1479,7 +1479,7 @@ public async Task SerializeSimpleDocumentWithTopLevelSelfReferencingComponentsAs
schema1: { }";
// Act
- var actual = await SimpleDocumentWithTopLevelSelfReferencingComponents.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0);
+ var actual = await SimpleDocumentWithTopLevelSelfReferencingComponents.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -1507,7 +1507,7 @@ public async Task SerializeSimpleDocumentWithTopLevelSelfReferencingWithOtherPro
type: string";
// Act
- var actual = await SimpleDocumentWithTopLevelSelfReferencingComponentsWithOtherProperties.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0);
+ var actual = await SimpleDocumentWithTopLevelSelfReferencingComponentsWithOtherProperties.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -1553,7 +1553,7 @@ public async Task SerializeDocumentWithReferenceButNoComponents()
document.Paths["/"].Operations[HttpMethod.Get].Responses["200"].Content["application/json"].Schema = new OpenApiSchemaReference("test", document);
// Act
- var actual = await document.SerializeAsync(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Json);
+ var actual = await document.SerializeAsync(OpenApiSpecVersion.OpenApi2_0, OpenApiConstants.Json, TestContext.Current.CancellationToken);
// Assert
Assert.NotEmpty(actual);
@@ -1581,7 +1581,7 @@ public async Task SerializeRelativePathAsV2JsonWorks()
};
// Act
- var actual = await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0);
+ var actual = await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -1611,7 +1611,7 @@ public async Task SerializeRelativePathWithHostAsV2JsonWorks()
};
// Act
- var actual = await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0);
+ var actual = await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -1640,7 +1640,7 @@ public async Task SerializeRelativeRootPathWithHostAsV2JsonWorks()
};
// Act
- var actual = await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0);
+ var actual = await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -1653,18 +1653,18 @@ public async Task TestHashCodesForSimilarOpenApiDocuments()
// Arrange
var sampleFolderPath = "Models/Samples/";
- var doc1 = await ParseInputFileAsync(Path.Combine(sampleFolderPath, "sampleDocument.yaml"));
- var doc2 = await ParseInputFileAsync(Path.Combine(sampleFolderPath, "sampleDocument.yaml"));
- var doc3 = await ParseInputFileAsync(Path.Combine(sampleFolderPath, "sampleDocumentWithWhiteSpaces.yaml"));
+ var doc1 = await ParseInputFileAsync(Path.Join(sampleFolderPath, "sampleDocument.yaml"));
+ var doc2 = await ParseInputFileAsync(Path.Join(sampleFolderPath, "sampleDocument.yaml"));
+ var doc3 = await ParseInputFileAsync(Path.Join(sampleFolderPath, "sampleDocumentWithWhiteSpaces.yaml"));
// Act && Assert
/*
Test whether reading in two similar documents yield the same hash code,
And reading in similar documents(one has a whitespace) yields the same hash code as the result is terse
*/
- var doc1HashCode = await doc1.GetHashCodeAsync();
- var doc2HashCode = await doc2.GetHashCodeAsync();
- var doc3HashCode = await doc3.GetHashCodeAsync();
+ var doc1HashCode = await doc1.GetHashCodeAsync(TestContext.Current.CancellationToken);
+ var doc2HashCode = await doc2.GetHashCodeAsync(TestContext.Current.CancellationToken);
+ var doc3HashCode = await doc3.GetHashCodeAsync(TestContext.Current.CancellationToken);
Assert.NotNull(doc1HashCode);
Assert.NotNull(doc2HashCode);
Assert.NotNull(doc3HashCode);
@@ -1725,7 +1725,7 @@ public async Task SerializeV2DocumentWithNonArraySchemaTypeDoesNotWriteOutCollec
};
// Act
- var actual = await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0);
+ var actual = await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi2_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -1813,7 +1813,7 @@ public async Task SerializeV2DocumentWithStyleAsNullDoesNotWriteOutStyleValue()
};
// Act
- var actual = await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -1885,7 +1885,7 @@ public async Task SerializeDocumentWithWebhooksAsV3JsonWorks(bool produceTerseOu
// Act
DocumentWithWebhooks.SerializeAsV31(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
var actual = outputStringWriter.GetStringBuilder().ToString();
// Assert
@@ -1929,7 +1929,7 @@ public async Task SerializeDocumentWithWebhooksAsV3YamlWorks()
description: Return a 200 status to indicate that the data was received successfully";
// Act
- var actual = await DocumentWithWebhooks.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_1);
+ var actual = await DocumentWithWebhooks.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_1, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -1959,7 +1959,7 @@ public async Task SerializeDocumentWithRootJsonSchemaDialectPropertyWorks()
paths: { }";
// Act
- var actual = await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_1);
+ var actual = await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_1, TestContext.Current.CancellationToken);
// Assert
Assert.Equal(expected.MakeLineBreaksEnvironmentNeutral(), actual.MakeLineBreaksEnvironmentNeutral());
@@ -1980,7 +1980,7 @@ public async Task SerializeV31DocumentWithRefsInWebhooksWorks()
items:
type: object";
- var doc = (await OpenApiDocument.LoadAsync("Models/Samples/docWithReusableWebhooks.yaml", SettingsFixture.ReaderSettings)).Document;
+ var doc = (await OpenApiDocument.LoadAsync("Models/Samples/docWithReusableWebhooks.yaml", SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;
var stringWriter = new StringWriter();
var writer = new OpenApiYamlWriter(stringWriter, new OpenApiWriterSettings { InlineLocalReferences = true });
@@ -2034,8 +2034,8 @@ public async Task SerializeDocWithDollarIdInDollarRefSucceeds()
radius:
type: number
";
- var doc = (await OpenApiDocument.LoadAsync("Models/Samples/docWithDollarId.yaml", SettingsFixture.ReaderSettings)).Document;
- var actual = await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_1);
+ var doc = (await OpenApiDocument.LoadAsync("Models/Samples/docWithDollarId.yaml", SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;
+ var actual = await doc.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_1, TestContext.Current.CancellationToken);
Assert.Equal(expected.MakeLineBreaksEnvironmentNeutral(), actual.MakeLineBreaksEnvironmentNeutral());
}
@@ -2089,7 +2089,7 @@ public async Task SerializeDocumentTagsWithMultipleExtensionsWorks()
}
};
- var actual = await doc.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await doc.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
Assert.Equal(expected.MakeLineBreaksEnvironmentNeutral(), actual.MakeLineBreaksEnvironmentNeutral());
}
[Fact]
@@ -2236,7 +2236,7 @@ public async Task SerializeAdvancedDocumentAsVersionJsonWorksAsync(OpenApiSpecVe
// Act
AdvancedDocument.SerializeAs(version, writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(version);
@@ -2294,7 +2294,7 @@ public async Task SerializeDocWithSecuritySchemeWithInlineReferencesWorks()
scopes:
api://a2a7226d-e8d1-4ded-8c53-dd4c136ff456/repairs_read: Read repair records";
- var doc = (await OpenApiDocument.LoadAsync("Models/Samples/docWithSecurityScheme.yaml", SettingsFixture.ReaderSettings)).Document;
+ var doc = (await OpenApiDocument.LoadAsync("Models/Samples/docWithSecurityScheme.yaml", SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;
var stringWriter = new StringWriter();
doc.SerializeAsV3(new OpenApiYamlWriter(stringWriter, new OpenApiWriterSettings { InlineLocalReferences = true }));
var actual = stringWriter.ToString();
@@ -2326,7 +2326,7 @@ public async Task SerializeDocWithoutOperationSecurityWorks()
type: object
""";
- var doc = (await OpenApiDocument.LoadAsync("Models/Samples/docWithoutOperationSecurity.yaml", SettingsFixture.ReaderSettings)).Document;
+ var doc = (await OpenApiDocument.LoadAsync("Models/Samples/docWithoutOperationSecurity.yaml", SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;
var stringWriter = new StringWriter();
doc!.SerializeAsV3(new OpenApiYamlWriter(stringWriter, new OpenApiWriterSettings { InlineLocalReferences = true }));
var actual = stringWriter.ToString();
@@ -2361,7 +2361,7 @@ public async Task SerializeDocWithEmptyOperationSecurityWorks()
security: [ ]
""";
- var doc = (await OpenApiDocument.LoadAsync("Models/Samples/docWithEmptyOperationSecurity.yaml", SettingsFixture.ReaderSettings)).Document;
+ var doc = (await OpenApiDocument.LoadAsync("Models/Samples/docWithEmptyOperationSecurity.yaml", SettingsFixture.ReaderSettings, token: TestContext.Current.CancellationToken)).Document;
var stringWriter = new StringWriter();
doc!.SerializeAsV3(new OpenApiYamlWriter(stringWriter, new OpenApiWriterSettings { InlineLocalReferences = true }));
var actual = stringWriter.ToString();
@@ -2412,7 +2412,7 @@ public async Task SerializeDocumentWithSecurityRequirementAsJsonWorks(OpenApiSpe
""";
// Act
- var actual = await doc.SerializeAsJsonAsync(openApiSpecVersion);
+ var actual = await doc.SerializeAsJsonAsync(openApiSpecVersion, TestContext.Current.CancellationToken);
// Assert
var actualSecurity = JsonNode.Parse(actual)?["security"];
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs
index 81d6426ad..f9dcbb8ea 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiEncodingTests.cs
@@ -25,7 +25,7 @@ public class OpenApiEncodingTests
public async Task SerializeBasicEncodingAsV3Works(string format, string expected)
{
// Arrange & Act
- var actual = await BasicEncoding.SerializeAsync(OpenApiSpecVersion.OpenApi3_0, format);
+ var actual = await BasicEncoding.SerializeAsync(OpenApiSpecVersion.OpenApi3_0, format, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -48,7 +48,7 @@ public async Task SerializeAdvanceEncodingAsV3JsonWorks()
""";
// Act
- var actual = await AdvanceEncoding.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await AdvanceEncoding.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -69,7 +69,7 @@ public async Task SerializeAdvanceEncodingAsV3YamlWorks()
""";
// Act
- var actual = await AdvanceEncoding.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await AdvanceEncoding.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -119,7 +119,7 @@ public async Task WhenExplodeIsSetOutputShouldHaveExplode(bool? expectedExplode,
}
// Act
- var actual = await parameter.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await parameter.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs
index 3fb95d8c7..9b41ea090 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExampleTests.cs
@@ -104,7 +104,7 @@ public async Task SerializeAdvancedExampleAsV3JsonWorksAsync(bool produceTerseOu
// Act
AdvancedExample.SerializeAsV3(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
@@ -121,7 +121,7 @@ public async Task SerializeReferencedExampleAsV3JsonWorksAsync(bool produceTerse
// Act
OpenApiExampleReference.SerializeAsV3(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
@@ -138,7 +138,7 @@ public async Task SerializeReferencedExampleAsV3JsonWithoutReferenceWorksAsync(b
// Act
ReferencedExample.SerializeAsV3(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs
index 9a290d425..95bcde5d1 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiExternalDocsTests.cs
@@ -25,7 +25,7 @@ public class OpenApiExternalDocsTests
public async Task SerializeBasicExternalDocsAsV3Works(string format, string expected)
{
// Arrange & Act
- var actual = await BasicExDocs.SerializeAsync(OpenApiSpecVersion.OpenApi3_0, format);
+ var actual = await BasicExDocs.SerializeAsync(OpenApiSpecVersion.OpenApi3_0, format, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -46,7 +46,7 @@ public async Task SerializeAdvanceExDocsAsV3JsonWorks()
""";
// Act
- var actual = await AdvanceExDocs.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await AdvanceExDocs.SerializeAsJsonAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
@@ -65,7 +65,7 @@ public async Task SerializeAdvanceExDocsAsV3YamlWorks()
""";
// Act
- var actual = await AdvanceExDocs.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0);
+ var actual = await AdvanceExDocs.SerializeAsYamlAsync(OpenApiSpecVersion.OpenApi3_0, TestContext.Current.CancellationToken);
// Assert
actual = actual.MakeLineBreaksEnvironmentNeutral();
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs
index 0f57503b3..a42fd1fb6 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiHeaderTests.cs
@@ -45,7 +45,7 @@ public async Task SerializeAdvancedHeaderAsV3JsonWorksAsync(bool produceTerseOut
// Act
AdvancedHeader.SerializeAsV3(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
@@ -62,7 +62,7 @@ public async Task SerializeReferencedHeaderAsV3JsonWorksAsync(bool produceTerseO
// Act
OpenApiHeaderReference.SerializeAsV3(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
@@ -79,7 +79,7 @@ public async Task SerializeReferencedHeaderAsV3JsonWithoutReferenceWorksAsync(bo
// Act
ReferencedHeader.SerializeAsV3(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
@@ -96,7 +96,7 @@ public async Task SerializeAdvancedHeaderAsV2JsonWorksAsync(bool produceTerseOut
// Act
AdvancedHeader.SerializeAsV2(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
@@ -113,7 +113,7 @@ public async Task SerializeReferencedHeaderAsV2JsonWorksAsync(bool produceTerseO
// Act
OpenApiHeaderReference.SerializeAsV2(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
@@ -130,7 +130,7 @@ public async Task SerializeReferencedHeaderAsV2JsonWithoutReferenceWorksAsync(bo
// Act
ReferencedHeader.SerializeAsV2(writer);
- await writer.FlushAsync();
+ await writer.FlushAsync(TestContext.Current.CancellationToken);
// Assert
await Verifier.Verify(outputStringWriter).UseParameters(produceTerseOutput);
diff --git a/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs b/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs
index 57c3e1c7e..eaded3a3f 100644
--- a/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs
+++ b/test/Microsoft.OpenApi.Tests/Models/OpenApiInfoTests.cs
@@ -61,7 +61,7 @@ public static IEnumerable