How to configure SDK plugin nesting to get Class.v1.method() structure?
#3439
-
|
Current config export default defineConfig({
...
plugins: [
{
name: "@hey-api/sdk",
operations: "byTags",
},
],
});I want the generated SDK to have this structure: Current generated SDK |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 11 replies
-
|
Hi @wellington-vell! I'm Dosu and I’m helping the openapi-ts team. You can achieve the export default defineConfig({
// ...
plugins: [
{
name: "@hey-api/sdk",
operations: {
strategy: "single", // Required for class-based SDK with nesting
nesting(operation) {
// Parse your tag (e.g., "HealthV1") into ["Health", "v1"]
const tag = operation.tags?.[0] || "default";
const versionMatch = tag.match(/^(.+?)(V\d+)$/i);
if (versionMatch) {
const [, baseName, version] = versionMatch;
return [baseName, version.toLowerCase(), operation.operationId || operation.method];
}
return [tag, operation.operationId || operation.method];
},
},
},
],
});The Note: The To reply, just mention @dosu. How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other |
Beta Was this translation helpful? Give feedback.
-
|
@wellington-vell Does what Dosu told you help? You can't get the same exact structure today because there's no support for mixed containers (root class and nested objects), but you should be able to produce nested classes with the |
Beta Was this translation helpful? Give feedback.
@wellington-vell you just need to do what Dosu told you.