'Best practice for modeling RESTapi objects in client
I'm currently in the proces of creating a .net-core Rest api client library. I want the library to contain objects that represents the different objects returned by the api, fx. ApiClient.GetAccountById(string accountId), which then returns an Account class.
The problem is that the json schemas provided by the documentation uses URI links to refer to further endpoints in the object, fx. an account could have a reference to the contra account etc. But i don't know the best practice to implement this in the model.
My first idea was to have a method in the model called Account.GetContraAccount() that simply returns the contra account object. If this is the best way to do it, is there a way to automate this? Since it is a rather large api (100+ models) doing this approach manually would take quite a long time to implement.
Another idea i had was simply to create a method for each link. For example:
ApiClient.GetContraAccountFromAccountById(string accountId), although i feel like this would make it quite confusing to navigate the objects.
So what would be the best way to do this?
They do not have OpenApi
Here is an example of one of the json schemas: https://restapi.e-conomic.com/schema/accounts.get.schema.json
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
