Skip to content

Document custom IApiDescriptionProvider in MVC application model - #37601

Merged
wadepickett merged 4 commits into
dotnet:mainfrom
Skyrunner-Dev-ops:docs/8465-api-description-providers
Sep 6, 2026
Merged

Document custom IApiDescriptionProvider in MVC application model#37601
wadepickett merged 4 commits into
dotnet:mainfrom
Skyrunner-Dev-ops:docs/8465-api-description-providers

Conversation

@Skyrunner-Dev-ops

@Skyrunner-Dev-ops Skyrunner-Dev-ops commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

…8465)

Fixes #8465

Description

IApiDescriptionProvider implementations construct ApiDescription metadata for ApiExplorerModel, which OpenAPI/Swagger doc generators rely upon. Previously, aspnetcore/mvc/controllers/application-model.md explained application model conventions and ApiExplorerModel, but lacked documentation on custom IApiDescriptionProvider implementations.

This PR adds a ### Custom API description providers with IApiDescriptionProvider subsection under ## Use ApiExplorer to document an app in aspnetcore/mvc/controllers/application-model.md.

Changes

  • Documented IApiDescriptionProvider and its execution order methods (OnProvidersExecuting and OnProvidersExecuted).
  • Provided a C# example demonstrating a custom IApiDescriptionProvider that enriches ApiDescription instances with custom metadata.
  • Demonstrated registering IApiDescriptionProvider implementations in DI using builder.Services.TryAddEnumerable(ServiceDescriptor.Transient<IApiDescriptionProvider, ...>()).

Internal previews

File Preview link
aspnetcore/mvc/controllers/application-model.md Learn preview

Build report

@Skyrunner-Dev-ops

Skyrunner-Dev-ops commented Sep 5, 2026 via email

Copy link
Copy Markdown
Contributor Author

@Skyrunner-Dev-ops

Skyrunner-Dev-ops commented Sep 5, 2026 via email

Copy link
Copy Markdown
Contributor Author

Added versioning and included information about built-in OpenAPI document generation in .NET 9 and updated guidance on using IApiDescriptionProvider.
@wadepickett
wadepickett self-requested a review September 5, 2026 22:25
@wadepickett wadepickett assigned wadepickett and unassigned tdykstra Sep 5, 2026
@wadepickett

wadepickett commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@Skyrunner-Dev-ops, Thanks so much for this contribution, ! This is solid work. Your IApiDescriptionProvider write-up is technically accurate: I verified the execution order (OnProvidersExecuting ascending, OnProvidersExecuted reverse), the default provider's Order = -1000, the ApiDescription.Properties usage, and the TryAddEnumerable registration against the dotnet/aspnetcore source, and they all check out. The code samples compile and follow the framework's own registration idiom.

I made one structural change on top of your work to account for how OpenAPI has evolved across versions in ASP.NET Core, and I want to walk you through it so the reasoning is clear:

What changed in the platform:

.NET 9 introduced built-in OpenAPI document generation via the Microsoft.AspNetCore.OpenApi package (AddOpenApi/MapOpenApi). For customizing generated output, the recommended approach is now document, operation, and schema transformers — not implementing IApiDescriptionProvider directly.
.NET 10 went further and deprecated the Microsoft.Extensions.ApiDescription.Client package (the build-time client-generation tooling), so steering readers toward that ApiExplorer-based generator path is no longer the guidance we want on current versions.
Because your section originally rendered for all versions un-gated, a reader on .NET 9/10 would have seen IApiDescriptionProvider presented as the current way to customize OpenAPI, which isn't accurate anymore.

What I changed (now in commit b3c6f20, lines 221–282):

Split the section by version using monikers, following the existing WebApiCompatShim moniker pattern already in this article:

= aspnetcore-9.0: a short note pointing readers to built-in OpenAPI and transformers, with a link to xref:fundamentals/openapi/aspnetcore-openapi.
= aspnetcore-6.0 < aspnetcore-9.0: your full content, preserved as-is — explanation, both bullets, and both code samples. I chose the 6.0 lower bound specifically so your minimal-API Program.cs registration sample stays valid throughout the range.
Added an "advanced extensibility point" caveat (mirroring the article's existing IApplicationModelProvider note), since this API is really for framework/library authors.
Reworded "OpenAPI and Swagger generators inspect these" to "Tools such as Swashbuckle and NSwag inspect these," which is the accurate framing for the pre-9 range.
Net result: every version now gets correct guidance, and your documentation is preserved for exactly the versions where it's the relevant approach. Nothing of substance was removed from what you wrote.

One small follow-up: we should bump ms.date in the frontmatter to today's date since the file changed substantially. I've assigned @tdykstra for a final look. Thanks again for jumping in on this!

If this looks good to you after the structural change I made and the current ms.author signs off I think this is good to publish now myself and approve.

The PR does not address all of what the original Issue called out, but that issue is so old it is way out of date now. I think the scope you hit here is right and we can consider it closing the issue.

Comment thread aspnetcore/mvc/controllers/application-model.md Outdated
Updated the article date.
@wadepickett

Copy link
Copy Markdown
Contributor

@tdykstra, could use yor review on this.

@wadepickett wadepickett left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approved after we versioned the new information.

@wadepickett

Copy link
Copy Markdown
Contributor

Thanks again @Skyrunner-Dev-ops! This is going live today.

@wadepickett
wadepickett merged commit 38b8030 into dotnet:main Sep 6, 2026
5 checks passed
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.

Add documentation for API description providers in web sites

3 participants