diff --git a/eng/Versions.props b/eng/Versions.props index 5cef785a6257..ed056a7a6f7c 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -325,8 +325,8 @@ $(XunitVersion) 2.8.2 5.2.2 - 2.0.0-preview.17 - 2.0.0-preview.17 + 2.0.0-preview.18 + 2.0.0-preview.18 6.0.322601 1.10.93 diff --git a/src/OpenApi/gen/XmlCommentGenerator.Emitter.cs b/src/OpenApi/gen/XmlCommentGenerator.Emitter.cs index 6b6e7139e373..9dca2b991008 100644 --- a/src/OpenApi/gen/XmlCommentGenerator.Emitter.cs +++ b/src/OpenApi/gen/XmlCommentGenerator.Emitter.cs @@ -61,7 +61,6 @@ namespace Microsoft.AspNetCore.OpenApi.Generated using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; - using Microsoft.OpenApi.Any; {{GeneratedCodeAttribute}} file record XmlComment( diff --git a/src/OpenApi/perf/Microbenchmarks/TransformersBenchmark.cs b/src/OpenApi/perf/Microbenchmarks/TransformersBenchmark.cs index b9c3267ca07f..dc7a78d517d7 100644 --- a/src/OpenApi/perf/Microbenchmarks/TransformersBenchmark.cs +++ b/src/OpenApi/perf/Microbenchmarks/TransformersBenchmark.cs @@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Routing; using Microsoft.Extensions.DependencyInjection; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; namespace Microsoft.AspNetCore.OpenApi.Microbenchmarks; @@ -105,11 +105,11 @@ public void SchemaTransformer_Setup() schema.Extensions ??= []; if (context.JsonTypeInfo.Type == typeof(Todo) && context.ParameterDescription != null) { - schema.Extensions["x-my-extension"] = new OpenApiAny(context.ParameterDescription.Name); + schema.Extensions["x-my-extension"] = new JsonNodeExtension(context.ParameterDescription.Name); } else { - schema.Extensions["x-my-extension"] = new OpenApiAny("response"); + schema.Extensions["x-my-extension"] = new JsonNodeExtension("response"); } return Task.CompletedTask; }); @@ -179,11 +179,11 @@ public Task TransformAsync(OpenApiSchema schema, OpenApiSchemaTransformerContext schema.Extensions ??= []; if (context.JsonTypeInfo.Type == typeof(Todo) && context.ParameterDescription != null) { - schema.Extensions["x-my-extension"] = new OpenApiAny(context.ParameterDescription.Name); + schema.Extensions["x-my-extension"] = new JsonNodeExtension(context.ParameterDescription.Name); } else { - schema.Extensions["x-my-extension"] = new OpenApiAny("response"); + schema.Extensions["x-my-extension"] = new JsonNodeExtension("response"); } return Task.CompletedTask; } diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/AddOpenApiTests.CanInterceptAddOpenApi#OpenApiXmlCommentSupport.generated.verified.cs b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/AddOpenApiTests.CanInterceptAddOpenApi#OpenApiXmlCommentSupport.generated.verified.cs index 3d2702fbe1f1..0d3d206fec8b 100644 --- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/AddOpenApiTests.CanInterceptAddOpenApi#OpenApiXmlCommentSupport.generated.verified.cs +++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/AddOpenApiTests.CanInterceptAddOpenApi#OpenApiXmlCommentSupport.generated.verified.cs @@ -43,7 +43,6 @@ namespace Microsoft.AspNetCore.OpenApi.Generated using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; - using Microsoft.OpenApi.Any; [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.AspNetCore.OpenApi.SourceGenerators, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60", "42.42.42.42")] file record XmlComment( diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/AdditionalTextsTests.CanHandleXmlForSchemasInAdditionalTexts#OpenApiXmlCommentSupport.generated.verified.cs b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/AdditionalTextsTests.CanHandleXmlForSchemasInAdditionalTexts#OpenApiXmlCommentSupport.generated.verified.cs index 945ae11f52cf..b876791c8100 100644 --- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/AdditionalTextsTests.CanHandleXmlForSchemasInAdditionalTexts#OpenApiXmlCommentSupport.generated.verified.cs +++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/AdditionalTextsTests.CanHandleXmlForSchemasInAdditionalTexts#OpenApiXmlCommentSupport.generated.verified.cs @@ -43,7 +43,6 @@ namespace Microsoft.AspNetCore.OpenApi.Generated using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; - using Microsoft.OpenApi.Any; [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.AspNetCore.OpenApi.SourceGenerators, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60", "42.42.42.42")] file record XmlComment( diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/CompletenessTests.SupportsAllXmlTagsOnSchemas#OpenApiXmlCommentSupport.generated.verified.cs b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/CompletenessTests.SupportsAllXmlTagsOnSchemas#OpenApiXmlCommentSupport.generated.verified.cs index 391c98725057..a9b36cb7daea 100644 --- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/CompletenessTests.SupportsAllXmlTagsOnSchemas#OpenApiXmlCommentSupport.generated.verified.cs +++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/CompletenessTests.SupportsAllXmlTagsOnSchemas#OpenApiXmlCommentSupport.generated.verified.cs @@ -43,7 +43,6 @@ namespace Microsoft.AspNetCore.OpenApi.Generated using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; - using Microsoft.OpenApi.Any; [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.AspNetCore.OpenApi.SourceGenerators, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60", "42.42.42.42")] file record XmlComment( diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsXmlCommentsOnOperationsFromControllers#OpenApiXmlCommentSupport.generated.verified.cs b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsXmlCommentsOnOperationsFromControllers#OpenApiXmlCommentSupport.generated.verified.cs index 2b2e1e1d01fe..7905cbba9514 100644 --- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsXmlCommentsOnOperationsFromControllers#OpenApiXmlCommentSupport.generated.verified.cs +++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsXmlCommentsOnOperationsFromControllers#OpenApiXmlCommentSupport.generated.verified.cs @@ -43,7 +43,6 @@ namespace Microsoft.AspNetCore.OpenApi.Generated using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; - using Microsoft.OpenApi.Any; [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.AspNetCore.OpenApi.SourceGenerators, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60", "42.42.42.42")] file record XmlComment( diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsXmlCommentsOnOperationsFromMinimalApis#OpenApiXmlCommentSupport.generated.verified.cs b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsXmlCommentsOnOperationsFromMinimalApis#OpenApiXmlCommentSupport.generated.verified.cs index 3ee9ad39a98a..301db6afae05 100644 --- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsXmlCommentsOnOperationsFromMinimalApis#OpenApiXmlCommentSupport.generated.verified.cs +++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/OperationTests.SupportsXmlCommentsOnOperationsFromMinimalApis#OpenApiXmlCommentSupport.generated.verified.cs @@ -43,7 +43,6 @@ namespace Microsoft.AspNetCore.OpenApi.Generated using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; - using Microsoft.OpenApi.Any; [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.AspNetCore.OpenApi.SourceGenerators, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60", "42.42.42.42")] file record XmlComment( diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/SchemaTests.SupportsXmlCommentsOnSchemas#OpenApiXmlCommentSupport.generated.verified.cs b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/SchemaTests.SupportsXmlCommentsOnSchemas#OpenApiXmlCommentSupport.generated.verified.cs index ae28560f6351..8f57fda92e1b 100644 --- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/SchemaTests.SupportsXmlCommentsOnSchemas#OpenApiXmlCommentSupport.generated.verified.cs +++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/snapshots/SchemaTests.SupportsXmlCommentsOnSchemas#OpenApiXmlCommentSupport.generated.verified.cs @@ -43,7 +43,6 @@ namespace Microsoft.AspNetCore.OpenApi.Generated using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.Interfaces; using Microsoft.OpenApi.Models.References; - using Microsoft.OpenApi.Any; [System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.AspNetCore.OpenApi.SourceGenerators, Version=42.42.42.42, Culture=neutral, PublicKeyToken=adb9793829ddae60", "42.42.42.42")] file record XmlComment( diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.PolymorphicSchemas.cs b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.PolymorphicSchemas.cs index a222c5e3083a..ab21291453ab 100644 --- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.PolymorphicSchemas.cs +++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.PolymorphicSchemas.cs @@ -3,7 +3,7 @@ using System.Net.Http; using Microsoft.AspNetCore.Builder; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.RequestBodySchemas.cs b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.RequestBodySchemas.cs index 9d2576b8cbf7..5eb02fb12744 100644 --- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.RequestBodySchemas.cs +++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.RequestBodySchemas.cs @@ -10,7 +10,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Mvc; using Microsoft.Extensions.DependencyInjection; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.ResponseSchemas.cs b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.ResponseSchemas.cs index a59bfb28d1d5..ac92e52bce02 100644 --- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.ResponseSchemas.cs +++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.ResponseSchemas.cs @@ -7,7 +7,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; public partial class OpenApiSchemaServiceTests : OpenApiDocumentServiceTestBase diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/CustomSchemaTransformerTests.cs b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/CustomSchemaTransformerTests.cs index 9a98cd71ec0f..aff3182bd2ea 100644 --- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/CustomSchemaTransformerTests.cs +++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/CustomSchemaTransformerTests.cs @@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.OpenApi; using Microsoft.Extensions.DependencyInjection; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; @@ -159,7 +159,7 @@ public async Task GetOrCreateSchema_CanBeUsedInSchemaTransformer() // Add a reference to the example in the shape schema schema.Extensions ??= []; - schema.Extensions["x-example-component"] = new OpenApiAny("#/components/schemas/TriangleExample"); + schema.Extensions["x-example-component"] = new JsonNodeExtension("#/components/schemas/TriangleExample"); schema.Description = "A shape with an example reference"; } }); diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/Implementations/OpenApiSchemaReferenceTransformerTests.cs b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/Implementations/OpenApiSchemaReferenceTransformerTests.cs index 2fa5cce2989d..603007c0a083 100644 --- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/Implementations/OpenApiSchemaReferenceTransformerTests.cs +++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/Implementations/OpenApiSchemaReferenceTransformerTests.cs @@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.OpenApi; using Microsoft.Extensions.DependencyInjection; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; using Microsoft.OpenApi.Writers; @@ -287,7 +287,7 @@ public async Task TypeModifiedWithSchemaTransformerMapsToDifferentReferenceId() if (context.JsonTypeInfo.Type == typeof(Todo) && context.ParameterDescription is not null) { schema.Extensions ??= []; - schema.Extensions["x-my-extension"] = new OpenApiAny(context.ParameterDescription.Name); + schema.Extensions["x-my-extension"] = new JsonNodeExtension(context.ParameterDescription.Name); } return Task.CompletedTask; }); @@ -301,7 +301,7 @@ await VerifyOpenApiDocument(builder, options, document => var responseSchema = getOperation.Responses["200"].Content["application/json"].Schema; // Schemas are distinct because of applied transformer so no reference is used. Assert.NotEqual(((OpenApiSchemaReference)requestSchema).Reference.Id, ((OpenApiSchemaReference)responseSchema).Reference.Id); - Assert.Equal("todo", ((OpenApiAny)requestSchema.Extensions["x-my-extension"]).Node.GetValue()); + Assert.Equal("todo", ((JsonNodeExtension)requestSchema.Extensions["x-my-extension"]).Node.GetValue()); Assert.False(responseSchema.Extensions.TryGetValue("x-my-extension", out var _)); }); } diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/SchemaTransformerTests.cs b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/SchemaTransformerTests.cs index 6cc281bf6b9a..bed6a02e50f2 100644 --- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/SchemaTransformerTests.cs +++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/SchemaTransformerTests.cs @@ -8,7 +8,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.OpenApi; using Microsoft.Extensions.DependencyInjection; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Models.References; @@ -156,15 +156,15 @@ public async Task SchemaTransformer_RunsInRegisteredOrder() options.AddSchemaTransformer((schema, context, cancellationToken) => { schema.Extensions ??= []; - schema.Extensions["x-my-extension"] = new OpenApiAny("1"); + schema.Extensions["x-my-extension"] = new JsonNodeExtension("1"); schema.Format = "1"; return Task.CompletedTask; }); options.AddSchemaTransformer((schema, context, cancellationToken) => { schema.Extensions ??= []; - Assert.Equal("1", ((OpenApiAny)schema.Extensions["x-my-extension"]).Node.GetValue()); - schema.Extensions["x-my-extension"] = new OpenApiAny("2"); + Assert.Equal("1", ((JsonNodeExtension)schema.Extensions["x-my-extension"]).Node.GetValue()); + schema.Extensions["x-my-extension"] = new JsonNodeExtension("2"); return Task.CompletedTask; }); @@ -172,7 +172,7 @@ await VerifyOpenApiDocument(builder, options, document => { var operation = Assert.Single(document.Paths.Values).Operations.Values.Single(); var schema = operation.RequestBody.Content["application/json"].Schema; - Assert.Equal("2", ((OpenApiAny)schema.Extensions["x-my-extension"]).Node.GetValue()); + Assert.Equal("2", ((JsonNodeExtension)schema.Extensions["x-my-extension"]).Node.GetValue()); }); } @@ -190,7 +190,7 @@ public async Task SchemaTransformer_OnTypeModifiesBothRequestAndResponse() if (context.JsonTypeInfo.Type == typeof(Todo)) { schema.Extensions ??= []; - schema.Extensions["x-my-extension"] = new OpenApiAny("1"); + schema.Extensions["x-my-extension"] = new JsonNodeExtension("1"); } return Task.CompletedTask; }); @@ -200,10 +200,10 @@ await VerifyOpenApiDocument(builder, options, document => var path = Assert.Single(document.Paths.Values); var postOperation = path.Operations[HttpMethod.Post]; var requestSchema = postOperation.RequestBody.Content["application/json"].Schema; - Assert.Equal("1", ((OpenApiAny)requestSchema.Extensions["x-my-extension"]).Node.GetValue()); + Assert.Equal("1", ((JsonNodeExtension)requestSchema.Extensions["x-my-extension"]).Node.GetValue()); var getOperation = path.Operations[HttpMethod.Get]; var responseSchema = getOperation.Responses["200"].Content["application/json"].Schema; - Assert.Equal("1", ((OpenApiAny)responseSchema.Extensions["x-my-extension"]).Node.GetValue()); + Assert.Equal("1", ((JsonNodeExtension)responseSchema.Extensions["x-my-extension"]).Node.GetValue()); }); } @@ -220,7 +220,7 @@ public async Task SchemaTransformer_WithDescriptionOnlyModifiesParameter() { if (context.JsonTypeInfo.Type == typeof(Todo) && context.ParameterDescription is not null) { - schema.Extensions["x-my-extension"] = new OpenApiAny(context.ParameterDescription.Name); + schema.Extensions["x-my-extension"] = new JsonNodeExtension(context.ParameterDescription.Name); } return Task.CompletedTask; }); @@ -230,7 +230,7 @@ await VerifyOpenApiDocument(builder, options, document => var path = Assert.Single(document.Paths.Values); var postOperation = path.Operations[HttpMethod.Post]; var requestSchema = postOperation.RequestBody.Content["application/json"].Schema; - Assert.Equal("todo", ((OpenApiAny)requestSchema.Extensions["x-my-extension"]).Node.GetValue()); + Assert.Equal("todo", ((JsonNodeExtension)requestSchema.Extensions["x-my-extension"]).Node.GetValue()); var getOperation = path.Operations[HttpMethod.Get]; var responseSchema = getOperation.Responses["200"].Content["application/json"].Schema; Assert.False(responseSchema.Extensions.TryGetValue("x-my-extension", out var _)); @@ -253,10 +253,10 @@ await VerifyOpenApiDocument(builder, options, document => var path = Assert.Single(document.Paths.Values); var postOperation = path.Operations[HttpMethod.Post]; var requestSchema = postOperation.RequestBody.Content["application/json"].Schema; - Assert.Equal("1", ((OpenApiAny)requestSchema.Extensions["x-my-extension"]).Node.GetValue()); + Assert.Equal("1", ((JsonNodeExtension)requestSchema.Extensions["x-my-extension"]).Node.GetValue()); var getOperation = path.Operations[HttpMethod.Get]; var responseSchema = getOperation.Responses["200"].Content["application/json"].Schema; - Assert.Equal("1", ((OpenApiAny)responseSchema.Extensions["x-my-extension"]).Node.GetValue()); + Assert.Equal("1", ((JsonNodeExtension)responseSchema.Extensions["x-my-extension"]).Node.GetValue()); }); } @@ -276,10 +276,10 @@ await VerifyOpenApiDocument(builder, options, document => var path = Assert.Single(document.Paths.Values); var postOperation = path.Operations[HttpMethod.Post]; var requestSchema = postOperation.RequestBody.Content["application/json"].Schema; - Assert.Equal("1", ((OpenApiAny)requestSchema.Extensions["x-my-extension"]).Node.GetValue()); + Assert.Equal("1", ((JsonNodeExtension)requestSchema.Extensions["x-my-extension"]).Node.GetValue()); var getOperation = path.Operations[HttpMethod.Get]; var responseSchema = getOperation.Responses["200"].Content["application/json"].Schema; - Assert.Equal("1", ((OpenApiAny)responseSchema.Extensions["x-my-extension"]).Node.GetValue()); + Assert.Equal("1", ((JsonNodeExtension)responseSchema.Extensions["x-my-extension"]).Node.GetValue()); }); } @@ -303,21 +303,21 @@ await VerifyOpenApiDocument(builder, options, document => var path = Assert.Single(document.Paths.Values); var postOperation = path.Operations[HttpMethod.Post]; var requestSchema = postOperation.RequestBody.Content["application/json"].Schema; - value = ((OpenApiAny)requestSchema.Extensions["x-my-extension"]).Node.GetValue(); + value = ((JsonNodeExtension)requestSchema.Extensions["x-my-extension"]).Node.GetValue(); Assert.Equal(Dependency.InstantiationCount.ToString(CultureInfo.InvariantCulture), value); var getOperation = path.Operations[HttpMethod.Get]; var responseSchema = getOperation.Responses["200"].Content["application/json"].Schema; - Assert.Equal(value, ((OpenApiAny)responseSchema.Extensions["x-my-extension"]).Node.GetValue()); + Assert.Equal(value, ((JsonNodeExtension)responseSchema.Extensions["x-my-extension"]).Node.GetValue()); }); await VerifyOpenApiDocument(builder, options, document => { var path = Assert.Single(document.Paths.Values); var postOperation = path.Operations[HttpMethod.Post]; var requestSchema = postOperation.RequestBody.Content["application/json"].Schema; - Assert.Equal(value, ((OpenApiAny)requestSchema.Extensions["x-my-extension"]).Node.GetValue()); + Assert.Equal(value, ((JsonNodeExtension)requestSchema.Extensions["x-my-extension"]).Node.GetValue()); var getOperation = path.Operations[HttpMethod.Get]; var responseSchema = getOperation.Responses["200"].Content["application/json"].Schema; - Assert.Equal(value, ((OpenApiAny)responseSchema.Extensions["x-my-extension"]).Node.GetValue()); + Assert.Equal(value, ((JsonNodeExtension)responseSchema.Extensions["x-my-extension"]).Node.GetValue()); }); } @@ -500,7 +500,7 @@ public async Task SchemaTransformer_CanModifyPolymorphicChildSchemas() if (context.JsonTypeInfo.Type == typeof(Triangle)) { schema.Extensions ??= []; - schema.Extensions["x-my-extension"] = new OpenApiAny("this-is-a-triangle"); + schema.Extensions["x-my-extension"] = new JsonNodeExtension("this-is-a-triangle"); } return Task.CompletedTask; }); @@ -518,7 +518,7 @@ await VerifyOpenApiDocument(builder, options, document => path = document.Paths["/triangle"]; postOperation = path.Operations[HttpMethod.Post]; requestSchema = postOperation.RequestBody.Content["application/json"].Schema; - Assert.Equal("this-is-a-triangle", ((OpenApiAny)requestSchema.Extensions["x-my-extension"]).Node.GetValue()); + Assert.Equal("this-is-a-triangle", ((JsonNodeExtension)requestSchema.Extensions["x-my-extension"]).Node.GetValue()); }); } @@ -571,11 +571,11 @@ public async Task SchemaTransformer_CanModifyListOfPolymorphicTypes() schema.Extensions ??= []; if (context.JsonTypeInfo.Type == typeof(Triangle)) { - schema.Extensions["x-my-extension"] = new OpenApiAny("this-is-a-triangle"); + schema.Extensions["x-my-extension"] = new JsonNodeExtension("this-is-a-triangle"); } if (context.JsonTypeInfo.Type == typeof(Square)) { - schema.Extensions["x-my-extension"] = new OpenApiAny("this-is-a-square"); + schema.Extensions["x-my-extension"] = new JsonNodeExtension("this-is-a-square"); } return Task.CompletedTask; }); @@ -590,13 +590,13 @@ await VerifyOpenApiDocument(builder, options, document => var triangleSubschema = Assert.Single(itemSchema.AnyOf.Where(s => ((OpenApiSchemaReference)s).Reference.Id == "ShapeTriangle")); // Assert that the x-my-extension type is set to this-is-a-triangle Assert.True(triangleSubschema.Extensions.TryGetValue("x-my-extension", out var triangleExtension)); - Assert.Equal("this-is-a-triangle", ((OpenApiAny)triangleExtension).Node.GetValue()); + Assert.Equal("this-is-a-triangle", ((JsonNodeExtension)triangleExtension).Node.GetValue()); // Assert that the `Square` type within the polymorphic type list has been updated var squareSubschema = Assert.Single(itemSchema.AnyOf.Where(s => ((OpenApiSchemaReference)s).Reference.Id == "ShapeSquare")); // Assert that the x-my-extension type is set to this-is-a-square Assert.True(squareSubschema.Extensions.TryGetValue("x-my-extension", out var squareExtension)); - Assert.Equal("this-is-a-square", ((OpenApiAny)squareExtension).Node.GetValue()); + Assert.Equal("this-is-a-square", ((JsonNodeExtension)squareExtension).Node.GetValue()); }); } @@ -613,11 +613,11 @@ public async Task SchemaTransformer_CanModifyPolymorphicTypesInProperties() schema.Extensions ??= []; if (context.JsonTypeInfo.Type == typeof(Triangle)) { - schema.Extensions["x-my-extension"] = new OpenApiAny("this-is-a-triangle"); + schema.Extensions["x-my-extension"] = new JsonNodeExtension("this-is-a-triangle"); } if (context.JsonTypeInfo.Type == typeof(Square)) { - schema.Extensions["x-my-extension"] = new OpenApiAny("this-is-a-square"); + schema.Extensions["x-my-extension"] = new JsonNodeExtension("this-is-a-square"); } return Task.CompletedTask; }); @@ -632,13 +632,13 @@ await VerifyOpenApiDocument(builder, options, document => var triangleSubschema = Assert.Single(someShapeSchema.AnyOf.Where(s => ((OpenApiSchemaReference)s).Reference.Id == "ShapeTriangle")); // Assert that the x-my-extension type is set to this-is-a-triangle Assert.True(triangleSubschema.Extensions.TryGetValue("x-my-extension", out var triangleExtension)); - Assert.Equal("this-is-a-triangle", ((OpenApiAny)triangleExtension).Node.GetValue()); + Assert.Equal("this-is-a-triangle", ((JsonNodeExtension)triangleExtension).Node.GetValue()); // Assert that the `Square` type within the polymorphic type list has been updated var squareSubschema = Assert.Single(someShapeSchema.AnyOf.Where(s => ((OpenApiSchemaReference)s).Reference.Id == "ShapeSquare")); // Assert that the x-my-extension type is set to this-is-a-square Assert.True(squareSubschema.Extensions.TryGetValue("x-my-extension", out var squareExtension)); - Assert.Equal("this-is-a-square", ((OpenApiAny)squareExtension).Node.GetValue()); + Assert.Equal("this-is-a-square", ((JsonNodeExtension)squareExtension).Node.GetValue()); }); } @@ -655,11 +655,11 @@ public async Task SchemaTransformer_CanModifyDeeplyNestedPolymorphicTypesInPrope schema.Extensions ??= []; if (context.JsonTypeInfo.Type == typeof(Triangle)) { - schema.Extensions["x-my-extension"] = new OpenApiAny("this-is-a-triangle"); + schema.Extensions["x-my-extension"] = new JsonNodeExtension("this-is-a-triangle"); } if (context.JsonTypeInfo.Type == typeof(Square)) { - schema.Extensions["x-my-extension"] = new OpenApiAny("this-is-a-square"); + schema.Extensions["x-my-extension"] = new JsonNodeExtension("this-is-a-square"); } return Task.CompletedTask; }); @@ -674,13 +674,13 @@ await VerifyOpenApiDocument(builder, options, document => var triangleSubschema = Assert.Single(someShapeSchema.AnyOf.Where(s => ((OpenApiSchemaReference)s).Reference.Id == "ShapeTriangle")); // Assert that the x-my-extension type is set to this-is-a-triangle Assert.True(triangleSubschema.Extensions.TryGetValue("x-my-extension", out var triangleExtension)); - Assert.Equal("this-is-a-triangle", ((OpenApiAny)triangleExtension).Node.GetValue()); + Assert.Equal("this-is-a-triangle", ((JsonNodeExtension)triangleExtension).Node.GetValue()); // Assert that the `Square` type within the polymorphic type list has been updated var squareSubschema = Assert.Single(someShapeSchema.AnyOf.Where(s => ((OpenApiSchemaReference)s).Reference.Id == "ShapeSquare")); // Assert that the x-my-extension type is set to this-is-a-square Assert.True(squareSubschema.Extensions.TryGetValue("x-my-extension", out var squareExtension)); - Assert.Equal("this-is-a-square", ((OpenApiAny)squareExtension).Node.GetValue()); + Assert.Equal("this-is-a-square", ((JsonNodeExtension)squareExtension).Node.GetValue()); }); } @@ -742,7 +742,7 @@ public async Task SchemaTransformers_CanImplementNotSchemaIndependently() UseNotSchemaTransformer(options, (schema, context, cancellationToken) => { schema.Extensions ??= []; - schema.Extensions["modified-by-not-schema-transformer"] = new OpenApiAny(true); + schema.Extensions["modified-by-not-schema-transformer"] = new JsonNodeExtension(true); return Task.CompletedTask; }); @@ -752,13 +752,13 @@ await VerifyOpenApiDocument(builder, options, document => var path = document.Paths["/todo"]; var getOperation = path.Operations[HttpMethod.Get]; var responseSchema = getOperation.Responses["200"].Content["application/json"].Schema; - Assert.True(((OpenApiAny)responseSchema.Not.Extensions["modified-by-not-schema-transformer"]).Node.GetValue()); + Assert.True(((JsonNodeExtension)responseSchema.Not.Extensions["modified-by-not-schema-transformer"]).Node.GetValue()); var shapePath = document.Paths["/shape"]; var shapeOperation = shapePath.Operations[HttpMethod.Post]; var shapeRequestSchema = shapeOperation.RequestBody.Content["application/json"].Schema; var triangleSchema = Assert.Single(shapeRequestSchema.AnyOf.Where(s => ((OpenApiSchemaReference)s).Reference.Id == "ShapeTriangle")); - Assert.True(((OpenApiAny)triangleSchema.Not.Extensions["modified-by-not-schema-transformer"]).Node.GetValue()); + Assert.True(((JsonNodeExtension)triangleSchema.Not.Extensions["modified-by-not-schema-transformer"]).Node.GetValue()); }); static void UseNotSchemaTransformer(OpenApiOptions options, Func func) @@ -958,7 +958,7 @@ public Task TransformAsync(OpenApiSchema schema, OpenApiSchemaTransformerContext if (context.JsonTypeInfo.Type == typeof(Todo)) { schema.Extensions ??= []; - schema.Extensions["x-my-extension"] = new OpenApiAny("1"); + schema.Extensions["x-my-extension"] = new JsonNodeExtension("1"); } return Task.CompletedTask; } @@ -1007,7 +1007,7 @@ public Task TransformAsync(OpenApiSchema schema, OpenApiSchemaTransformerContext { dependency.TestMethod(); schema.Extensions ??= []; - schema.Extensions["x-my-extension"] = new OpenApiAny(Dependency.InstantiationCount.ToString(CultureInfo.InvariantCulture)); + schema.Extensions["x-my-extension"] = new JsonNodeExtension(Dependency.InstantiationCount.ToString(CultureInfo.InvariantCulture)); return Task.CompletedTask; } } diff --git a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/TypeBasedTransformerLifetimeTests.cs b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/TypeBasedTransformerLifetimeTests.cs index 0a4c67087977..8f343a95d51f 100644 --- a/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/TypeBasedTransformerLifetimeTests.cs +++ b/src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Transformers/TypeBasedTransformerLifetimeTests.cs @@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.OpenApi; using Microsoft.Extensions.DependencyInjection; -using Microsoft.OpenApi.Any; +using Microsoft.OpenApi.Extensions; using Microsoft.OpenApi.Models; public class TypeBasedTransformerLifetimeTests : OpenApiDocumentServiceTestBase @@ -349,7 +349,7 @@ public Task TransformAsync(OpenApiSchema schema, OpenApiSchemaTransformerContext if (context.JsonTypeInfo.Type == typeof(Todo)) { schema.Extensions ??= []; - schema.Extensions["x-my-extension"] = new OpenApiAny("1"); + schema.Extensions["x-my-extension"] = new JsonNodeExtension("1"); } return Task.CompletedTask; }