You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: release-notes/10.0/preview/preview3/aspnetcore.md
+126Lines changed: 126 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ Here's a summary of what's new in ASP.NET Core in this preview release:
10
10
-[Validation support in minimal APIs](#validation-support-in-minimal-apis)
11
11
-[OpenAPI support enabled by default in the ASP.NET Core Web API (native AOT) template](#openapi-support-enabled-by-default-in-the-aspnet-core-web-api-native-aot-template)
12
12
-[Support for Server-Sent Events (SSE)](#support-for-server-sent-events-sse)
The new `AddOpenApiOperationTransformer` API makes it easier to customize OpenAPI documentation for your ASP.NET Core endpoints. This API allows you to register custom operation transformers, which modify OpenAPI operation definitions programmatically.
267
+
This feature reduces the need for manual intervention or external tools, streamlining the API documentation process.
268
+
269
+
### Key Features
270
+
271
+
-**Targeted Transformations**: Use custom or predefined logic to modify individual OpenAPI operations.
272
+
-**Support for Multiple Transformers**: Chain multiple transformers to apply different transformations sequentially.
273
+
274
+
#### Example: Custom transformer
275
+
276
+
Here’s how you can use the `AddOpenApiOperationTransformer` extension method with a custom transformer:
operation.Description="This endpoint returns a greeting message.";
286
+
returnTask.CompletedTask;
287
+
});
288
+
289
+
app.Run();
290
+
```
291
+
292
+
#### Example: Predefined and chained transformers
293
+
294
+
You can also create predefined transformers that you can use on multiple endpoints. These are defined as extension methods on `RouteHandlerBuilder`, and return a `RouteHandlerBuilder` so they can be chained with other methods like `WithName`, `WithTags`, and other operation transformers.
295
+
Some example use cases are a transformer to add a description for a specific response code, or a transformer to add a response header.
0 commit comments