Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

[Bug]: Kiota generation is weird because of the OpenAPI scheme

オープン
#3,632 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 8 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
csharp, openapi

調査の方向性

提供された OpenAPI のレスポンススキーマと Kiota 1.6.77 を使って問題を再現し、その後、生成された C# のレスポンスタイプと、この OpenAPI 操作を構築するソースを追跡します。生成されたオーバーロードを、提案された明示的なコレクションスキーマと比較します。レスポンスが意図した型付きモデルで表現され、古い重複メソッドが存在しなければ完了です。

索引モデルが issue の本文から書いたものです。

説明

bug cri triage
What happened?

For a simple orders table, I get this path in the OpenAPI document

"/Order": {
    "get": {
      "tags": [
        "Order"
      ],
      "description": "Returns entities.",
      "parameters": [
        {
          "name": "X-MS-API-ROLE",
          "in": "header",
          "schema": {
            "type": "string"
          }
        },
        {
          "name": "Authorization",
          "in": "header",
          "schema": {
            "type": "string"
          }
        },
        {
          "name": "$select",
          "in": "query",
          "description": "A comma separated list of fields to return in the response.",
          "schema": {
            "type": "string"
          }
        },
        {
          "name": "$filter",
          "in": "query",
          "description": "An OData expression (an expression that returns a boolean value) using the entity's fields to retrieve a subset of the results.",
          "schema": {
            "type": "string"
          }
        },
        {
          "name": "$orderby",
          "in": "query",
          "description": "Uses a comma-separated list of expressions to sort response items. Add 'desc' for descending order, otherwise it's ascending by default.",
          "schema": {
            "type": "string"
          }
        },
        {
          "name": "$first",
          "in": "query",
          "description": "An integer value that specifies the number of items to return. Default is 100.",
          "schema": {
            "type": "integer"
          }
        },
        {
          "name": "$after",
          "in": "query",
          "description": "An opaque string that specifies the cursor position after which results should be returned.",
          "schema": {
            "type": "string"
          }
        }
      ],
      "responses": {
        "400": {
          "description": "BadRequest"
        },
        "401": {
          "description": "Unauthorized"
        },
        "403": {
          "description": "Forbidden"
        },
        "404": {
          "description": "NotFound"
        },
        "200": {
          "description": "OK",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "value": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Order"
                    }
                  },
                  "nextLink": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "post": {
      "tags": [
        "Order"
      ],
      "description": "Create entity.",
      "parameters": [
        {
          "name": "X-MS-API-ROLE",
          "in": "header",
          "schema": {
            "type": "string"
          }
        },
        {
          "name": "Authorization",
          "in": "header",
          "schema": {
            "type": "string"
          }
        }
      ],
      "requestBody": {
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Order_NoAutoPK"
            }
          }
        },
        "required": true
      },
      "responses": {
        "400": {
          "description": "BadRequest"
        },
        "401": {
          "description": "Unauthorized"
        },
        "403": {
          "description": "Forbidden"
        },
        "404": {
          "description": "NotFound"
        },
        "201": {
          "description": "Created",
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "value": {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/Order"
                    }
                  }
                }
              }
            }
          }
        },
        "409": {
          "description": "Conflict"
        }
      }
    }
  }

Then I run Kiota in the document and I get the following

[Obsolete("This method is obsolete. Use GetAsOrderGetResponseAsync instead.")]
public async Task<global::TestSimple.Client.Order.OrderResponse?> GetAsync(Action<RequestConfiguration<global::TestSimple.Client.Order.OrderRequestBuilder.OrderRequestBuilderGetQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default) { /*stuff*/}

public async Task<global::TestSimple.Client.Order.OrderGetResponse?> GetAsOrderGetResponseAsync(Action<RequestConfiguration<global::TestSimple.Client.Order.OrderRequestBuilder.OrderRequestBuilderGetQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default) { /* stuff */}

From what I understood, this is a problem on the generated OpenAPI Specification that is not enough typed (the object should be an explicit object like "OrderCollection"

"200": {
  "description": "OK",
  "content": {
    "application/json": {
      "schema": {
        "type": "object",
        "properties": {
          "value": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Order"
            }
          },
          "nextLink": {
            "type": "string"
          }
        }
      }
    }
  }
}
Version

1.6.77

What database are you using?

Azure SQL

What hosting model are you using?

Custom Docker host

Which API approach are you accessing DAB through?

REST

Relevant log output

Code of Conduct
  • I agree to follow this project's Code of Conduct
主要言語
C#
スター
1.5k
フォーク
371
平均マージ
8日 19時間
マージ済み PR(30日)
10

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

Azure/data-api-builder のほかの issue

Azure/data-api-builder の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。