help wantedtype: enhancement
描述
Related to https://github.com/RSuter/NSwag/issues/1216. The fix that removed ExpandoObject and used any instead worked for most of our cases, but surfaced another bug.
When generating TypeScript for a Web API method that accepts a dynamic, ExpandoObject, or object` parameter, the wrong code is generated.
It is generating this:
foo(bar: any | null): Observable<void> {
let url_ = this.baseUrl + "/api/Baz/Foo?";
if (bar === undefined)
throw new Error("The parameter 'bar' must be defined.");
else
url_ += "bar=" + encodeURIComponent("" + bar) + "&";
...
}
Instead of this:
foo(bar: any | null): Observable<void> {
let url_ = this.baseUrl + "/api/Baz/Foo";
url_ = url_.replace(/[?&]$/, "");
const content_ = JSON.stringify(bar);
...
In other words, its treating dynamic, ExpandoObject, or object parameters the same as it treats primitives. It instead should be calling JSON.stringify on them.