diff --git a/eng/Versions.props b/eng/Versions.props
index 324cb9d4acc3..c9a3da1c8ba3 100644
--- a/eng/Versions.props
+++ b/eng/Versions.props
@@ -335,8 +335,8 @@
$(XunitVersion)
2.8.2
5.2.2
- 2.0.0-preview2
- 2.0.0-preview2
+ 2.0.0-preview4
+ 2.0.0-preview4
6.0.322601
1.10.93
diff --git a/src/OpenApi/sample/Transformers/AddExternalDocsTransformer.cs b/src/OpenApi/sample/Transformers/AddExternalDocsTransformer.cs
index acc4402c32f6..b47b3b4d7697 100644
--- a/src/OpenApi/sample/Transformers/AddExternalDocsTransformer.cs
+++ b/src/OpenApi/sample/Transformers/AddExternalDocsTransformer.cs
@@ -29,7 +29,7 @@ public Task TransformAsync(OpenApiSchema schema, OpenApiSchemaTransformerContext
{
if (Uri.TryCreate(configuration["DocumentationBaseUrl"], UriKind.Absolute, out var baseUri))
{
- var url = new Uri(baseUri, $"/api/docs/schemas/{Uri.EscapeDataString(schema.Type.ToString()!)}");
+ var url = new Uri(baseUri, $"/api/docs/schemas/{Uri.EscapeDataString(schema.Type.ToString()!.ToLowerInvariant())}");
schema.ExternalDocs = new OpenApiExternalDocs
{
diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Extensions/OpenApiEndpointRouteBuilderExtensionsTests.cs b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Extensions/OpenApiEndpointRouteBuilderExtensionsTests.cs
index d4c6eaa1fbc5..fdc86f1120db 100644
--- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Extensions/OpenApiEndpointRouteBuilderExtensionsTests.cs
+++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Extensions/OpenApiEndpointRouteBuilderExtensionsTests.cs
@@ -200,8 +200,8 @@ private static async Task ValidateOpenApiDocumentAsync(MemoryStream documentStre
documentStream.Position = 0;
OpenApiReaderRegistry.RegisterReader(OpenApiConstants.Yaml, new OpenApiYamlReader());
var result = await OpenApiDocument.LoadAsync(documentStream, format);
- Assert.Empty(result.OpenApiDiagnostic.Errors);
- action(result.OpenApiDocument);
+ Assert.Empty(result.Diagnostic.Errors);
+ action(result.Document);
}
private static IServiceProvider CreateServiceProvider(string documentName = Microsoft.AspNetCore.OpenApi.OpenApiConstants.DefaultDocumentName)
diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=controllers.verified.txt b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=controllers.verified.txt
index 16cd8ae49e69..e084a63428b5 100644
--- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=controllers.verified.txt
+++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=controllers.verified.txt
@@ -8,7 +8,9 @@
"/getbyidandname/{id}/{name}": {
"get": {
"tags": [
- "Test"
+ {
+ "name": "Test"
+ }
],
"parameters": [
{
@@ -57,7 +59,9 @@
"/forms": {
"post": {
"tags": [
- "Test"
+ {
+ "name": "Test"
+ }
],
"requestBody": {
"content": {
@@ -89,6 +93,8 @@
}
},
"tags": [
- "Test"
+ {
+ "name": "Test"
+ }
]
}
\ No newline at end of file
diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=forms.verified.txt b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=forms.verified.txt
index af7b2367c6d4..7a9afdd7473d 100644
--- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=forms.verified.txt
+++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=forms.verified.txt
@@ -8,7 +8,9 @@
"/forms/form-file": {
"post": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"requestBody": {
"content": {
@@ -38,7 +40,9 @@
"/forms/form-files": {
"post": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"requestBody": {
"content": {
@@ -68,7 +72,9 @@
"/forms/form-file-multiple": {
"post": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"requestBody": {
"content": {
@@ -112,7 +118,9 @@
"/forms/form-todo": {
"post": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"requestBody": {
"content": {
@@ -139,7 +147,9 @@
"/forms/forms-pocos-and-files": {
"post": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"requestBody": {
"content": {
@@ -215,6 +225,8 @@
}
},
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
]
}
\ No newline at end of file
diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=responses.verified.txt b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=responses.verified.txt
index 20be794c5af2..3b5407eab404 100644
--- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=responses.verified.txt
+++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=responses.verified.txt
@@ -8,7 +8,9 @@
"/responses/200-add-xml": {
"get": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"responses": {
"200": {
@@ -32,7 +34,9 @@
"/responses/200-only-xml": {
"get": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"responses": {
"200": {
@@ -51,7 +55,9 @@
"/responses/triangle": {
"get": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"responses": {
"200": {
@@ -70,7 +76,9 @@
"/responses/shape": {
"get": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"responses": {
"200": {
@@ -196,6 +204,8 @@
}
},
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
]
}
\ No newline at end of file
diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=schemas-by-ref.verified.txt b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=schemas-by-ref.verified.txt
index b60ee14c9940..40e2a1b58bb6 100644
--- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=schemas-by-ref.verified.txt
+++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=schemas-by-ref.verified.txt
@@ -8,7 +8,9 @@
"/schemas-by-ref/typed-results": {
"get": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"responses": {
"200": {
@@ -27,7 +29,9 @@
"/schemas-by-ref/multiple-results": {
"get": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"responses": {
"200": {
@@ -56,7 +60,9 @@
"/schemas-by-ref/iresult-no-produces": {
"get": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"responses": {
"200": {
@@ -68,7 +74,9 @@
"/schemas-by-ref/iresult-with-produces": {
"get": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"responses": {
"200": {
@@ -87,7 +95,9 @@
"/schemas-by-ref/primitives": {
"get": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"parameters": [
{
@@ -121,7 +131,9 @@
"/schemas-by-ref/product": {
"get": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"requestBody": {
"content": {
@@ -150,7 +162,9 @@
"/schemas-by-ref/account": {
"get": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"requestBody": {
"content": {
@@ -179,7 +193,9 @@
"/schemas-by-ref/array-of-ints": {
"post": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"requestBody": {
"content": {
@@ -213,7 +229,9 @@
"/schemas-by-ref/list-of-ints": {
"post": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"requestBody": {
"content": {
@@ -247,7 +265,9 @@
"/schemas-by-ref/ienumerable-of-ints": {
"post": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"responses": {
"200": {
@@ -267,7 +287,9 @@
"/schemas-by-ref/dictionary-of-ints": {
"get": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"responses": {
"200": {
@@ -290,7 +312,9 @@
"/schemas-by-ref/frozen-dictionary-of-ints": {
"get": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"responses": {
"200": {
@@ -313,7 +337,9 @@
"/schemas-by-ref/shape": {
"post": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"requestBody": {
"content": {
@@ -335,7 +361,9 @@
"/schemas-by-ref/weatherforecastbase": {
"post": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"requestBody": {
"content": {
@@ -357,7 +385,9 @@
"/schemas-by-ref/person": {
"post": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"requestBody": {
"content": {
@@ -617,6 +647,8 @@
}
},
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
]
}
\ No newline at end of file
diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=v1.verified.txt b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=v1.verified.txt
index a769a43de436..45256d45e1a1 100644
--- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=v1.verified.txt
+++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=v1.verified.txt
@@ -8,7 +8,9 @@
"/v1/array-of-guids": {
"get": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"parameters": [
{
@@ -53,7 +55,9 @@
"/v1/todos": {
"post": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"summary": "Creates a new todo item.",
"parameters": [
@@ -86,7 +90,9 @@
"/v1/todos/{id}": {
"get": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"description": "Returns a specific todo item.",
"parameters": [
@@ -190,6 +196,8 @@
}
},
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
]
}
\ No newline at end of file
diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=v2.verified.txt b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=v2.verified.txt
index 42ee779ad9c6..b93d00d293dd 100644
--- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=v2.verified.txt
+++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApiDocumentIntegrationTests.VerifyOpenApiDocument_documentName=v2.verified.txt
@@ -15,7 +15,9 @@
"/v2/users": {
"get": {
"tags": [
- "users"
+ {
+ "name": "users"
+ }
],
"responses": {
"200": {
@@ -28,12 +30,12 @@
"type": "string",
"externalDocs": {
"description": "Documentation for this OpenAPI schema",
- "url": "https://example.com/api/docs/schemas/String"
+ "url": "https://example.com/api/docs/schemas/string"
}
},
"externalDocs": {
"description": "Documentation for this OpenAPI schema",
- "url": "https://example.com/api/docs/schemas/Array"
+ "url": "https://example.com/api/docs/schemas/array"
}
}
}
@@ -43,7 +45,9 @@
},
"post": {
"tags": [
- "Sample"
+ {
+ "name": "Sample"
+ }
],
"externalDocs": {
"description": "Documentation for this OpenAPI endpoint",
@@ -59,7 +63,11 @@
}
},
"tags": [
- "users",
- "Sample"
+ {
+ "name": "users"
+ },
+ {
+ "name": "Sample"
+ }
]
}
\ No newline at end of file
diff --git a/src/Tools/GetDocumentInsider/tests/GetDocumentTests.cs b/src/Tools/GetDocumentInsider/tests/GetDocumentTests.cs
index 1a6c52b55fef..af0900881224 100644
--- a/src/Tools/GetDocumentInsider/tests/GetDocumentTests.cs
+++ b/src/Tools/GetDocumentInsider/tests/GetDocumentTests.cs
@@ -37,11 +37,12 @@ public void GetDocument_Works()
], new GetDocumentCommand(_console), throwOnUnexpectedArg: false);
// Assert
- var result = OpenApiDocument.Load(File.OpenRead(Path.Combine(outputPath.FullName, "Sample.json")), "json");
- // TODO: https://github.com/microsoft/OpenAPI.NET/issues/1991
- // Assert.Empty(result.OpenApiDiagnostic.Errors);
- Assert.Equal(OpenApiSpecVersion.OpenApi3_1, result.OpenApiDiagnostic.SpecificationVersion);
- Assert.Equal("GetDocumentSample | v1", result.OpenApiDocument.Info.Title);
+ using var stream = new MemoryStream(File.ReadAllBytes(Path.Combine(outputPath.FullName, "Sample.json")));
+ var result = OpenApiDocument.Load(stream, "json");
+ // TODO: Needs https://github.com/microsoft/OpenAPI.NET/issues/2055 to be fixed
+ // Assert.Empty(result.Diagnostic.Errors);
+ Assert.Equal(OpenApiSpecVersion.OpenApi3_1, result.Diagnostic.SpecificationVersion);
+ Assert.Equal("GetDocumentSample | v1", result.Document.Info.Title);
}
[Fact]
@@ -63,11 +64,12 @@ public void GetDocument_WithOpenApiVersion_Works()
], new GetDocumentCommand(_console), throwOnUnexpectedArg: false);
// Assert
- var result = OpenApiDocument.Load(File.OpenRead(Path.Combine(outputPath.FullName, "Sample.json")), "json");
- // TODO: https://github.com/microsoft/OpenAPI.NET/issues/1991
- // Assert.Empty(result.OpenApiDiagnostic.Errors);
- Assert.Equal(OpenApiSpecVersion.OpenApi2_0, result.OpenApiDiagnostic.SpecificationVersion);
- Assert.Equal("GetDocumentSample | v1", result.OpenApiDocument.Info.Title);
+ using var stream = new MemoryStream(File.ReadAllBytes(Path.Combine(outputPath.FullName, "Sample.json")));
+ var result = OpenApiDocument.Load(stream, "json");
+ // TODO: Needs https://github.com/microsoft/OpenAPI.NET/issues/2055 to be fixed
+ // Assert.Empty(result.Diagnostic.Errors);
+ Assert.Equal(OpenApiSpecVersion.OpenApi2_0, result.Diagnostic.SpecificationVersion);
+ Assert.Equal("GetDocumentSample | v1", result.Document.Info.Title);
}
[Fact]
@@ -90,11 +92,12 @@ public void GetDocument_WithInvalidOpenApiVersion_Errors()
// Assert that error was produced and files were generated with v3.
Assert.Contains("Invalid OpenAPI spec version 'OpenApi4_0' provided. Falling back to default: v3.0.", _console.GetOutput());
- var result = OpenApiDocument.Load(File.OpenRead(Path.Combine(outputPath.FullName, "Sample.json")), "json");
- // TODO: https://github.com/microsoft/OpenAPI.NET/issues/1991
- // Assert.Empty(result.OpenApiDiagnostic.Errors);
- Assert.Equal(OpenApiSpecVersion.OpenApi3_1, result.OpenApiDiagnostic.SpecificationVersion);
- Assert.Equal("GetDocumentSample | v1", result.OpenApiDocument.Info.Title);
+ using var stream = new MemoryStream(File.ReadAllBytes(Path.Combine(outputPath.FullName, "Sample.json")));
+ var result = OpenApiDocument.Load(stream, "json");
+ // TODO: Needs https://github.com/microsoft/OpenAPI.NET/issues/2055 to be fixed
+ // Assert.Empty(result.Diagnostic.Errors);
+ Assert.Equal(OpenApiSpecVersion.OpenApi3_1, result.Diagnostic.SpecificationVersion);
+ Assert.Equal("GetDocumentSample | v1", result.Document.Info.Title);
}
[Fact]
@@ -123,12 +126,13 @@ public void GetDocument_WithDocumentName_Works()
Assert.Single(documentNames);
Assert.Contains(expectedDocumentPath, documentNames);
- var result = OpenApiDocument.Load(File.OpenRead(Path.Combine(outputPath.FullName, "Sample_internal.json")), "json");
- // TODO: https://github.com/microsoft/OpenAPI.NET/issues/1991
- // Assert.Empty(result.OpenApiDiagnostic.Errors);
- Assert.Equal(OpenApiSpecVersion.OpenApi3_1, result.OpenApiDiagnostic.SpecificationVersion);
+ using var stream = new MemoryStream(File.ReadAllBytes(Path.Combine(outputPath.FullName, "Sample_internal.json")));
+ var result = OpenApiDocument.Load(stream, "json");
+ // TODO: Needs https://github.com/microsoft/OpenAPI.NET/issues/2055 to be fixed
+ // Assert.Empty(result.Diagnostic.Errors);
+ Assert.Equal(OpenApiSpecVersion.OpenApi3_1, result.Diagnostic.SpecificationVersion);
// Document name in the title gives us a clue that the correct document was actually resolved
- Assert.Equal("GetDocumentSample | internal", result.OpenApiDocument.Info.Title);
+ Assert.Equal("GetDocumentSample | internal", result.Document.Info.Title);
}
[Fact]