Feature request: Fields like invoiceID/projectId/etcId should be non-nullable on fetched resources
adamburgess opened this issue · 1 comments
SDK you're using (please complete the following information):
- Version 4.27.0
Is your feature request related to a problem? Please describe.
A problem throughout this library is the types of fields that should always exist after fetching a resource are typed as nullable.
For example:
const project = (await xero.projectApi.getProject(tenantId, projectId)).body;
type idType = typeof project.projectId;
// idType is string | undefined
in this case, since I have fetched it, it must have an id. So it should be string
and not string | undefined
.
Describe the solution you'd like
I think the base type (e.g. Invoice) should be the resource with all the non-optional fields... non-optional.
If the fields need to be optional, then a sub-interface should do that, like a PartialInvoice for example.
I hope this can be fixed, because it is not fun littering invoice.invoiceID!
everywhere...
Hey @adamburgess we've had this particular request come up previously on one of our other repos and unfortunately I'm not finding the more detailed explanation at the moment but the gist of it is that this is a limitation of OpenAPI - if we were to make the ID required on fetched resources we would have to maintain near duplicate models for most resources with the ID requirement being the differentiator. This would significantly increase the size of our spec files as well as the SDK libraries we generate from the spec files.