Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#3,632 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Ít trao đổi
Công nghệ
csharp, openapi
Lĩnh vực
api, backend-api-design

Hướng nghiên cứu

Tái hiện sự cố với schema phản hồi OpenAPI được cung cấp và Kiota 1.6.77, sau đó lần theo các kiểu phản hồi C# được tạo ra và mã nguồn xây dựng operation OpenAPI này. So sánh các overload được tạo ra với schema collection tường minh được đề xuất; hoàn tất khi phản hồi được biểu diễn bằng model có kiểu như dự kiến và không còn method trùng lặp đã lỗi thời.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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
Ngôn ngữ chính
C#
Star
1.5k
Fork
372
Merge trung bình
9 ngày 1 giờ
Pull request đã merge (30 ngày)
13

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Azure/data-api-builder

Tất cả issue của Azure/data-api-builder

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.