Skip to content

Improve build-time OpenAPI document generation #58353

Open
1 of 5 issues completed
Open

Description

@captainsafia

This is a meta-issue to track a set of improvements that can be made to the tooling we currently provide for generating OpenAPI documents at build-time.

Build-time OpenAPI document generation issue currently supported by the Microsoft.Extensions.ApiDescription.Server package and was primarily implemented with the assumption that another package (like Swashbuckle or NSwag) would be installed alongside it.

Here's a braindump of the current issues with the design and how we might improve them in the future:

  • The current implementation uses an internal executable that is called via MSBuild, so there's massaging that needs to be done when mapping the MSBuild arguments to arguments for the CLI tool. IMO, we should ship either a tool or stick to MSBuild targets. I don't think there's much value in providing half-baked support for both.
  • The current implementation is intended to work with tools like Swashbuckle, which support a wider set of target frameworks that we intend to. Moving to a different approach would allow us to remove code/packaging logic related to unsupported frameworks (netfx, netstandard).
  • I'd like to standardize the configuration story for build-time document generation so there's an official schema exposed via options (similar to what you get with Aspire's config model) to improve the discoverability of these options.
  • The current implementation relies on private reflection-based contract exposed via the “IDocumentProvider” interface. This interface should be fleshed out and made public.
  • The current implementation will attempt to boot up the application's entry-point at build-time in oder to resolve the IDocumentProvider instance from the DI container. This can present issues for applications that resolve configuration at startup that might not exist when it is launched by the command line tool. Furthermore, it's difficult to detect when an application is being launched by the tool which makes it difficult to create conditional logic for this behavior.

This collection of issues and our overall investment in OpenAPI warrants another look here to see if we can establish something better and address something of these pain-points. The goals of this effort include:

  • Reducing the reliance on internal or undocumented APIs for the implementation
  • Streamline the process for configuring options for the command line tool
  • Make it easier to stub out unavailable startup dependences in the entry points

Sub-issues

Sub-issues

1 of 5 Issues completed
Loading 5 sub-issues

Activity

  1. added
    area-minimal
    area-mvc
    on Oct 10, 2024
  2. added this to the .NET 10 Planning milestone on Oct 10, 2024
  3. self-assigned this
    on Oct 10, 2024
  4. marinasundstrom commented on Nov 12, 2024

    @marinasundstrom
  5. captainsafia commented on Nov 14, 2024

    @captainsafia
    ContributorAuthor

    @marinasundstrom I think you might've intended to post this comment on the issue tracking adoption of 3.1 support: #58619

  6. mikekistler commented on Jun 25, 2025

    @mikekistler

    Sadly we have to drop this off the roadmap for .NET 10 due to resource constraints.

  7. gareth-a-jones commented on Nov 19, 2025

    @gareth-a-jones

    We are very interested in driving along this path for the M365 Substrate. We have hundreds of APIs on a wide variety of stacks from Fx462 through many recent versions of dotnet. Clearly, we are working to migrate them to latest dotnet, but it is slow (years slow etc.)

    Most of these APIs are JSON REST-ish based on ASP.net - some with OData of various point versions.

    Being able to create openAPI documents for services without having to check a line of code into that services repo is our key ask.

    Getting permissions to make even minor changes at scale across substrate will turn this project into a year or more's investment and likely kill or severely limit it.

    Consequently we need a wholly external scanner that can load the target system's assemblies into some hosting tool and spit out reasonably accurate openAI files.

  8. removed their assignment
    on Jan 14, 2026
  9. removed
    area-mvc
    on Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-minimalfeature-openapi

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions