Skip to content
This repository was archived by the owner on Apr 17, 2025. It is now read-only.

Commit e9d169a

Browse files
committed
Aggiunta documentazione Swagger Date and Time Only
1 parent 5cde20f commit e9d169a

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# SwaggerUI Date Time configuration
2+
3+
4+
## Registering services at Startup (with xml documentation)
5+
6+
```csharp
7+
public Startup(IConfiguration configuration)
8+
{
9+
Configuration = configuration;
10+
}
11+
12+
public IConfiguration Configuration { get; }
13+
14+
public void ConfigureServices(IServiceCollection services)
15+
{
16+
var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
17+
var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
18+
19+
services.AddSwaggerGenDateTimeConfig("My Web Api", "v1", "Add here a description which will be shown in the swagger UI", true, xmlPath);
20+
//OR services.AddSwaggerGenDateTimeConfig("My Web Api", "v1", string.Empty, true, xmlPath);
21+
}
22+
23+
//OMISSIS
24+
25+
public void Configure(WebApplication app)
26+
{
27+
app.AddUseSwaggerUI("My Web Api v1");
28+
}
29+
```
30+
31+
<b>Note:</b> If you want to add xml documentation to web api you need to add TRUE value to GenerateDocumentationFile tag to csproj project file.
32+
33+
34+
## Registering services at Startup (without xml documentation)
35+
36+
```csharp
37+
public Startup(IConfiguration configuration)
38+
{
39+
Configuration = configuration;
40+
}
41+
42+
public IConfiguration Configuration { get; }
43+
44+
public void ConfigureServices(IServiceCollection services)
45+
{
46+
services.AddSwaggerGenDateTimeConfig("My Web Api", "v1", "Add here a description which will be shown in the swagger UI");
47+
//OR services.AddSwaggerGenDateTimeConfig("My Web Api", "v1", string.Empty);
48+
}
49+
50+
//OMISSIS
51+
52+
public void Configure(WebApplication app)
53+
{
54+
app.AddUseSwaggerUI("My Web Api v1");
55+
}
56+
```

0 commit comments

Comments
 (0)