microsoft / microsoft/OpenAPI.NET
Consider returning reference type from `AddComponent` API
オープン
まだ誰も着手していません。
- 主要言語
- C#
- スター
- 1.6k
- フォーク
- 286
- 平均マージ
- 6時間 38分
- マージ済み PR(30日)
- 35
説明
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.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、AddComponent API の実装と、ドキュメントコンポーネントの登録に関する既存のカバレッジを確認します。現在の boolean 結果を AddOperationTransformer の例と比較し、返された参照が挿入されたスキーマを表していることを確認するとともに、既存の登録動作が維持されていることを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- csharp
- 領域
- api, backend-api-design
- issue の種類
- 機能追加
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100