How should enum arrays and flags expand in URL templates?

未關閉
#898 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
18/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
openapi, python
領域
api

研究方向

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.

由索引模型根據 Issue 內容生成。

描述

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.

主要語言
Python
星號
31
分支
48
平均合併
16 小時 36 分鐘
30 天內合併 PR
73

環境準備

在 Codespaces 中開啟

在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

microsoft/kiota-python 的其他 Issue

查看 microsoft/kiota-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。