-
ServiceStack v6 user here. Started using TS lately, and wanted to fiddle around with the TS client. The API I'm working against, heavily utilizes "name" on attribute "DataMember". For instance, a member of an API response looks like this: [DataMember(Name = "darkMode", Order = 1)]
public string PrefersDarkMode{ get; set; } JSON response is something like this: "responseObject": {
"darkMode": "",
} While it's served correctly via json resonse (property is 'darkMode'), when I try to generate types (with x tool, or by directly accessing // @DataMember(Name="darkMode", Order=1)
public PrefersDarkMode: string; The TS property name does not match the response property name (even though the serialized name is there as a comment above the type member). I checked all the code generation properties in order to find something that alters this behavior and can't seem to find something related. I might be missing something obvious, but all my searches regardind "servicestack" and "datamember" in forums were unsuccessful. Thanks in advance |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
Can you provide the complete C# and generated TypeScript Request DTO please. |
Beta Was this translation helpful? Give feedback.
-
Here is an actual request. [Route("/sites/{Id}", "GET")]
[DataContract]
public class SiteRequest : IGet, IReturn<SiteResponse>
{
[DataMember(Order = 1)] public long Id { get; set; }
} And the generated types. // @Route("/sites/{Id}", "GET")
// @DataContract
export class SiteRequest implements IReturn<SiteResponse>, IGet {
// @DataMember(Order=1)
public id: number
public constructor(init?: Partial<SiteRequest>) {
;(Object as any).assign(this, init)
}
public getTypeName() {
return 'SiteRequest'
}
public getMethod() {
return 'GET'
}
public createResponse() {
return new SiteResponse()
}
} |
Beta Was this translation helpful? Give feedback.
-
great thanks, this should now be supported from v6.3.1+ that's now available on MyGet. |
Beta Was this translation helpful? Give feedback.
great thanks, this should now be supported from v6.3.1+ that's now available on MyGet.