-
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
Merged
Merged
Update Open API document generation documentation to use Microsoft.AspNetCore.OpenApi (CMS 18.0)
#8021
Changes from 11 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
eaccc2a
Update documentation for Microsoft.AspNetCore.OpenApi
lauraneto ef567f7
Add Umbraco 18 upgrade notes for OpenAPI changes
lauraneto c61c752
Add documentation for ExcludeFromDefaultOpenApiDocument attribute
lauraneto 431a75e
Fix OpenAPI documentation issues discovered during testing
lauraneto 9fea065
Update OpenAPI documentation for UmbracoOpenApiOptions
lauraneto 0f8a284
Update OpenAPI documentation for v18 URL changes
lauraneto 6a3b49d
Update OpenAPI examples to use AddOpenApiDocumentToUi
lauraneto 3070883
Update docs for AddDeliveryApiOpenApiMemberAuthentication extension m…
lauraneto 4a456c5
Merge branch 'main' into cms/v18/microsoft-open-api-docs
lauraneto 67d829e
Move OpenAPI documentation changes from v17 to v18
lauraneto a5e2a84
Address vale linter feedback from PR review
lauraneto 97578c9
Merge branch 'main' into cms/v18/microsoft-open-api-docs
lauraneto 75764e9
Sync v18 OpenAPI docs with current code
lauraneto 34b59fc
Document new IUmbracoPipelineFilter PreMapEndpoints / PostMapEndpoint…
lauraneto a6c7a4c
Document MapToApi filtering for custom OpenAPI documents in v18
lauraneto 8168e00
Trim v18 OpenAPI upgrade notes to link out to reference docs
lauraneto 9322dae
Restructure API versioning and OpenAPI reference
lauraneto fb894ad
Tidy custom-backoffice-api walkthrough wording
lauraneto b8ef878
Slim adding-a-custom-openapi-document tutorial
lauraneto c4ea685
Tighten umbraco-schema-and-operation-ids tutorial wording
lauraneto bf392c7
Sharpen custom-generated-client AllowAnonymous behavior and heading c…
lauraneto d9419cd
Remove migrating-macros tutorial
lauraneto 04855b3
Tighten OpenAPI wording in management-api and documenting-your-contro…
lauraneto f3f59ab
Fix schema ID example and use composer pattern for custom backoffice API
lauraneto 6ce8224
Document AddBackOfficeOpenApiDocument as the recommended path for bac…
lauraneto e43c6ba
Add more details to the OpenAPI upgrade notes
lauraneto d6bdadd
Minor grammar
sofietoft 701a067
Grammar fixes
sofietoft 5d579d2
Fix description punctuation in OpenAPI document tutorial
sofietoft ea0dbae
Revert v18 upgrade notes changes (already added in #8049)
lauraneto a5b5f50
Merge branch 'main' into cms/v18/microsoft-open-api-docs
lauraneto 6df2238
Restore links in v18 upgrade notes
lauraneto File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); | ||
| ``` | ||
|
|
||
| `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: | ||
|
|
||
| | 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.
|
||
|
|
||
| * **Property editors have been split in two** | ||
|
|
||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[UmbracoDocs.SentenceLength] Write shorter sentences (less than 25 words). For content inside note or warning blocks, add blank lines around the content.