-
Notifications
You must be signed in to change notification settings - Fork 825
Update Open API document generation documentation to use Microsoft.AspNetCore.OpenApi (CMS 18.0)
#8021
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update Open API document generation documentation to use Microsoft.AspNetCore.OpenApi (CMS 18.0)
#8021
Changes from 10 commits
eaccc2a
ef567f7
c61c752
431a75e
9fea065
0f8a284
6a3b49d
3070883
4a456c5
67d829e
a5e2a84
97578c9
75764e9
34b59fc
a6c7a4c
8168e00
9322dae
fb894ad
b8ef878
c4ea685
bf392c7
d9419cd
04855b3
f3f59ab
6ce8224
e43c6ba
d6bdadd
701a067
5d579d2
ea0dbae
a5b5f50
6df2238
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,7 +21,122 @@ Use the [general upgrade guide](../) to complete the upgrade of your project. | |
|
|
||
| <summary>Umbraco 18</summary> | ||
|
|
||
| *Add details about breaking changes in Umbraco 18 here.* | ||
| **Swashbuckle replaced with Microsoft.AspNetCore.OpenApi** | ||
|
|
||
| Umbraco no longer uses Swashbuckle for OpenAPI documentation. It has been replaced with [Microsoft.AspNetCore.OpenApi](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/openapi/overview). | ||
|
|
||
| If you have custom APIs with OpenAPI documentation, you will need to update your code. | ||
|
|
||
| *Registering OpenAPI documents* | ||
|
|
||
| Replace `IConfigureOptions<SwaggerGenOptions>` with `AddOpenApi()`. This can be done in `Program.cs` or in a composer. See [Adding your own OpenAPI documents](../../../../reference/api-versioning-and-openapi.md#adding-your-own-openapi-documents) for details. | ||
|
|
||
| Before: | ||
|
|
||
| ```csharp | ||
| public class MyApiConfigureSwaggerGenOptions : IConfigureOptions<SwaggerGenOptions> | ||
| { | ||
| public void Configure(SwaggerGenOptions options) | ||
| { | ||
| options.SwaggerDoc("my-api-v1", new OpenApiInfo { Title = "My API v1", Version = "1.0" }); | ||
| } | ||
| } | ||
|
|
||
| // In a composer: | ||
| builder.Services.ConfigureOptions<MyApiConfigureSwaggerGenOptions>(); | ||
| ``` | ||
|
|
||
| After: | ||
|
|
||
| ```csharp | ||
| // In Program.cs or a composer: | ||
| builder.Services.AddOpenApi("my-api-v1", options => | ||
| { | ||
| options.AddDocumentTransformer((document, context, cancellationToken) => | ||
| { | ||
| document.Info.Title = "My API v1"; | ||
| document.Info.Version = "1.0"; | ||
| return Task.CompletedTask; | ||
| }); | ||
| }); | ||
|
|
||
| // Add the document to the Swagger UI dropdown | ||
| builder.Services.AddOpenApiDocumentToUi("my-api-v1", "My API v1"); | ||
| ``` | ||
|
|
||
| Note that `AddOpenApiDocumentToUi()` is required to show the document in Swagger UI. Previously with Swashbuckle, documents were automatically added to the UI when registered. The second parameter (title) is optional and defaults to the document name if not specified. | ||
|
|
||
| *Backoffice security requirements* | ||
|
|
||
| Replace `BackOfficeSecurityRequirementsOperationFilterBase` with the `AddBackofficeSecurityRequirements()` extension method. See [Custom Backoffice API](../../../../reference/custom-backoffice-api.md) for a complete example. | ||
|
|
||
| Before: | ||
|
|
||
| ```csharp | ||
| public class MyApiSecurityRequirementsOperationFilter : BackOfficeSecurityRequirementsOperationFilterBase | ||
| { | ||
| protected override string ApiName => "my-api-v1"; | ||
| } | ||
|
|
||
| options.OperationFilter<MyApiSecurityRequirementsOperationFilter>(); | ||
| ``` | ||
|
|
||
| After: | ||
|
|
||
| ```csharp | ||
| builder.Services.AddOpenApi("my-api-v1", options => | ||
| { | ||
| options.AddBackofficeSecurityRequirements(); | ||
| }); | ||
| ``` | ||
|
|
||
| *Schema ID handlers* | ||
|
|
||
| The `ISchemaIdHandler` interface and `SchemaIdHandler` base class have been removed. Use `CreateSchemaReferenceId` on `OpenApiOptions` instead. See [Adding custom schema IDs](../../../../reference/api-versioning-and-openapi.md#adding-custom-schema-ids) for details. | ||
|
|
||
| *Operation ID handlers* | ||
|
|
||
| The `IOperationIdHandler` interface and `OperationIdHandler` base class have been removed. Use `IOpenApiOperationTransformer` instead. See [Adding custom operation IDs](../../../../reference/api-versioning-and-openapi.md#adding-custom-operation-ids) for details. | ||
|
|
||
| *Delivery API member authentication* | ||
|
|
||
| The class `ConfigureUmbracoMemberAuthenticationDeliveryApiSwaggerGenOptions` has been removed. Use the `AddDeliveryApiOpenApiMemberAuthentication()` extension method to add member authentication support to the Delivery API OpenAPI document: | ||
|
|
||
| ```csharp | ||
| using Umbraco.Cms.Api.Delivery.OpenApi; | ||
|
|
||
| builder.Services.AddDeliveryApiOpenApiMemberAuthentication(); | ||
| ``` | ||
|
|
||
| For more details, see [Testing with Swagger](../../../../reference/content-delivery-api/protected-content-in-the-delivery-api/README.md#testing-with-swagger). | ||
|
|
||
| *OpenAPI route and availability configuration* | ||
|
|
||
| If you were previously overriding the `OpenApiRouteTemplatePipelineFilter` methods (`OpenApiIsEnabled`, `OpenApiRouteTemplate`, or `OpenApiUiRoutePrefix`) to customize OpenAPI routes or availability, you should migrate to using `UmbracoOpenApiOptions` instead. The pipeline filter methods are now private implementation details. | ||
|
|
||
| Use `PostConfigure` to override the defaults: | ||
|
|
||
| ```csharp | ||
| builder.Services.PostConfigure<UmbracoOpenApiOptions>(options => | ||
| { | ||
| options.Enabled = true; | ||
| options.RouteTemplate = "openapi/{documentName}.json"; | ||
| options.UiRoutePrefix = "openapi"; | ||
| }); | ||
| ``` | ||
|
|
||
| See [OpenAPI route and/or availability](../../../../reference/api-versioning-and-openapi.md#openapi-route-andor-availability) for details. | ||
|
|
||
| *OpenAPI URL changes* | ||
|
|
||
| The OpenAPI endpoints have been renamed from "swagger" to "openapi" to follow Microsoft's naming conventions: | ||
|
lauraneto marked this conversation as resolved.
Outdated
|
||
|
|
||
| | Old URL | New URL | | ||
| |---------|---------| | ||
| | `/umbraco/swagger` | `/umbraco/openapi` | | ||
| | `/umbraco/swagger/{documentName}/swagger.json` | `/umbraco/openapi/{documentName}.json` | | ||
|
|
||
| For more details, see the [API versioning and OpenAPI](../../../../reference/api-versioning-and-openapi.md) article. | ||
|
|
||
| </details> | ||
|
|
||
|
|
@@ -453,7 +568,7 @@ This configuration will no longer have an effect. | |
|
|
||
| Notifications have changed their behavior to an extent. You can still implement notifications such as `ContentSavingNotification` to react to changes for related systems or add messages to be shown in the Backoffice. You can no longer modify the models being transferred through the API. | ||
|
|
||
| If you wish to modify the Backoffice UI, register the extensions through the manifest system that hook on to the desired areas of the Backoffice UI. If you used to modify the models because you needed more data on the models, it's recommended that you build your own API controller to achieve this. You can read more about [building custom API controllers on the Umbraco Documentation](https://docs.umbraco.com/umbraco-cms/reference/custom-swagger-api) and even learn how to register your controllers in the Swagger UI. | ||
| If you wish to modify the Backoffice UI, register the extensions through the manifest system that hook on to the desired areas of the Backoffice UI. If you used to modify the models because you needed more data on the models, it's recommended that you build your own API controller to achieve this. You can read more about [building custom API controllers on the Umbraco Documentation](https://docs.umbraco.com/umbraco-cms/reference/custom-backoffice-api) and even learn how to register your controllers in Swagger UI. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| * **Property editors have been split in two** | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.