[typescript-fetch] Convert request body set to array

RG
2d ago
+97-1

When a set is passed into a request body, the client will attempt to map the objects in the set to JSON, but Set doesn't have a map method. To resolve this, the set is wrapped in Array.from.

Fixes #24887

@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka @joscha @KannaKim

  • Read the contribution guidelines.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Fixes serialization of request bodies typed as sets in the TypeScript fetch client.

When an array body parameter has uniqueItems: true, the generated client now wraps the value in Array.from() before mapping it to JSON. Previously, the code called .map() directly on the value, which fails at runtime because Set doesn't have a map method.

  • Adds a test with a new OpenAPI 3.1 spec covering object, array, and set request bodies.