You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm consuming a gigantic API, with hundreds of endpoints, but I only really need one or two. Even generating modular output and splitting endpoint into files by first tag generates quite huge classes.
Is there a way to filter what endpoints end up being generated into the http client class?
The text was updated successfully, but these errors were encountered:
Hi!
I had a similar issue, and I resolved it by using '@apidevtools/swagger-parser'.
I split the OpenAPI file into smaller pieces before passing them to the generator.
code example:
export async function splitOpenAPIFile(inputFilePath: string, outputDir: string): Promise<void> {
const api = await SwaggerParser.parse(inputFilePath) as OpenAPIV3.Document;
const resources: { [key: string]: OpenAPIV3.Document } = {};
for (const [path, methods] of Object.entries(api.paths)) {
const resourceName = path.split('/')[1];
if (!resources[resourceName]) {
resources[resourceName] = {
...api,
paths: {}
};
}
resources[resourceName].paths[path] = methods;
}
await ensureDir(outputDir);
for (const [resourceName, resourceApi] of Object.entries(resources)) {
const resourceFilePath = path.join(outputDir, `${resourceName}.json`);
await writeJson(resourceFilePath, resourceApi, { spaces: 2 });
}
}
Hi, I'm consuming a gigantic API, with hundreds of endpoints, but I only really need one or two. Even generating modular output and splitting endpoint into files by first tag generates quite huge classes.
Is there a way to filter what endpoints end up being generated into the http client class?
The text was updated successfully, but these errors were encountered: