fix(typescript-axios): send non-object explode query params as a single value

Merged
TH
6d ago
+95-12

Since #16898 explode query param that is not primitive type goes through Object.entries. For oneOf of primitives (Cursor = number | string from #18999) that splits string into chars (cursor='abc' gives ?0=a&1=b&2=c) and drops numbers. Template cant tell these params apart from object ones: both have isModel and isAnyType, only composed schemas differ, so guard is at runtime, Object.entries only for non-null, non-array object, else value goes under param name

Checked built client at runtime: cursor='abc' and 7 now go as ?cursor=abc / ?cursor=7, object params (filter={x:'1'}, allOf and oneOf of objects) give same query as before. Added test in TypeScriptAxiosClientCodegenTest. Only echo_api typescript-axios sample changes

Fixes #18999

PR checklist

  • 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
    
    Commit all changed files.
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

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


Summary by cubic

Fixes typescript-axios explode query params so non-object values are sent as a single query parameter. Previously, oneOf params of primitive types (Cursor = number | string) were run through Object.entries, which split strings into characters (cursor='abc' → ?0=a&1=b&2=c) and dropped numbers.

  • Added a runtime check to spread with Object.entries only when the value is a non-null, non-array object; primitives and arrays are set directly under the param name.
  • Object params, including allOf and oneOf of objects, behave as before.
  • Added a regression test and updated the echo_api sample.

Fixes #18999.