-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from EasilyNET/dev
Dev
- Loading branch information
Showing
15 changed files
with
92 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...T.WebCore/Attributes/ApiGroupAttribute.cs → ...e.Swagger/Attributes/ApiGroupAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
....WebCore/Attributes/HiddenApiAttribute.cs → ....Swagger/Attributes/HiddenApiAttribute.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/EasilyNET.WebCore.Swagger/EasilyNET.WebCore.Swagger.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks> | ||
<PackageProjectUrl>https://www.nuget.org/packages/EasilyNET.WebCore.Swagger</PackageProjectUrl> | ||
<Description>一些Swagger的一些配置.</Description> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" /> | ||
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\EasilyNET.WebCore\EasilyNET.WebCore.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
### EasilyNET.WebCore.Swagger | ||
|
||
将Swagger的扩展独立出来,避免WebCore的过度依赖. | ||
|
||
### 如何使用? | ||
|
||
- [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) | ||
|
||
```csharp | ||
// 添加 Swagger 服务 | ||
private const string name = $"{title}-{version}"; | ||
|
||
private const string version = "v1"; | ||
private const string title = "WebApi.Test"; | ||
|
||
builder.Services.AddSwaggerGen(c => | ||
{ | ||
// 配置默认的文档信息 | ||
c.SwaggerDoc(name, new() | ||
{ | ||
Title = title, | ||
Version = version, | ||
Description = "Console.WriteLine(\"🐂🍺\")" | ||
}); | ||
// 这里使用EasilyNET提供的扩展配置. | ||
c.EasilySwaggerGenOptions(name); | ||
// 配置认证方式 | ||
c.AddSecurityDefinition("Bearer", new() | ||
{ | ||
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", | ||
Name = "Authorization", | ||
In = ParameterLocation.Header, | ||
Type = SecuritySchemeType.ApiKey, | ||
Scheme = "Bearer" | ||
}); | ||
}); | ||
|
||
... | ||
|
||
// 注册 Swagger 中间件 | ||
app.UseSwagger().UseSwaggerUI(c => | ||
{ | ||
// 配置默认文档 | ||
c.SwaggerEndpoint($"/swagger/{name}/swagger.json", $"{title} {version}"); | ||
// 使用EasilyNET提供的扩展配置 | ||
c.EasilySwaggerUIOptions(); | ||
}); | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters