@@ -104,16 +104,52 @@ app.Run();
104104
105105### 2. Access the OpenAPI UI
106106
107- Navigate to ` /openapi-ui ` in your browser to view the API documentation interface.
107+ Navigate to ` /openapi-ui ` in your browser to view the API documentation interface (or your custom path if configured).
108+
109+ ** Note:** The default UI path is ` /openapi-ui ` and the default OpenAPI specification path is ` /swagger/v1/swagger.json ` .
108110
109111## Configuration
110112
111- ### Custom OpenAPI Specification Path
113+ ### Basic Configuration Options
114+
115+ The middleware provides several overloads for different configuration needs:
116+
117+ #### Default Configuration
118+
119+ ``` csharp
120+ app .UseOpenApiUi (); // Uses default settings
121+ ```
122+
123+ ** Default values:**
124+
125+ - ` OpenApiSpecPath ` : ` "/swagger/v1/swagger.json" `
126+ - ` OpenApiUiPath ` : ` "openapi-ui" `
127+
128+ #### Simple Path Configuration
129+
130+ ``` csharp
131+ app .UseOpenApiUi (" /api/docs/swagger.json" ); // Custom OpenAPI spec path only
132+ ```
133+
134+ #### Fluent Configuration
135+
136+ ``` csharp
137+ app .UseOpenApiUi (config =>
138+ {
139+ config .OpenApiSpecPath = " /api/v2/openapi.json" ; // Custom spec path
140+ config .OpenApiUiPath = " api-docs" ; // Custom UI path
141+ });
142+ ```
112143
113- You can specify a custom path to your OpenAPI specification:
144+ #### Configuration Object
114145
115146``` csharp
116- app .UseOpenApiUi (" /api/docs/swagger.json" );
147+ var configuration = new OpenApiUiConfiguration
148+ {
149+ OpenApiSpecPath = " /api/docs/swagger.json" ,
150+ OpenApiUiPath = " docs"
151+ };
152+ app .UseOpenApiUi (configuration );
117153```
118154
119155## Usage Examples
@@ -140,8 +176,11 @@ var app = builder.Build();
140176// add OpenUI specification
141177app .UseSwagger ();
142178
143- // add OpenAPI UI
144- app .UseOpenApiUi ();
179+ // add OpenAPI UI with custom configuration
180+ app .UseOpenApiUi (config =>
181+ {
182+ config .OpenApiUiPath = " api-docs" ; // Access via /api-docs instead of default /openapi-ui
183+ });
145184
146185app .UseHttpsRedirection ();
147186app .UseAuthorization ();
@@ -150,6 +189,33 @@ app.MapControllers();
150189app .Run ();
151190```
152191
192+ ### Advanced Configuration
193+
194+ ``` csharp
195+ // Custom path and specification
196+ app .UseOpenApiUi (config =>
197+ {
198+ config .OpenApiSpecPath = " /api/v2/openapi.json" ; // Different spec location
199+ config .OpenApiUiPath = " documentation" ; // Custom UI path
200+ });
201+
202+ // Multiple API versions
203+ if (app .Environment .IsDevelopment ())
204+ {
205+ app .UseOpenApiUi (config =>
206+ {
207+ config .OpenApiSpecPath = " /swagger/v1/swagger.json" ;
208+ config .OpenApiUiPath = " docs/v1" ;
209+ });
210+
211+ app .UseOpenApiUi (config =>
212+ {
213+ config .OpenApiSpecPath = " /swagger/v2/swagger.json" ;
214+ config .OpenApiUiPath = " docs/v2" ;
215+ });
216+ }
217+ ```
218+
153219## Requirements
154220
155221- .NET 6.0, 8.0, or 9.0
0 commit comments