Hi, I’m evaluating Strapi to build some applications, with browser and mobile frontends. I’m wondering if there’s an easy way to auto-generate SDKs for a backend built with Strapi, with different compilation targets, like TypeScript (with request and response types) for the frontend, or iOS/Android. Possibly export an OpenAPI definition and use standard tooling to generate the SDKs from that?
Thanks
I do this. I use Strapi documentation plugin to generate an OpenAPI Spec, then use the OpenAPI Generator to generate a Typescript-fetch SDK.
Keep in mind the Strapi documentation plugin might require some “massaging” to get it to generate a valid spec, but this is easily done by overriding specific OpenAPI definitions for specific content models.
You got any examples of how you run this ? @badsyntax currently I use this package Strapi2TypeScript
@Eventyret Here’s my strapi repo: GitHub - badsyntax/richardwillis.info-strapi
Here’s my npm scripts (in a different repo) where i generate the client: richardwillis.info/package.json at f53848aa82462387c28566a9cce1d90677a10a33 · badsyntax/richardwillis.info · GitHub
Here’s the generated SDK: richardwillis.info/src/features/api/strapi at master · badsyntax/richardwillis.info · GitHub</ti
Here’s an example TypeScript model: richardwillis.info/Project.ts at f53848aa82462387c28566a9cce1d90677a10a33 · badsyntax/richardwillis.info · GitHub
Here’s how I instantiate the SDK API’s: richardwillis.info/apiClient.ts at f53848aa82462387c28566a9cce1d90677a10a33 · badsyntax/richardwillis.info · GitHub
And here’s how I consume the API: richardwillis.info/api.ts at f53848aa82462387c28566a9cce1d90677a10a33 · badsyntax/richardwillis.info · GitHub