-
-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Open
Description
I'm trying to find a way to directly import the generated api calls with minimal boilerplate.
Currently, that's the most minimal I found:
import { Configuration, Post, PostsApi } from "./generated-sources/openapi";
const configuration = new Configuration({
basePath: window.location.origin,
});
const postsApi = new PostsApi(configuration);
const loadedPosts = await postsApi.getPosts();
Which is way too much boilerplate imo (since it needs to be done manually for each new api resource)
I found a way to import an existing axios instance (with the base url already there, as well as interceptors) but the api call functions (like getPosts()) isn't something we can import right away as it still needs some sort of initialization.
My goal:
import { getPosts } from "./generated-sources/openapi";
const loadedPosts = await postsApi.getPosts();
Is there a way to do that (maybe with a template)?
Metadata
Metadata
Assignees
Labels
No labels