Skip to content

Commit cc36ec0

Browse files
committed
Update README.md
1 parent edbf815 commit cc36ec0

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,35 @@ Use custom security key validator and extrator
222222
```c#
223223
builder.Services.AddSecurityKey<CustomSecurityKeyValidator, CustomSecurityKeyExtractor>();
224224
```
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+
```

0 commit comments

Comments
 (0)