零度框架升级到 Aspire 13.0 版本
This commit is contained in:
1 parent
41f6c147d5
commit
b11ba4f6a5
50 files changed
+336
-446
No files matched your search
+43
@@ -0,0 +1,43 @@
|
||||
// Copyright (c) HelloShop Corporation. All rights reserved.
|
||||
// See the license file in the project root for more information.
|
||||
|
||||
using Microsoft.AspNetCore.OpenApi;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
using Microsoft.OpenApi;
|
||||
|
||||
namespace HelloShop.ServiceDefaults.Infrastructure
|
||||
{
|
||||
public sealed class AcceptLanguageHeaderDocumentTransformer : IOpenApiDocumentTransformer
|
||||
{
|
||||
public Task TransformAsync(OpenApiDocument document, OpenApiDocumentTransformerContext context, CancellationToken cancellationToken)
|
||||
{
|
||||
var parameter = new OpenApiParameter
|
||||
{
|
||||
Name = HeaderNames.AcceptLanguage,
|
||||
In = ParameterLocation.Header,
|
||||
Required = false,
|
||||
Schema = new OpenApiSchema
|
||||
{
|
||||
Type = JsonSchemaType.String,
|
||||
Default = "zh-CN",
|
||||
Enum = ["zh-CN", "en-US"]
|
||||
}
|
||||
};
|
||||
|
||||
foreach (var path in document.Paths.Values)
|
||||
{
|
||||
if (path.Operations != null)
|
||||
{
|
||||
foreach (var operation in path.Operations.Values)
|
||||
{
|
||||
operation.Parameters ??= [];
|
||||
operation.Parameters.Add(parameter);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user