Skip to content

Support configuring document-level parts of OpenAPI schema #44192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
captainsafia opened this issue Sep 26, 2022 · 2 comments
Closed

Support configuring document-level parts of OpenAPI schema #44192

captainsafia opened this issue Sep 26, 2022 · 2 comments
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-openapi

Comments

@captainsafia
Copy link
Member

Starting in .NET 7, we added support for a WithOpenApi extension method on endpoints that allowed users to modify the OpenApiOperation associated with a particular endpoint. For example, we can modify the summary of an OpenApi Operation associated with an endpoint using the following.

app.MapGet("/foo/bar", () => ...)
  .WithOpenApi(operation =>
  {
    operation.Summary = "Just a sample endpoint";
  });

However, this API has a major limitation: it doesn't allow modifying aspects of the OpenAPI definition that exist at the document-level. This includes things like:

IMO, a super ✨ amazing ✨ experience would be supporting a WithOpenApi extension method directly on the WebApplication so that users could modify the OpenApiDocument associated with their application:

app.WithOpenApi(document =>
{
  document.Tags = ["this", "is", "some", "tags"];
});

One thing to note here, is how the app-level WithOpenApi and the endpoint-specific WithOpenApi will interact with each other. If I'm operating on the app-level WithOpenApi, can I modify operation-level details that can then be examined within an application?

If this was the case, we'd probably want there to be an OpenApiDocument in DI that is projected upon from the WithOpenApi extension methods targeting each endpoint/endpoint group/document.

While writing this issue, I came across microsoft/OpenAPI.NET#673, which proposes a builder-style syntax for building an OpenAPI document. This would be a great feature to add into the application.

@captainsafia captainsafia added feature-openapi old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels labels Sep 26, 2022
@captainsafia captainsafia added this to the .NET 8 Planning milestone Sep 26, 2022
@ghost
Copy link

ghost commented Sep 26, 2022

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@captainsafia captainsafia added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels labels Jun 20, 2023
@captainsafia
Copy link
Member Author

This is done now with our new built-in support for OpenAPI in .NET 9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-openapi
Projects
No open projects
Status: No status
Development

No branches or pull requests

1 participant