Consider returning reference type from `AddComponent` API
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 45/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- csharp
- Lĩnh vực
- api, backend-api-design
Hướng nghiên cứu
Bắt đầu bằng cách xác định phần triển khai API AddComponent và mọi coverage hiện có cho việc đăng ký component của document. So sánh kết quả boolean hiện tại của nó với ví dụ AddOperationTransformer, sau đó xác minh rằng reference được trả về đại diện cho schema đã chèn, trong khi hành vi đăng ký hiện có vẫn được giữ nguyên.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
The AddComponent API currently returns a boolean that indicates if the addition of the component to the document registry succeeded.
It would be nice if the API returned a reference to the item that was just constructed. In an M.A.OpenAPI transformer, I currently need to write:
options.AddOperationTransformer((operation, context, cancellationToken) =>
{
var schemaService = context.ApplicationServices.GetRequiredKeyedService<IOpenApiSchemaService>(context.DocumentName);
if (context.Description.RelativePath == "error")
{
var errorSchema = schemaService.GetOrCreateSchema(typeof(ProblemDetails));
context.Document.AddComponent("Error", errorSchema);
operation.Responses["500"] = new OpenApiResponse
{
Description = "Error",
Content =
{
["application/problem+json"] = new OpenApiMediaType
{
Schema = new OpenApiSchemaReference("Error", context.Document),
},
},
};
}
return Task.CompletedTask;
});
but would like to write:
options.AddOperationTransformer((operation, context, cancellationToken) =>
{
var schemaService = context.ApplicationServices.GetRequiredKeyedService<IOpenApiSchemaService>(context.DocumentName);
if (context.Description.RelativePath == "error")
{
var errorSchema = schemaService.GetOrCreateSchema(typeof(ProblemDetails));
var insertedSchema = context.Document.AddComponent("Error", errorSchema);
operation.Responses["500"] = new OpenApiResponse
{
Description = "Error",
Content =
{
["application/problem+json"] = new OpenApiMediaType
{
Schema = insertedSchema,
},
},
};
}
return Task.CompletedTask;
});
cc: @baywet I couldn't see if an API that did this existed already and figured I'd add the proposal.
- Ngôn ngữ chính
- C#
- Star
- 1.6k
- Fork
- 286
- Merge trung bình
- 6 giờ 38 phút
- Pull request đã merge (30 ngày)
- 35
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/OpenAPI.NET
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
microsoft/OpenAPI.NET#2798 ·
-
microsoft/OpenAPI.NET#3056 · 1 bình luận · 1 reaction · 2 người được giao ·
-
type:breaking-change
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 52/100
microsoft/OpenAPI.NET#3014 · 2 bình luận ·
-
Implement equality (`IEquatable<T>` and override object.Equals/GetHashCode) for object models Đang mởhelp wanted
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
microsoft/OpenAPI.NET#2989 · 3 bình luận ·
-
help wanted type:feature
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
microsoft/OpenAPI.NET#2967 · 18 bình luận · 1 reaction ·
Tất cả issue của microsoft/OpenAPI.NET
Issue tương tự
-
Add more to the documentation Đang mở:watch: Not Triaged dotnet-fsharp/svc
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
-
Client customer-reported needs-team-attention question Service Attention WebPubSub
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Azure/azure-sdk-for-net#63292 · 3 bình luận · 1 reaction ·
-
Issue-Enhancement Needs-Triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 86/100
PowerShell/PowerShell#28061 · 2 reaction ·
-
dependencies needs-team-triage server-Azure.Mcp
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
aspnet-core/svc aspnetcore-signalr/subsvc doc-enhancement Pri2 SignalR
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 88/100
dotnet/AspNetCore.Docs#37729 ·