Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#3,632 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
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
平均合并
7 天 5 小时
30 天内合并 PR
8

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

Azure/data-api-builder 的其他 Issue

查看 Azure/data-api-builder 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。