kubb-labs / kubb

The ultimate toolkit for working with APIs.
https://kubb.dev
MIT License
670 stars 54 forks source link

Imports not taking into consideration models transformation name #1042

Closed vitorcamachoo closed 3 months ago

vitorcamachoo commented 3 months ago

What version of kubb is running?

2.19.6

What platform is your computer?

MacOs

What version of external packages are you using(@tanstack-query, MSW, React, Vue, ...)

"@kubb/cli": "^2.19.6", "@kubb/core": "^2.19.6", "@kubb/plugin-oas": "2.19.6", "@kubb/swagger": "2.19.6", "@kubb/swagger-client": "2.19.6", "@kubb/swagger-tanstack-query": "2.19.6", "@kubb/swagger-ts": "2.19.6",

What steps can reproduce the bug?

// Kubb config

const transformers = {
    name(name: string, type?: "function" | "type" | "file" | undefined) {
        if (type === 'file') return `${name[0].toLowerCase() + name.slice(1)}`;
        return name;
    },
};

export default defineConfig({
    root: '.',
    input: { path: './api/schema.yaml' },
    output: {
        path: './src/api',
        clean: true,
    },
    plugins: [
        pluginOas({ output: false }),
        pluginTs({
            output: { path: './model' },
            enumType: 'asConst',
            transformers,
        }),
        pluginClient({
            client: { importPath: '../../axios/custom-instance' },
            output: { path: './api/index.ts' },
        }),
    ],
});

Based on this configuration, I was expecting that the @kubb/swagger-client would be aware of the name transformation. What is happening is that when importing the model types, the suffix "Schema" is not being added to the import: Screenshot 2024-06-18 at 11 50 25

Screenshot 2024-06-18 at 11 50 38

How often does this bug happen?

Every time

What is the expected behavior?

No response

Swagger/OpenAPI file?

No response

Additional information

No response

stijnvanhulle commented 3 months ago

Will be fixed as part of https://github.com/kubb-labs/kubb/issues/1031