From fb3ef51b221f614d64f72d67f0644a673b959b3c Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Wed, 12 Feb 2025 16:08:41 -1000 Subject: [PATCH 1/2] Add OpenAPI --- aspnetcore/release-notes/aspnetcore-10.0.md | 51 +++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/aspnetcore/release-notes/aspnetcore-10.0.md b/aspnetcore/release-notes/aspnetcore-10.0.md index 3c8422189e58..a7ea58cee1a8 100644 --- a/aspnetcore/release-notes/aspnetcore-10.0.md +++ b/aspnetcore/release-notes/aspnetcore-10.0.md @@ -29,6 +29,57 @@ This section describes new features for SignalR. This section describes new features for minimal APIs. +## OpenAPI + +This section describes new features for OpenAPI. + +### Breaking changes + +Support for OpenAPI 3.1 requires an update to the underlying OpenAPI.NET library to a new major version, 2.0. +This new version has some breaking changes from the previous version, and this may impact your applications +if you have any document, operation, or schema transformers. +Perhaps the most significant change is that the `OpenApiAny` class has been dropped in favor of using `JsonNode` directly. +If your transformers use `OpenApiAny`, you will need to update them to use `JsonNode` instead. +For example, a schema transformer to add an example in .NET 9 might look like this: + +```csharp + options.AddSchemaTransformer((schema, context, cancellationToken) => + { + if (context.JsonTypeInfo.Type == typeof(WeatherForecast)) + { + schema.Example = new OpenApiObject + { + ["date"] = new OpenApiString(DateTime.Now.AddDays(1).ToString("yyyy-MM-dd")), + ["temperatureC"] = new OpenApiInteger(0), + ["temperatureF"] = new OpenApiInteger(32), + ["summary"] = new OpenApiString("Bracing"), + }; + } + return Task.CompletedTask; + }); +``` + +In .NET 10 the transformer to do the same task will look like this: + +```csharp + options.AddSchemaTransformer((schema, context, cancellationToken) => + { + if (context.JsonTypeInfo.Type == typeof(WeatherForecast)) + { + schema.Example = new JsonObject + { + ["date"] = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"), + ["temperatureC"] = 0, + ["temperatureF"] = 32, + ["summary"] = "Bracing", + }; + } + return Task.CompletedTask; + }); +``` + +Note that these changes will be necessary even if you congfigure the OpenAPI version to 3.0. + ## Authentication and authorization This section describes new features for authentication and authorization. From 6f73709120da00c13a92b2dffcf122fe0b580cb2 Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Wed, 12 Feb 2025 16:10:07 -1000 Subject: [PATCH 2/2] Add OpenAPI --- aspnetcore/release-notes/aspnetcore-10.0.md | 47 --------------------- 1 file changed, 47 deletions(-) diff --git a/aspnetcore/release-notes/aspnetcore-10.0.md b/aspnetcore/release-notes/aspnetcore-10.0.md index a7ea58cee1a8..e84c0a44a482 100644 --- a/aspnetcore/release-notes/aspnetcore-10.0.md +++ b/aspnetcore/release-notes/aspnetcore-10.0.md @@ -33,53 +33,6 @@ This section describes new features for minimal APIs. This section describes new features for OpenAPI. -### Breaking changes - -Support for OpenAPI 3.1 requires an update to the underlying OpenAPI.NET library to a new major version, 2.0. -This new version has some breaking changes from the previous version, and this may impact your applications -if you have any document, operation, or schema transformers. -Perhaps the most significant change is that the `OpenApiAny` class has been dropped in favor of using `JsonNode` directly. -If your transformers use `OpenApiAny`, you will need to update them to use `JsonNode` instead. -For example, a schema transformer to add an example in .NET 9 might look like this: - -```csharp - options.AddSchemaTransformer((schema, context, cancellationToken) => - { - if (context.JsonTypeInfo.Type == typeof(WeatherForecast)) - { - schema.Example = new OpenApiObject - { - ["date"] = new OpenApiString(DateTime.Now.AddDays(1).ToString("yyyy-MM-dd")), - ["temperatureC"] = new OpenApiInteger(0), - ["temperatureF"] = new OpenApiInteger(32), - ["summary"] = new OpenApiString("Bracing"), - }; - } - return Task.CompletedTask; - }); -``` - -In .NET 10 the transformer to do the same task will look like this: - -```csharp - options.AddSchemaTransformer((schema, context, cancellationToken) => - { - if (context.JsonTypeInfo.Type == typeof(WeatherForecast)) - { - schema.Example = new JsonObject - { - ["date"] = DateTime.Now.AddDays(1).ToString("yyyy-MM-dd"), - ["temperatureC"] = 0, - ["temperatureF"] = 32, - ["summary"] = "Bracing", - }; - } - return Task.CompletedTask; - }); -``` - -Note that these changes will be necessary even if you congfigure the OpenAPI version to 3.0. - ## Authentication and authorization This section describes new features for authentication and authorization.