According to the https://docs.servicestack.net/api-design, I create my model like this:
[Route("/my-request")]
public class MyRequest : IGet, IHasQueryParams, IReturn<MyResponse>
{
public Dictionary<string, string>? QueryParams {get; set;}
}
Now I generate a Typescript DTO:
// @Route("/my-request")
export class MyRequest implements IReturn<MyResponse>, IGet
{
public queryParams?: { [index:string]: string; };
public constructor(init?: Partial<MyRequest>) { (Object as any).assign(this, init); }
public getTypeName() { return 'MyRequest'; }
public getMethod() { return 'GET'; }
public createResponse() { return new Array<MyResponse>(); }
}
Now, in my code, I send data like this:
async getData(
param1: string,
param2: string,
param3: string
): Promise<MyResponse> {
return await this.client.get(
new MyRequest({
queryParams: { param1, param2, param3 },
})
);
}
It generates the request like this:
https://localhost:5003/api/MyRequest?queryParams=%5Bobject%20Object%5D
Expected:
https://localhost:5003/api/MyRequest?param1=...¶m2=...¶m3=...
According to the https://docs.servicestack.net/api-design, I create my model like this:
Now I generate a Typescript DTO:
Now, in my code, I send data like this:
It generates the request like this:
Expected: