Skip to content
Merged
Show file tree
Hide file tree
Changes from 95 commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
6e2413b
Uninstall `Swashbuckle.AspNetCore` and install `Microsoft.AspNetCore.…
lauraneto Nov 3, 2025
5b035ff
Registered UI and removed or commented out Swashbuckle specific code
lauraneto Nov 3, 2025
ad9393c
Started configuring the different Open API documents
lauraneto Nov 3, 2025
fbd358d
Started moving configuration
lauraneto Nov 4, 2025
9449564
Simplifying configuration
lauraneto Nov 4, 2025
f04cd94
Added missing configuration for the Delivery API
lauraneto Nov 5, 2025
8a32af3
Added missing configurations for Management API
lauraneto Nov 5, 2025
e954aeb
Adjust Umbraco Extension template with OpenApi changes
lauraneto Nov 5, 2025
4dee734
Handle sub types in open api document generation
lauraneto Nov 6, 2025
a29faae
Renaming mime types transformer to align with others
lauraneto Nov 6, 2025
e6caf6e
Added discriminator configuration
lauraneto Nov 6, 2025
902bbad
Reference Umbraco.Cms.DevelopmentMode.Backoffice from integration tes…
lauraneto Nov 6, 2025
7011f39
Now configuring and using the HTTP json options instead of having cus…
lauraneto Nov 10, 2025
1c70f54
Merge branch 'main' into v18/feature/microsoft-open-api-document-gene…
lauraneto Nov 12, 2025
6574d58
Fixes to examples
lauraneto Nov 13, 2025
d9f82e9
Merge branch 'main' into v18/feature/microsoft-open-api-document-gene…
lauraneto Nov 13, 2025
d32628b
Update OpenAPI packages
lauraneto Nov 13, 2025
271f698
Mark most transformers as internal
lauraneto Nov 17, 2025
90e2422
Simplify adding backoffice security requirements to your API
lauraneto Nov 17, 2025
fa34354
Fix missing required properties
lauraneto Nov 17, 2025
6fed966
Re-order transformers to fix missing notification headers
lauraneto Nov 17, 2025
fc36c5f
Fix most build errors after regenerating client
lauraneto Nov 17, 2025
f9f358a
Merge branch 'main' into v18/feature/microsoft-open-api-document-gene…
lauraneto Nov 18, 2025
5ca3965
Fix mime types transformer being applied to Management API
lauraneto Nov 18, 2025
1c4f78d
Additional fixes
lauraneto Nov 18, 2025
4d3ab86
Additional fixes to file response types
lauraneto Nov 18, 2025
6583106
Configure Swagger UI documents
lauraneto Nov 18, 2025
62ee663
Clear server list
lauraneto Nov 18, 2025
91df6e2
Sort APIs in UI
lauraneto Nov 18, 2025
28a2df9
Merge branch 'main' into v18/feature/microsoft-open-api-document-gene…
lauraneto Dec 2, 2025
09a0c9e
Merge branch 'main' into v18/feature/microsoft-open-api-document-gene…
lauraneto Dec 2, 2025
aa717d0
Re-introduce schema handlers and fix issue with nullable enum schema …
lauraneto Dec 2, 2025
ed65b95
Simplify examples
lauraneto Dec 3, 2025
a95b6fd
Small optimization
lauraneto Dec 3, 2025
ba003c0
Merge branch 'main' into v18/feature/microsoft-open-api-document-gene…
lauraneto Dec 3, 2025
5d3abf7
Simplify nullability check in RequireNonNullablePropertiesSchemaTrans…
lauraneto Dec 4, 2025
7a2cd36
Merge branch 'v18/dev' into v18/feature/microsoft-open-api-document-g…
lauraneto Dec 4, 2025
1e85671
Remove unused property
lauraneto Dec 4, 2025
31c6808
Small fixes suggested by Claude
lauraneto Dec 4, 2025
c8c1d6f
Undo unintended space changes
lauraneto Dec 4, 2025
3ad75dd
Add unit tests for OpenAPI transformers
lauraneto Dec 4, 2025
9834cb0
Add unit tests for additional OpenAPI transformers
lauraneto Dec 4, 2025
ea31004
Rename SwaggerGen classes to OpenApi for consistency
lauraneto Dec 4, 2025
ed217ba
Update OpenAPI contract test for Microsoft.AspNetCore.OpenApi
lauraneto Dec 4, 2025
bf7d054
Disable Models Builder in integration tests by default
lauraneto Dec 7, 2025
2da7a6d
Rename Swagger references to OpenApi for consistency
lauraneto Dec 8, 2025
70de857
Merge branch 'v18/dev' into v18/feature/microsoft-open-api-document-g…
lauraneto Dec 11, 2025
cdb6c67
Re-generate Management API open api doc and UI client after merge
lauraneto Dec 11, 2025
4849df7
Add reference in comment to additional PR to fix file return types sc…
lauraneto Dec 11, 2025
0d54cfa
Fix Open API validation errors
lauraneto Dec 11, 2025
82a7dbb
Merge branch 'v18/dev' into v18/feature/microsoft-open-api-document-g…
lauraneto Dec 16, 2025
32265b4
OpenAPI: Replace ISchemaIdHandler/ISchemaIdSelector with static Umbra…
lauraneto Dec 19, 2025
b215c2a
Rename CustomOperationIdsTransformer to UmbracoOperationIdTransformer…
lauraneto Dec 19, 2025
e3e69f4
OpenAPI: Update Delivery API contract test for new document format
lauraneto Jan 6, 2026
4e911a7
Merge branch 'v18/dev' into v18/feature/microsoft-open-api-document-g…
lauraneto Jan 6, 2026
4172e9a
OpenAPI: Remove obsolete DocumentInclusionSelector abstraction
lauraneto Jan 6, 2026
8d27913
OpenAPI: Reorganize Management API OpenApi folder structure
lauraneto Jan 6, 2026
b5231d0
OpenAPI: Add ExcludeFromDefaultOpenApiDocument attribute
lauraneto Jan 6, 2026
2983f13
OpenAPI: Add UmbracoOpenApiOptions for configuring OpenAPI routes
lauraneto Jan 7, 2026
f874a80
Pipeline filters: Add OnPreMapEndpoints and rename OnEndpoints to OnP…
lauraneto Dec 17, 2025
685f680
OpenAPI: Move MapOpenApi to PreMapEndpoints hook
lauraneto Jan 7, 2026
09fa158
OpenAPI: Rename URL paths from swagger to openapi
lauraneto Jan 7, 2026
b0f4900
Merge branch 'v18/dev' into v18/feature/microsoft-open-api-document-g…
lauraneto Jan 15, 2026
30326bf
OpenAPI: Update Microsoft.AspNetCore.OpenApi to 10.0.2
lauraneto Jan 15, 2026
f9b3ac0
OpenAPI: Add AddOpenApiDocumentToUi extension method
lauraneto Jan 15, 2026
2754cea
OpenAPI: Make OpenApiRouteTemplatePipelineFilter internal
lauraneto Jan 15, 2026
65f914d
OpenAPI: Rename DeliveryApiSecurityFilter to DeliveryApiSecurityTrans…
lauraneto Jan 15, 2026
42483ce
OpenAPI: Simplify Delivery API member authentication configuration
lauraneto Jan 15, 2026
5ea01b0
OpenAPI: Add reference to proposal for custom JSON options support
lauraneto Jan 15, 2026
008ebaf
Move Delivery API transformers to OpenApi/Transformers folder
lauraneto Jan 15, 2026
aaea040
Update OpenAPI contract tests to use new URL format
lauraneto Jan 16, 2026
dc27bef
Merge branch 'v18/dev' into v18/feature/microsoft-open-api-document-g…
lauraneto Feb 4, 2026
49a2eba
Apply suggestions from code review
lauraneto Feb 5, 2026
b23c69f
Update src/Umbraco.Cms.Api.Delivery/DependencyInjection/UmbracoBuilde…
lauraneto Feb 5, 2026
f97ad76
Fix IAuthorizationService injection detection in BackOfficeSecurityRe…
lauraneto Feb 5, 2026
146f8cd
Remove unnecessary InterceptorsNamespaces from API projects
lauraneto Feb 5, 2026
a6ab23f
Remove default implementations from IUmbracoPipelineFilter methods
lauraneto Feb 5, 2026
a85a426
Update documentation for Microsoft.AspNetCore.OpenApi migration
lauraneto Feb 5, 2026
67ef8db
Update Swashbuckle.AspNetCore.SwaggerUI to 10.1.2
lauraneto Feb 5, 2026
0c1b1e2
Refactor OpenAPI contract tests with validation
lauraneto Feb 6, 2026
5492ae0
Merge branch 'v18/dev' into v18/feature/microsoft-open-api-document-g…
lauraneto Feb 25, 2026
9f780e5
Update ElementReferenceResponseModel type reference after OpenAPI reg…
lauraneto Feb 25, 2026
9f3feac
Add discriminator values to Delivery API polymorphic JSON serialization
lauraneto Feb 25, 2026
a207d81
Move Delivery API OpenAPI contract tests to Umbraco.Api.Delivery folder
lauraneto Feb 25, 2026
9348449
Update Microsoft.AspNetCore.OpenApi to 10.0.3 and Swashbuckle.AspNetC…
lauraneto Feb 25, 2026
950fbbf
Use JsonDerivedType attributes for Delivery API polymorphic serializa…
lauraneto Feb 25, 2026
94e665b
Add OpenAPI test for custom derived type extensibility
lauraneto Feb 25, 2026
898d1bf
Fix OpenAPI contract test failing on CI due to ContinuousIntegrationB…
lauraneto Mar 3, 2026
0f0adce
Merge remote-tracking branch 'origin/v18/dev' into v18/feature/micros…
lauraneto Mar 3, 2026
4036c97
Merge remote-tracking branch 'origin/v18/dev' into v18/feature/micros…
lauraneto Apr 13, 2026
fbc8d19
Merge branch 'v18/dev' into v18/feature/microsoft-open-api-document-g…
lauraneto Apr 14, 2026
b068e75
Bump Swashbuckle.AspNetCore.SwaggerUI to 10.1.7
lauraneto Apr 14, 2026
a8f09f5
Remove duplicate InternalsVisibleTo for Umbraco.Tests.UnitTests
lauraneto Apr 15, 2026
74858e2
Extract ReplaceOpenApiSchemaService into shared Api.Common helper
lauraneto Apr 16, 2026
59087d2
Merge remote-tracking branch 'origin/v18/dev' into v18/feature/micros…
lauraneto Apr 20, 2026
17c4c38
Tighten visibility and improve DI extension structure
lauraneto Apr 20, 2026
2ebd548
Regenerate OpenApi.json to fix duplicate document patch endpoint
lauraneto Apr 20, 2026
114c7ee
Move MimeTypesTransformer to shared base and respect [Consumes]
lauraneto Apr 20, 2026
b67ebe3
Move Umbraco-specific transformers from shared base to API configs
lauraneto Apr 20, 2026
f38eafd
Clarify XML doc for UmbracoOpenApiOptions.Enabled
lauraneto Apr 21, 2026
b89e350
Use alphabetically-first tag across all operations for stable path so…
lauraneto Apr 21, 2026
82dae43
Update MimeTypesTransformer tests for operation transformer interface
lauraneto Apr 21, 2026
d24e2c0
Reference dotnet/aspnetcore#66340 in ReplaceOpenApiSchemaService docs
lauraneto Apr 21, 2026
fc9fb40
Merge branch 'v18/dev' into v18/feature/microsoft-open-api-document-g…
AndyButland Apr 23, 2026
fe82e89
Add unit tests to verify OpenApiSchemaServiceExtensions usage of inte…
AndyButland Apr 23, 2026
435f541
Bumped Microsoft.AspNetCore.OpenApi from 10.0.4 to 10.0.6 to match D…
AndyButland Apr 23, 2026
fada672
Fix indentation.
AndyButland Apr 23, 2026
303eacf
Defensively handle a non-integer status code response key in Response…
AndyButland Apr 23, 2026
cdb41db
Use TryGetValue in RequireNonNullablePropertiesSchemaTransformer to a…
AndyButland Apr 23, 2026
ef9778d
Additional tests and clarifying comments.
AndyButland Apr 23, 2026
7294406
Revert accidental local dev changes to Program.cs, Web.UI.csproj and …
AndyButland Apr 23, 2026
5a54668
Tighten visibility of OpenAPI configuration and transformer classes t…
lauraneto Apr 23, 2026
5752d5b
Merge branch 'v18/dev' into v18/feature/microsoft-open-api-document-g…
lauraneto Apr 24, 2026
69d9afd
Merge branch 'v18/dev' into v18/feature/microsoft-open-api-document-g…
lauraneto Apr 24, 2026
e74d55e
Merge branch 'v18/dev' into v18/feature/microsoft-open-api-document-g…
lauraneto Apr 29, 2026
3d31f6f
Merge remote-tracking branch 'origin/v18/dev' into v18/feature/micros…
lauraneto Apr 29, 2026
d0ad10d
Merge branch 'v18/dev' into v18/feature/microsoft-open-api-document-g…
lauraneto Apr 29, 2026
31d9932
Merge branch 'v18/dev' into v18/feature/microsoft-open-api-document-g…
lauraneto Apr 30, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ Enterprise-grade CMS built on .NET 10.0. This repository contains 21 production
- **ASP.NET Core** - Web framework
- **Entity Framework Core** - Modern ORM
- **OpenIddict** - OAuth 2.0/OpenID Connect authentication
- **Swashbuckle** - OpenAPI/Swagger documentation
- **Microsoft.AspNetCore.OpenApi** - OpenAPI document generation
- **Swashbuckle.AspNetCore.SwaggerUI** - Swagger UI for API documentation
- **Lucene.NET** - Full-text search via Examine
- **ImageSharp** - Image processing

Expand Down Expand Up @@ -368,10 +369,10 @@ public interface IMyService

```xml
<!-- Individual projects reference WITHOUT version -->
<PackageReference Include="Swashbuckle.AspNetCore" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" />

