kubb-labs / kubb

OpenAPI to TypeScript, React-Query, Zod, Zodios, Faker.js, MSW and Axios.
https://kubb.dev
MIT License
568 stars 40 forks source link

Client generated axios has incorrect pathing #1068

Closed Samuel-Morgan-Tyghe closed 1 week ago

Samuel-Morgan-Tyghe commented 1 week ago

What version of kubb is running?

2.12.2

What platform is your computer?

macos

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

"@kubb/cli": "^2.12.3", "@kubb/core": "^2.12.3", "@kubb/plugin-redoc": "^2.19.6", "@kubb/swagger": "^2.21.0", "@kubb/swagger-client": "^2.21.0", "@kubb/swagger-faker": "^2.19.5", "@kubb/swagger-msw": "^2.19.5", "@kubb/swagger-tanstack-query": "^2.12.3", "@kubb/swagger-ts": "^2.21.0", "@kubb/swagger-zod": "^2.12.3",

What steps can reproduce the bug?

paths to index files when there are none

    pluginClient({
      client: { importPath: "@shared/services/api/swaggerAxiosClient" },
      group: { output: "./axios/{{tag}}Service", type: "tag" },
      transformers: {
        name: (name) => `${name}Service`,
      },
    }),

output

export * as retailService from "./axios/retailService/index";
export * as ordersService from "./axios/ordersService/index";
export * as documentsService from "./axios/documentsService/index";
export * as capitalCallsService from "./axios/capitalCallsService/index";
export * as waitingListControllerService from "./axios/waitingListControllerService/index";
...

but these index files dont exist

How often does this bug happen?

None

What is the expected behavior?

they path to individual file, or theres index files at the axios sub folders

Swagger/OpenAPI file?

api-documentation.yaml.zip

Additional information

axios ├── actuatorService │ ├── beansService.ts │ ├── caches2Service.ts │ ├── cachesCache2Service.ts │ ├── cachesCacheService.ts │ ├── cachesService.ts │ ├── conditionsService.ts │ ├── configpropsPrefixService.ts │ ├── configpropsService.ts │ ├── envService.ts │ ├── envToMatchService.ts │ ├── healthPathService.ts │ ├── healthService.ts │ ├── heapdumpService.ts │ ├── infoService.ts │ ├── linksService.ts │ ├── loggersName2Service.ts │ ├── loggersNameService.ts │ ├── loggersService.ts │ ├── mappingsService.ts │ ├── metricsRequiredMetricNameService.ts │ ├── metricsService.ts │ ├── prometheusService.ts │ ├── scheduledtasksService.ts │ └── threaddumpService.ts ├── assetsService │ └── getWatermarkedPdfService.ts ├── capitalCallsService │ ├── confirmCapitalCallService.ts │ ├── confirmExternalCapitalCallService.ts │ ├── createCapitalCallService.ts │ ├── createExternalCapitalCallPaymentService.ts │ ├── executeCapitalCallPaymentService.ts │ ├── executeDistributionsService.ts │ ├── getCapitalCallDetailsService.ts │ ├── getCapitalCallService.ts │ └── getCapitalCallSummaryService.ts ├── documentsService │ ├── createDocumentService.ts │ ├── getDocumentService.ts │ ├── getDocumentsForInvestorService.ts │ ├── issueDocumentsToUsersService.ts │ ├── issueDocumentsToUsersV2Service.ts │ └── presignedUploadUrlService.ts ├── fundsService │ ├── getFinancialDocumentRetrievalItems2Service.ts │ ├── getFinancialDocumentRetrievalItemsService.ts │ ├── getFundFinancialDocumentTypesService.ts │ ├── getIssuedDocumentsService.ts │ ├── getLimitedPartnersService.ts │ ├── getSerializedByIdService.ts │ ├── getSerializedFundsByCompanyIdService.ts │ ├── requestMissingFinancialDocumentsService.ts │ └── requestMissingFinancialDocumentsV2Service.ts ├── onboardingTasksService │ ├── getAllService.ts │ ├── getByIdService.ts │ ├── getQuestionsService.ts │ ├── getResultsService.ts │ ├── getTaskStatusForInvestorService.ts │ └── submitResultsService.ts ├── ordersService │ ├── bulkUpdateService.ts │ ├── createClientOrderService.ts │ ├── executeClientOrderService.ts │ ├── findAll1Service.ts │ ├── findByIdService.ts │ ├── getClientOrderWithMarketOrdersService.ts │ ├── getMarketOrdersByClientOrderService.ts │ ├── getMarketOrdersService.ts │ ├── updateMarketOrderService.ts │ ├── updateOrderAndTransactionService.ts │ └── updateSubmittedMarketOrdersService.ts ├── portfolioService │ ├── createNewAnalyticViewForCompanyService.ts │ ├── deleteAnalyticsViewByIdService.ts │ ├── getAvailableReportsForCompanyService.ts │ ├── getPartialSellSummaryService.ts │ ├── getPortfolioAnalyticsViewSelectorService.ts │ ├── getPortfolioService.ts │ ├── getStatementsForInvestorsService.ts │ └── getViewDataByIdService.ts ├── questionPagesService │ ├── createPagesService.ts │ └── getPagesService.ts ├── retailService │ ├── createInvestorProductService.ts │ ├── createProductService.ts │ ├── createTransactionService.ts │ ├── createWalletAccountService.ts │ ├── createWalletService.ts │ ├── fetchSerializedTransactionService.ts │ ├── fetchSerializedTransactionsService.ts │ ├── fetchTransactionsService.ts │ ├── findAllService.ts │ ├── getActivitiesService.ts │ ├── getAll1Service.ts │ ├── getCapitalCallsService.ts │ ├── getChartService.ts │ ├── getInvestorProduct1Service.ts │ ├── getInvestorProductService.ts │ ├── getProductDocumentsStatusService.ts │ ├── getProductSummaryService.ts │ ├── getProductsService.ts │ ├── getRetailPortfolioSummaryService.ts │ ├── getWalletAccountByTypeService.ts │ ├── initiateTransactionService.ts │ ├── onboardToBrokerService.ts │ ├── shareInvestmentMixService.ts │ ├── signProductDocumentsService.ts │ ├── updateInvestorProductService.ts │ └── updateProductService.ts ├── tradingService │ ├── createSecondarySaleService.ts │ ├── findOneService.ts │ ├── getAll2Service.ts │ ├── getAssetPerformanceService.ts │ └── getPerformanceSummaryService.ts ├── twoFactorAuthenticationService │ ├── requestVerificationNewContactService.ts │ ├── requestVerificationService.ts │ ├── validateVerificationNewContactService.ts │ └── validateVerificationService.ts ├── userActivityService │ └── getUserFundInteractionAnalysisService.ts └── waitingListControllerService ├── createWaitingListInvestorService.ts └── getWaitingListQuestionsService.ts

