OpenApiDocumentTransformerContext.ApplicationServices Property

Definition

Gets the application services associated with the current document.

public IServiceProvider ApplicationServices { get; init; }
member this.ApplicationServices : IServiceProvider with get, set
Public Property ApplicationServices As IServiceProvider

Property Value

Examples

var myService = context.ApplicationServices.GetRequiredService<MyService>();

Remarks

This is the IServiceProvider used when generating the OpenAPI document and can be used to resolve application services within a document transformer. It is typically a scoped provider, such as HttpContext.RequestServices or a scope created specifically for document generation, but the exact lifetime of resolved services depends on how the OpenAPI document generation was invoked.

Applies to