<!-- Versions defined in Directory.Packages.props -->
<PackageVersion Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.0" />
```

### Build Configuration
Expand Down Expand Up @@ -417,7 +418,8 @@ All APIs use **OpenIddict** (OAuth 2.0/OpenID Connect):
APIs use `Asp.Versioning.Mvc`:
- Management API: `/umbraco/management/api/v{version}/*`
- Delivery API: `/umbraco/delivery/api/v{version}/*`
- OpenAPI/Swagger docs per version
- OpenAPI docs: `/umbraco/openapi/management.json`, `/umbraco/openapi/delivery.json`
- Swagger UI: `/umbraco/openapi/`

### Updating `OpenApi.json` (Management API)

Expand Down
5 changes: 3 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<!-- Microsoft packages -->
<ItemGroup>
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="10.0.6" />
<!-- When updating this version, also update templates/UmbracoExtension/Umbraco.Extension.csproj -->
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="10.0.6" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="5.0.0" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="5.0.0" />
<PackageVersion Include="Microsoft.Data.Sqlite" Version="10.0.6" />
Expand Down Expand Up @@ -78,8 +80,7 @@
<PackageVersion Include="Serilog.Sinks.Map" Version="2.0.0" />
<PackageVersion Include="SixLabors.ImageSharp" Version="3.1.12" />
<PackageVersion Include="SixLabors.ImageSharp.Web" Version="3.2.0" />
<!-- When updating this version, also update templates/UmbracoExtension/Umbraco.Extension.csproj -->
<PackageVersion Include="Swashbuckle.AspNetCore" Version="10.1.7" />
<PackageVersion Include="Swashbuckle.AspNetCore.SwaggerUI" Version="10.1.7" />
</ItemGroup>
<!-- Transitive pinned versions (only required because our direct dependencies have vulnerable versions of transitive dependencies) -->
<ItemGroup>
Expand Down
112 changes: 42 additions & 70 deletions src/Umbraco.Cms.Api.Common/CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ Shared infrastructure for Umbraco CMS REST APIs (Management and Delivery).
### Key Technologies

- **ASP.NET Core** - Web framework
- **Swashbuckle** - OpenAPI/Swagger documentation generation
- **Microsoft.AspNetCore.OpenApi** - OpenAPI document generation
- **Swashbuckle.AspNetCore.SwaggerUI** - Swagger UI for browsing API documentation
- **OpenIddict** - OAuth 2.0/OpenID Connect authentication
- **Asp.Versioning** - API versioning
- **System.Text.Json** - Polymorphic JSON serialization
Expand All @@ -27,14 +28,18 @@ Shared infrastructure for Umbraco CMS REST APIs (Management and Delivery).

```
Umbraco.Cms.Api.Common/
├── OpenApi/ # Schema/Operation ID handlers for Swagger
│ ├── SchemaIdHandler.cs # Generates schema IDs (e.g., "PagedUserModel")
│ ├── OperationIdHandler.cs # Generates operation IDs
│ └── SubTypesHandler.cs # Polymorphism support
├── OpenApi/ # OpenAPI transformers and schema generators
│ ├── UmbracoSchemaIdGenerator.cs # Generates schema IDs (e.g., "PagedUserModel")
│ ├── UmbracoOperationIdTransformer.cs # Generates operation IDs
│ ├── SortTagsAndPathsTransformer.cs # Sorts OpenAPI tags and paths
│ ├── TagActionsByGroupNameTransformer.cs # Tags operations by controller group
│ ├── FixFileReturnTypesTransformer.cs # Fixes file return type schemas
│ ├── RequireNonNullablePropertiesSchemaTransformer.cs # Schema nullability
│ └── OpenApiRouteTemplatePipelineFilter.cs # Adds OpenAPI endpoints
├── Serialization/ # JSON type resolution
│ └── UmbracoJsonTypeInfoResolver.cs
├── Configuration/ # Options configuration
│ ├── ConfigureUmbracoSwaggerGenOptions.cs
│ ├── ConfigureUmbracoOpenApiOptionsBase.cs
│ └── ConfigureOpenIddict.cs
├── DependencyInjection/ # Service registration
│ ├── UmbracoBuilderApiExtensions.cs
Expand All @@ -47,9 +52,8 @@ Umbraco.Cms.Api.Common/

### Design Patterns

1. **Strategy Pattern** - `ISchemaIdHandler`, `IOperationIdHandler` (extensible via inheritance)
2. **Builder Pattern** - `ProblemDetailsBuilder` for fluent error responses
3. **Options Pattern** - All configuration via `IConfigureOptions<T>`
1. **Builder Pattern** - `ProblemDetailsBuilder` for fluent error responses
2. **Options Pattern** - All configuration via `IConfigureOptions<T>`

---

Expand All @@ -61,36 +65,25 @@ See "Quick Reference" section at bottom for common commands.

## 3. Key Patterns

### Virtual Handlers for Extensibility
### Schema ID Generation (OpenApi/UmbracoSchemaIdGenerator.cs)

Handlers are intentionally virtual to allow consuming APIs to override:
Static utility class that generates OpenAPI schema IDs following Umbraco's naming conventions:

```csharp
// NOTE: Left unsealed on purpose, so it is extendable.
public class SchemaIdHandler : ISchemaIdHandler
{
public virtual bool CanHandle(Type type) { }
public virtual string Handle(Type type) { }
}
```

**Why**: Management and Delivery APIs can customize schema/operation ID generation.

### Schema ID Sanitization (OpenApi/SchemaIdHandler.cs:24-29, 32)

```csharp
// Add "Model" suffix to avoid TypeScript name clashes (lines 24-29)
// Add "Model" suffix to avoid TypeScript name clashes
if (name.EndsWith("Model") == false)
{
// because some models names clash with common classes in TypeScript (i.e. Document),
// we need to add a "Model" postfix to all models
name = $"{name}Model";
}

// Remove invalid characters to prevent OpenAPI generation errors (line 32)
// Remove invalid characters to prevent OpenAPI generation errors
return Regex.Replace(name, @"[^\w]", string.Empty);
```

**Generic Type Handling**: `PagedViewModel<RelationItemViewModel>` becomes `PagedRelationItemModel`

### Polymorphic Deserialization (Serialization/UmbracoJsonTypeInfoResolver.cs:29-35)

```csharp
Expand All @@ -116,9 +109,12 @@ if (type.IsInterface is false)
dotnet test tests/Umbraco.Tests.Integration/

# Verify OpenAPI generation
# 1. Run Management API
# 2. Navigate to /umbraco/swagger/
# 1. Run the application: dotnet run --project src/Umbraco.Web.UI
# 2. Navigate to /umbraco/openapi/ for Swagger UI
# 3. Check schema IDs and operation IDs
# OpenAPI JSON documents available at:
# - /umbraco/openapi/management.json (Management API)
# - /umbraco/openapi/delivery.json (Delivery API)
```

**Focus areas when testing**:
Expand Down Expand Up @@ -207,49 +203,24 @@ catch (NotSupportedException exception)

**Issue**: Type names like `Document` clash with TypeScript built-ins.

**Solution**: Add "Model" suffix (OpenApi/SchemaIdHandler.cs:24-29)
**Solution**: `UmbracoSchemaIdGenerator` adds "Model" suffix to all schema names.

### Generic Type Handling

**Issue**: `PagedViewModel<T>` needs flattened schema name.

**Solution** (OpenApi/SchemaIdHandler.cs:41-50):
```csharp
private string HandleGenerics(string name, Type type)
{
if (!type.IsGenericType)
return name;

// use attribute custom name or append the generic type names
// turns "PagedViewModel<RelationItemViewModel>" into "PagedRelationItem"
return $"{name}{string.Join(string.Empty, type.GenericTypeArguments.Select(SanitizedTypeName))}";
}
```
**Solution**: `UmbracoSchemaIdGenerator.Generate()` flattens generic types:
- `PagedViewModel<RelationItemViewModel>` becomes `PagedRelationItemModel`

---

## 7. Extending This Library

### Adding a Custom OpenAPI Handler

1. **Implement interface**:
```csharp
public class MySchemaIdHandler : SchemaIdHandler
{
public override bool CanHandle(Type type)
=> type.Namespace?.StartsWith("MyProject") is true;
### Adding Custom OpenAPI Transformers

public override string Handle(Type type)
=> $"My{base.Handle(type)}";
}
```
OpenAPI transformers are scoped per-document. To customize a document, implement `IOpenApiDocumentTransformer`, `IOpenApiOperationTransformer`, or `IOpenApiSchemaTransformer` and register with your OpenAPI options.

2. **Register in consuming API**:
```csharp
builder.Services.AddSingleton<ISchemaIdHandler, MySchemaIdHandler>();
```

**Note**: Handlers registered later take precedence in the selector.
For schema ID generation, use the static `UmbracoSchemaIdGenerator.Generate(Type)` method.

### Customizing Problem Details

Expand All @@ -269,13 +240,9 @@ return BadRequest(problemDetails);

## 8. Project-Specific Notes

### Why Virtual Handlers?

**Decision**: Make `SchemaIdHandler`, `OperationIdHandler`, etc. virtual.
### Per-Document Transformer Scoping

**Why**: Management API and Delivery API have different schema ID requirements. Virtual methods allow override without rewriting the entire handler.

**Example**: Management API might prefix all schemas with "Management", Delivery API with "Delivery".
With Microsoft.AspNetCore.OpenApi, transformers are configured per OpenAPI document. This means custom transformers only apply to the documents they're registered with, not globally. Each API (Management, Delivery) configures its own transformers via `ConfigureUmbracoOpenApiOptionsBase` subclasses.

### Performance: Subtype Caching

Expand Down Expand Up @@ -304,9 +271,13 @@ return BadRequest(problemDetails);
- Version: See `Directory.Packages.props`
- Uses ASP.NET Core Data Protection for token encryption

**Swashbuckle**:
- OpenAPI 3.0 document generation
- Custom filters: `EnumSchemaFilter`, `MimeTypeDocumentFilter`, `RemoveSecuritySchemesDocumentFilter`
**Microsoft.AspNetCore.OpenApi**:
- OpenAPI 3.1.1 document generation
- Custom transformers: `SchemaIdTransformer`, `OperationIdTransformer`, `MimeTypeDocumentTransformer`, `ServerTransformer`

**Swashbuckle.AspNetCore.SwaggerUI**:
- Swagger UI for browsing and testing API endpoints
- Accessed at `/umbraco/openapi/`

**Asp.Versioning**:
- API versioning via `ApiVersion` attribute
Expand All @@ -318,7 +289,7 @@ return BadRequest(problemDetails);

### Usage Pattern

Consuming APIs call `builder.AddUmbracoApiOpenApiUI().AddUmbracoOpenIddict()`
Consuming APIs call `builder.AddUmbracoOpenApi().AddUmbracoOpenIddict()`

---

Expand Down Expand Up @@ -346,7 +317,8 @@ dotnet list src/Umbraco.Cms.Api.Common/Umbraco.Cms.Api.Common.csproj package --v
| Class | Purpose | File |
|-------|---------|------|
| `ProblemDetailsBuilder` | Build RFC 7807 error responses | Builders/ProblemDetailsBuilder.cs |
| `SchemaIdHandler` | Generate OpenAPI schema IDs | OpenApi/SchemaIdHandler.cs |
| `UmbracoSchemaIdGenerator` | Generate OpenAPI schema IDs | OpenApi/UmbracoSchemaIdGenerator.cs |
| `UmbracoOperationIdTransformer` | Generate operation IDs | OpenApi/UmbracoOperationIdTransformer.cs |
| `UmbracoJsonTypeInfoResolver` | Polymorphic JSON serialization | Serialization/UmbracoJsonTypeInfoResolver.cs |
| `UmbracoBuilderAuthExtensions` | Configure OpenIddict | DependencyInjection/UmbracoBuilderAuthExtensions.cs |
| `HideBackOfficeTokensHandler` | Secure cookie-based token storage | DependencyInjection/HideBackOfficeTokensHandler.cs |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
using System.Reflection;
using Asp.Versioning;
using Microsoft.AspNetCore.Mvc.Abstractions;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Controllers;
using Umbraco.Cms.Api.Common.OpenApi;

namespace Umbraco.Cms.Api.Common.Configuration;

/// <summary>
/// Configures the OpenAPI options for the Default API.
/// </summary>
public class ConfigureDefaultApiOptions : ConfigureUmbracoOpenApiOptionsBase
{
/// <inheritdoc />
protected override string ApiName => DefaultApiConfiguration.ApiName;

/// <inheritdoc />
protected override string ApiTitle => "Default API";

/// <inheritdoc />
protected override string ApiVersion => "Latest";

/// <inheritdoc />
protected override string ApiDescription => "All endpoints not defined under specific APIs";

/// <inheritdoc />
protected override bool ShouldInclude(ApiDescription apiDescription)
{
// Exclude controllers with ExcludeFromDefaultOpenApiDocumentAttribute
if (apiDescription.ActionDescriptor is ControllerActionDescriptor controllerActionDescriptor
&& controllerActionDescriptor.ControllerTypeInfo.GetCustomAttribute<ExcludeFromDefaultOpenApiDocumentAttribute>() is not null)
{
return false;
}

// Include if explicitly mapped to this document
if (base.ShouldInclude(apiDescription))
{
return true;
}

// Include endpoints not explicitly assigned to another document
ApiVersionMetadata apiVersionMetadata = apiDescription.ActionDescriptor.GetApiVersionMetadata();
return string.IsNullOrEmpty(apiVersionMetadata.Name);
}
}
Loading
Loading