stijnvanhulle commented 1 week ago

I see that you are using different versions of Kubb for Core and the AxiosClient plugin, this can have an impact if some plugins are overriding other plugins. Please update all Kubb plugins to the latest version(2.21.2).

If that is still failing, can you provide me with your kubb.config.ts file so I can retry your config?

Samuel-Morgan-Tyghe commented 1 week ago

I made everything the latest

  "@kubb/cli": "latest",
    "@kubb/core": "latest",

    "@kubb/plugin-redoc": "latest",
    "@kubb/swagger": "latest",
    "@kubb/swagger-client": "latest",
    "@kubb/swagger-faker": "latest",
    "@kubb/swagger-msw": "latest",
    "@kubb/swagger-tanstack-query": "latest",
    "@kubb/swagger-ts": "latest",
    "@kubb/swagger-zod": "latest",

and

 "@kubb/cli": "^2.21.2",
    "@kubb/core": "^2.21.2",
    "@kubb/plugin-redoc": "^2.21.2",
    "@kubb/swagger": "^2.21.2",
    "@kubb/swagger-client": "^2.21.2",
    "@kubb/swagger-faker": "^2.21.2",
    "@kubb/swagger-msw": "^2.21.2",
    "@kubb/swagger-tanstack-query": "^2.21.2",
    "@kubb/swagger-ts": "^2.21.2",
    "@kubb/swagger-zod": "^2.21.2",

Both render the same issue

kubb.config.ts.zip

stijnvanhulle commented 1 week ago

When using group you better also define output, if not it will try creating the files in another folder. That is what is happening with your case here, group is generating files in the axios folder and output is not set(default to clients). Setting output will make sure the files are getting generated at the same location.

Example:

pluginClient({
  output: {
    path: './axios' // add this
  },
  client: { importPath: "@shared/services/api/swaggerAxiosClient" },
  group: { output: "./axios/{{tag}}Service", type: "tag" },
  transformers: {
    name: (name) => `${name}Service`,
  },
})
Samuel-Morgan-Tyghe commented 1 week ago

@stijnvanhulle Thanks, i thought it must be something simple, maybe worth adding to the docs https://www.kubb.dev/plugins/swagger-client/#group