Auto generate typescript types from models

I’m working on a Nextjs project with typescript. Normally when doing this, I prefer to setup auto generated types from the endpoints I consume. In this case from Meaning that all the models and custom fields, whether it is pages, sections or cms data models, will have its equivalent types auto generated and creating a reliable contract between the cms and codebase. I often do this in two ways:

  1. Using openapi-generator-cli @openapitools/openapi-generator-cli - npm. But this doesn’t seem possible with the the current rest api ( Drag & Drop Headless CMS), as it is not using swagger?

  2. Using GraphQL with graphql-codegen and its typescript plugins. This works just fine. But the GraphQL schamas are limited by the look of it. All the models setup in builder often is just defined as json in the schema and just reads as any type. So this won’t give the wanted result.

I know that a lot of the types makes sense to do manually when it comes to components, when using the registerComponent with the sdk, as this is codefirst. But some data won’t be, like a cms data model for the navigation. So getting a reliable contract between and the codebase would be a great feature. And that is what auto generated types deliver.

So my question is, if you have an approach to achieve? Getting types for the all the models and custom fields you setup in Or any other best practice to get model types?

Thanks in advance. : )