How should enum arrays and flags expand in URL templates?

Offen
#898 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
18/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
openapi, python
Bereich
api

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
Python
Sterne
31
Forks
48
Ø Merge
16 Std. 36 Min.
Gemergte PRs (30 T.)
73

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus microsoft/kiota-python

Alle Issues in microsoft/kiota-python

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.