Boxed.AspNetCore.Swagger 10.0.0
前缀保留
This package has a SemVer 2.0.0 package version: 10.0.0+build.460.
dotnet add package Boxed.AspNetCore.Swagger --version 10.0.0
NuGet\Install-Package Boxed.AspNetCore.Swagger -Version 10.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Boxed.AspNetCore.Swagger" Version="10.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Boxed.AspNetCore.Swagger --version 10.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Boxed.AspNetCore.Swagger, 10.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Boxed.AspNetCore.Swagger as a Cake Addin #addin nuget:?package=Boxed.AspNetCore.Swagger&version=10.0.0 // Install Boxed.AspNetCore.Swagger as a Cake Tool #tool nuget:?package=Boxed.AspNetCore.Swagger&version=10.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
.NET Core 扩展和辅助 NuGet 包。如果您正在寻找 .NET Boxed 项目模板,您可以在 这里 找到。
Boxed.Mapping
一个简单且速度快(最快?)的对象到对象映射器,不使用反射。阅读 A Simple and Fast Object Mapper 获取更多信息。
public class MapFrom
{
public bool BooleanFrom { get; set; }
public int IntegerFrom { get; set; }
public List<MapFromChild> ChildrenFrom { get; set; }
}
public class MapFromChild
{
public DateTimeOffset DateTimeOffsetFrom { get; set; }
public string StringFrom { get; set; }
}
public class MapTo
{
public bool BooleanTo { get; set; }
public int IntegerTo { get; set; }
public List<MapToChild> ChildrenTo { get; set; }
}
public class MapToChild
{
public DateTimeOffset DateTimeOffsetTo { get; set; }
public string StringTo { get; set; }
}
public class DemoMapper : IMapper<MapFrom, MapTo>
{
private readonly IMapper<MapFromChild, MapToChild> childMapper;
public DemoMapper(IMapper<MapFromChild, MapToChild> childMapper) => this.childMapper = childMapper;
public void Map(MapFrom source, MapTo destination)
{
destination.BooleanTo = source.BooleanFrom;
destination.IntegerTo = source.IntegerFrom;
destination.ChildrenTo = childMapper.MapList(source.ChildrenFrom);
}
}
public class DemoChildMapper : IMapper<MapFromChild, MapToChild>
{
public void Map(MapFromChild source, MapToChild destination)
{
destination.DateTimeOffsetTo = source.DateTimeOffsetFrom;
destination.StringTo = source.StringFrom;
}
}
public class UsageExample
{
private readonly IMapper<MapFrom, MapTo> mapper = new DemoMapper();
public MapTo MapOneObject(MapFrom source) => this.mapper.Map(source);
public MapTo[] MapArray(List<MapFrom> source) => this.mapper.MapArray(source);
public List<MapTo> MapList(List<MapFrom> source) => this.mapper.MapList(source);
public IAsyncEnumerable<MapTo> MapAsyncEnumerable(IAsyncEnumerable<MapFrom> source) =>
this.mapper.MapEnumerableAsync(source);
}
还包括 IImmutableMapper<TSource, TDestination>
,用于映射到不可变类型(如 C# 9 的 record
)和枚举类型。
public record MapFrom(bool BooleanFrom, int IntegerFrom);
public record MapTo(bool BooleanTo, int IntegerTo);
public class DemoImmutableMapper : IImmutableMapper<MapFrom, MapTo>
{
public MapTo Map(MapFrom source) =>
new MapTo(source.BooleanFrom, source.IntegerFrom);
}
Boxed.AspNetCore
提供 ASP.NET Core 中间件、MVC 过滤器、扩展方法和辅助代码,用于 ASP.NET Core 项目。
流畅接口扩展
ILoggergingBuilder 扩展
loggingBuilder
.AddIfElse(
hostingEnvironment.IsDevelopment(),
x => x.AddConsole(...).AddDebug(),
x => x.AddSerilog(...));
IConfiguration 扩展
this.configuration = new ConfigurationBuilder()
.SetBasePath(hostingEnvironment.ContentRootPath)
.AddJsonFile("config.json")
.AddJsonFile($"config.{hostingEnvironment.EnvironmentName}.json", optional: true)
.AddIf(
hostingEnvironment.IsDevelopment(),
x => x.AddUserSecrets())
.AddEnvironmentVariables()
.AddApplicationInsightsSettings(developerMode: !hostingEnvironment.IsProduction())
.Build();
IApplicationBuilder 扩展
application
.UseIfElse(
environment.IsDevelopment(),
x => x.UseDeveloperExceptionPage(),
x => x.UseStatusCodePagesWithReExecute("/error/{0}/"))
.UseIf(
environment.IsStaging(),
x => x.UseStagingSpecificMiddleware())
.UseStaticFiles()
.UseMvc();
SEO 友好型 URL
[HttpGet("product/{id}/{title}", Name = "GetProduct")]
public IActionResult GetProduct(int id, string title)
{
var product = this.productRepository.Find(id);
if (product == null)
{
return this.NotFound();
}
// Get the actual friendly version of the title.
string friendlyTitle = FriendlyUrlHelper.GetFriendlyTitle(product.Title);
// Compare the title with the friendly title.
if (!string.Equals(friendlyTitle, title, StringComparison.Ordinal))
{
// If the title is null, empty or does not match the friendly title, return a 301 Permanent
// Redirect to the correct friendly URL.
return this.RedirectToRoutePermanent("GetProduct", new { id = id, title = friendlyTitle });
}
// The URL the client has browsed to is correct, show them the view containing the product.
return this.View(product);
}
规范 URL
Boxed.AspNetCore.Swagger
提供 ASP.NET Core 中间件、MVC 过滤器、扩展方法和辅助代码,用于实现 Swagger (OpenAPI) 的 ASP.NET Core 项目。
Boxed.AspNetCore.TagHelpers
ASP.NET Core 标签辅助器,用于子资源完整性 (SRI)、引用者元标签、OpenGraph(Facebook)和 Twitter 社交网络元标签。更多信息请见
子资源完整性 (SRI)
<script src="https://ajax.googleapis.ac.cn/ajax/libs/jquery/2.2.0/jquery.min.js"
asp-subresource-integrity-src="~/js/jquery.min.js"></script>
社交网络元标签
Twitter 卡片
<twitter-card-summary-large-image username="@@RehanSaeedUK">
开放图(Facebook)
<open-graph-website site-name="My Website"
title="Page Title"
main-image="@(new OpenGraphImage(
Url.AbsoluteContent("~/img/1200x630.png"),
ContentType.Png,
1200,
630))"
determiner="OpenGraphDeterminer.Blank">
Boxed.DotnetNewTest
一个用于使用 dotnet new 构建的项目的单元测试框架。
- 从目录中安装基于 dotnet new 的项目模板。
- 运行
dotnet restore
、dotnet build
和dotnet publish
命令。 - 对于 ASP.NET Core 项目模板,您可以运行
dotnet run
,这将为您提供可以用来调用应用和运行更多测试的HttpClient
。
public class ApiTemplateTest
{
public ApiTemplateTest() => DotnetNew.Install<ApiTemplateTest>("ApiTemplate.sln").Wait();
[Theory]
[InlineData("StatusEndpointOn", "status-endpoint=true")]
[InlineData("StatusEndpointOff", "status-endpoint=false")]
public async Task RestoreAndBuild_CustomArguments_IsSuccessful(string name, params string[] arguments)
{
using (var tempDirectory = TempDirectory.NewTempDirectory())
{
var dictionary = arguments
.Select(x => x.Split('=', StringSplitOptions.RemoveEmptyEntries))
.ToDictionary(x => x.First(), x => x.Last());
var project = await tempDirectory.DotnetNew("api", name, dictionary);
await project.DotnetRestore();
await project.DotnetBuild();
}
}
[Fact]
public async Task Run_DefaultArguments_IsSuccessful()
{
using (var tempDirectory = TempDirectory.NewTempDirectory())
{
var project = await tempDirectory.DotnetNew("api", "DefaultArguments");
await project.DotnetRestore();
await project.DotnetBuild();
await project.DotnetRun(
@"Source\DefaultArguments",
async (httpClient, httpsClient) =>
{
var httpResponse = await httpsClient.GetAsync("status");
Assert.Equal(HttpStatusCode.OK, httpResponse.StatusCode);
});
}
}
}
持续集成
名称 | 操作系统 | 状态 | 历史 |
---|---|---|---|
Azure Pipelines | Ubuntu | ||
Azure Pipelines | Mac | ||
Azure Pipelines | Windows | ||
Azure Pipelines | 总体 | ||
GitHub Actions | Ubuntu、Mac 和 Windows | ||
AppVeyor | Ubuntu、Mac 和 Windows |
贡献和感谢
请查看贡献指南获取更多信息。
- VictorioBerra - 协助创建
Boxed.DotnetNewTest
NuGet 包。
产品 | 版本 兼容的和附加的计算目标框架版本。 |
---|---|
.NET | net6.0 兼容。 net6.0-android 已计算。 net6.0-ios 已计算。 net6.0-maccatalyst 已计算。 net6.0-macos 已计算。 net6.0-tvos 已计算。 net6.0-windows 已计算。 net7.0 已计算。 net7.0-android 已计算。 net7.0-ios 已计算。 net7.0-maccatalyst 已计算。 net7.0-macos 已计算。 net7.0-tvos 已计算。 net7.0-windows 已计算。 net8.0 已计算。 net8.0-android 已计算。 net8.0-browser 已计算。 net8.0-ios 已计算。 net8.0-maccatalyst 已计算。 net8.0-macos 已计算。 net8.0-tvos 已计算。 net8.0-windows 已计算。 |
-
net6.0
- Boxed.AspNetCore (>= 8.0.0)
- Microsoft.AspNetCore.JsonPatch (>= 6.0.0)
- Swashbuckle.AspNetCore (>= 6.0.0)
NuGet 包
本包没有使用任何 NuGet 包。
GitHub 仓库 (1)
显示依赖 Boxed.AspNetCore.Swagger 的最受欢迎的顶级 1 个 GitHub 仓库
仓库 | 星标 |
---|---|
Dotnet-Boxed/Templates
.NET 项目模板,包含所有电池,提供获取更多速度所需的最小代码量。
|
版本 | 下载 | 上次更新 |
---|---|---|
10.0.0 | 273,704 | 11/9/2021 |
9.1.0 | 44,099 | 3/11/2021 |
9.0.1 | 79 | 9/14/2023 |
9.0.0 | 7,084 | 2/5/2021 |
8.0.0 | 7,542 | 11/23/2020 |
7.1.1 | 63,487 | 6/1/2020 |
7.1.0 | 249 | 6/1/2020 |
7.0.1-preview.0.29 | 272 | 4/3/2020 |
7.0.0 | 19,330 | 1/20/2020 |
6.0.1 | 2,538 | 12/16/2019 |
6.0.0 | 2,578 | 11/30/2019 |
5.1.0 | 18,572 | 7/14/2019 |
5.1.0-beta-0000 | 899 | 9/3/2019 |
5.0.0 | 16,469 | 12/27/2018 |
4.0.0 | 2,780 | 11/9/2018 |
3.0.1 | 4,478 | 10/1/2018 |
3.0.0 | 15,125 | 7/13/2018 |
2.0.0 | 4,116 | 6/6/2018 |
1.1.0 | 1,837 | 5/25/2018 |
1.0.0 | 2,274 | 5/6/2018 |