[OpenAPI] Use transformers that are registered in DI.
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Is your feature request related to a problem? Please describe the problem.
I am trying to use the same transformers for multiple OpenAPI documents, but instead of registering them in every `.AddOpenApi()` call, I want to register certain transformers globally in de the services.
### Describe the solution you'd like
I would like to be able to do something like:
```C#
builder.Services.AddScoped();
builder.Services.AddOpenApi("v1");
builder.Services.AddOpenApi("v2");
```
so that when running generating the OpenApi document, all the transformers that are registered in the Services are also used.
### Additional context
Of course I can work around this by using a custom extension method:
```C#
public static void AddCustomOpenApi(this IServiceCollection services, string documentName, Action configure)
{
services.AddOpenApi(documentName, options =>
{
options.AddDocumentTransformer();
configure(options);
}
}
```
But I think the first suggestion would be more useful.
Contributor guide
Assessment
This issue has not been assessed yet.