File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -222,3 +222,35 @@ Use custom security key validator and extrator
222
222
``` c#
223
223
builder .Services .AddSecurityKey <CustomSecurityKeyValidator , CustomSecurityKeyExtractor >();
224
224
```
225
+
226
+ ### Open API
227
+
228
+ NuGet Package: ` AspNetCore.SecurityKey.OpenApi `
229
+
230
+ Add Open API support
231
+
232
+ ``` c#
233
+ var builder = WebApplication .CreateBuilder (args );
234
+
235
+ builder .Services
236
+ .AddAuthentication ()
237
+ .AddSecurityKey ();
238
+
239
+ builder .Services .AddAuthorization ();
240
+ builder .Services .AddSecurityKey ();
241
+
242
+ // add api key requirment to open api
243
+ builder .Services .AddOpenApi (options => options
244
+ .AddDocumentTransformer <SecurityKeyDocumentTransformer >()
245
+ );
246
+
247
+ var app = builder .Build ();
248
+
249
+ app .UseAuthentication ();
250
+ app .UseAuthorization ();
251
+
252
+ app .MapOpenApi ();
253
+
254
+ // use Scalar.AspNetCore package
255
+ app .MapScalarApiReference ();
256
+ ```
You can’t perform that action at this time.
0 commit comments