How should enum arrays and flags expand in URL templates?

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

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
18/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
openapi, python
Lĩnh vực
api

Hướng nghiên cứu

The behaviour lives in RequestInformation query and path expansion in kiota_abstractions/request_information.py, with the enum handling introduced in #223 and kept in #883. Reproduce the four printed URLs from the issue before touching anything. Done would mean the maintainers have stated whether an enum list is an array or a flags value, and any change keeps the non-exploded %2C separator for flags.

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

Mô tả

I'd like to clarify the enum-collection contract before proposing a change to request URL construction.

On current main 17b952f81ea2a4d46bb44b6fe6b253578a0cf481, these public calls produce different URLs:

from enum import Enum
from kiota_abstractions.method import Method
from kiota_abstractions.request_information import RequestInformation

class Colour(Enum):
    RED = "red"
    BLUE = "blue"

for values in (["red", "blue"], [Colour.RED, Colour.BLUE]):
    request = RequestInformation(Method.GET, "https://example.com/items{?colour*}")
    request.query_parameters["colour"] = values
    print(request.url)
https://example.com/items?colour=red&colour=blue
https://example.com/items?colour=red%2Cblue

Likewise, {/colour*} produces separate segments for the string list but one comma-joined segment for the enum list. I ran these locally on Windows/CPython 3.13.7; no service call is involved.

For a true array, repeated keys/segments match RFC6570. However, enum joining was introduced in #223 and deliberately preserved in #883, and enum lists can be used as a scalar representation in the form writer. I don't want to remove a flags convention while fixing array expansion.

Could you confirm whether generated query/path enum lists always represent array parameters, or whether they can also represent a single flags enum? If both forms exist, what should distinguish them at URI-template expansion time?

A local proposal that retains the collection makes the array examples work, but also changes non-exploded list separators from %2C to literal commas and normalizes boolean-valued enum elements differently. I'm keeping that runtime change unpublished until the intended contract is clear.

Ngôn ngữ chính
Python
Star
31
Fork
48
Merge trung bình
16 giờ 36 phút
Pull request đã merge (30 ngày)
73

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

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 microsoft/kiota-python

Tất cả issue của microsoft/kiota-python

Issue tương tự

Thêm issue về Python

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.