Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 31, 2025

Swashbuckle.AspNetCore v10 upgraded from Microsoft.OpenApi v1.x to v2.x, introducing breaking API changes that caused compilation failures.

Changes

Namespace migration

  • Microsoft.OpenApi.ModelsMicrosoft.OpenApi (namespace removed in v2)

Security scheme reference pattern

// v1.x (old)
var securityScheme = new OpenApiSecurityScheme
{
    Reference = new OpenApiReference
    {
        Type = ReferenceType.SecurityScheme,
        Id = "Bearer"
    }
};
operation.Security.Add(new OpenApiSecurityRequirement { [securityScheme] = scopes });

// v2.x (new)
var schemeRef = new OpenApiSecuritySchemeReference("Bearer");
operation.Security?.Add(new OpenApiSecurityRequirement { [schemeRef] = scopes });

Nullability handling

  • Added null-conditional operators for operation.Security, operation.Responses, swaggerDoc.Components.SecuritySchemes (nullable in v2)

Package references

  • Added explicit Microsoft.OpenApi v2.3.0 dependency
  • Temporarily disabled Workleap.OpenApi.MSBuild in test project (incompatible with Swashbuckle v10 until updated)

Affected files

  • SecurityDefinitionDocumentFilter.cs
  • SecurityRequirementOperationFilter.cs
  • SwaggerConfigurationExtensions.cs (test project)

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…lity

- Changed using Microsoft.OpenApi.Models to Microsoft.OpenApi (namespace change in v2)
- Updated OpenApiSecurityRequirement to use OpenApiSecuritySchemeReference instead of OpenApiSecurityScheme
- Added explicit Microsoft.OpenApi package reference
- Added null-conditional operators for OpenApiDocument/OpenApiOperation properties
- Temporarily disabled Workleap.OpenApi.MSBuild in test project (incompatible with v10)

Co-authored-by: geraldbarre-workleap <[email protected]>
Copilot AI changed the title [WIP] Update Swashbuckle.AspNetCore to version 10 Fix compilation errors from Swashbuckle v10 / Microsoft.OpenApi v2 upgrade Dec 31, 2025
@Infra-Workleap Infra-Workleap force-pushed the renovate/major-swashbuckle-aspnetcore-monorepo branch 3 times, most recently from 97f10a3 to 7bee6c7 Compare January 5, 2026 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants