API Casing in Typesense and Dotnet Client Code

TLDR satish sought clarification on API casing standards. Jason explained that Typesense API uses snake_case, while the dotnet client code uses camelCase. Rune further elaborated on how to override the default properties in dotnet.

Powered by Struct AI
Join the chat
Apr 04, 2022 (19 months ago)
Photo of md5-21068ce5c0a7db9d103fad551dbefbc7
04:38 PM
What is the casing followed in API, Is that a snake case or Camel casing? I am looking at dotnet client code and its using camel casing but the docs shows snake case
Photo of md5-8813087cccc512313602b6d9f9ece19f
06:05 PM
The Typesense API itself uses snake_case for API params. So the client might be translating from camel case to snake case before sending to Typesense.

CC: Rune who authored the dot net client
Photo of md5-a5a4aaa05c3354be4cd94c3d525ff5d7
06:08 PM
satish It uses camelCase by default, but you can override it on the document classes you want to insert into Typesense, here is an example:
public int HouseNumber { get; set; }

So you can set the names to whatever you like. 🙂
You could also do something weird like:
public int HouseNumber { get; set; } 

Full class example using snake_case:
public class Address
    public string Id { get; set; }
    public int HouseNumber { get; set; }
    public string AccessAddress { get; set; }
    public string MetadataNotes { get; set; }

Also all API params are translated to snake_case if you use the default implementation shown in the docs, example doing a search.
var query = new SearchParameters("Smed", "access_address");
var searchResult = await typesenseClient.Search<Address>("Addresses", query);
Apr 05, 2022 (19 months ago)
Photo of md5-21068ce5c0a7db9d103fad551dbefbc7
02:10 AM
Thanks Rune.