Skip to content

Conversation

@mdaneri
Copy link
Contributor

@mdaneri mdaneri commented Jan 22, 2026

Pull Request

Description

Adds first-class support for OpenAPI 3.2 oauth2MetadataUrl on OAuth2 security schemes, including serialization and OpenAPI 3.2 reader support.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Other (please describe):

Related Issue(s)

Fixes #2694

Changes Made

  • Add OAuth2MetadataUrl to OpenApiSecurityScheme/IOpenApiSecurityScheme and reference wrapper.
  • Serialize oauth2MetadataUrl only for OpenAPI 3.2+ when type: oauth2.
  • Parse oauth2MetadataUrl in the OpenAPI 3.2 reader.
  • Add unit tests for serialization and parsing.

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing performed
  • All existing tests pass

Checklist

  • My code follows the code style of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Versions applicability

  • My change applies to the version 1.X of the library, if so PR link:
  • My change applies to the version 2.X of the library, if so PR link:
  • My change applies to the version 3.X of the library, if so PR link:
  • I have evaluated the applicability of my change against the other versions above.

Additional Notes

Unit tests executed locally:

  • test/Microsoft.OpenApi.Tests/Models/OpenApiSecuritySchemeTests.cs
  • test/Microsoft.OpenApi.Readers.Tests/V32Tests/OpenApiSecuritySchemeTests.cs

@mdaneri mdaneri requested a review from a team as a code owner January 22, 2026 17:15
Copy link
Member

@baywet baywet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

In addition to the requested change, you'll need to refresh the public API export.

@mdaneri
Copy link
Contributor Author

mdaneri commented Jan 22, 2026

Always I forget about that 😓

@mdaneri
Copy link
Contributor Author

mdaneri commented Jan 22, 2026

That test looks interesting! I might just borrow it and incorporate it into my project.

@baywet
Copy link
Member

baywet commented Jan 22, 2026

That test looks interesting! I might just borrow it and incorporate it into my project.

The dotnet team actually made it an analyzer, so you get feedback on build and not on tests anymore. We just haven't taken the time to update things here. See this as an example.

https://github.com/BinkyLabs/openapi-overlays-dotnet/blob/b9635b903f375498673a3ef801d7d862879e2e3b/src/lib/BinkyLabs.OpenApi.Overlays.csproj#L45

When serializing OAuth2 security schemes, the OAuth2MetadataUrl is now written as 'x-oauth2-metadata-url' for OpenAPI 3.1 and later. Updated tests and public API documentation to reflect this change.
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.

OpenAPI 3.2: oauth2MetadataUrl Missing from Microsoft.OpenApi.OpenApiSecurityScheme

2 participants