OpenAPITools / OpenAPITools/openapi-generator
[BUG] Module does not provide an export
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
I am migrating our frontend to use Vite. We are using the OpenAPI generator Axios client to generate all our API code from a specification.
I have generated the code again, and see it in the target folder. Afterwards, I am building it using npm and a dist folder appears. Then I am adding it as a local import in my package.json file and install it. It's the same as it was before.
"restClient": "file:src/api/generated-sources"
When I start the Vite dev server, for some reason I am getting below error:
Uncaught SyntaxError: The requested module '/src/api/generated-sources/dist/index.js' does not provide an export named 'SortParams' (at HomeView.vue:6:3)
I am using this enum in my code without any errors being shown. Only when running the server it throws an error.
This is the enum, in the generated file:
/**
*
- @export
- @enum {string}
*/
export declare enum SortParams {
CreationDatetime = "CREATION_DATETIME",
ModificationDatetime = "MODIFICATION_DATETIME",
Process = "PROCESS",
Status = "STATUS"
}
Above is coming from a file called api.d.ts, which is generated. There's also a javascript file called api.js, which is built so it's a bit hard to read. A cmd+f reveals that the SortParams enum is present there and seems to be exported.
This is how I am importing it in my HomeView:
import {
CaptureCaseSortParams,
CaptureCaseStatus,
Configuration,
DocumentCaptureCasesApi,
PaginationData,
SortOrder,
} from 'restClient';
The error is already being thrown at the line of the import.
This is my openapitools.json file:
{
"$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "5.3.0",
"useDocker": true,
"generators": {
"v1": {
"generatorName": "typescript-axios",
"inputSpec": "src/api/openapi.yml",
"output": "src/api/generated-sources",
"additionalProperties": {
"npmName": "restClient",
"useSingleRequestParameter": true
},
"globalProperty": {
"skipFormModel": false
}
}
}
}
}
Does anyone know what this might be?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with openapitools.json and the generated api.d.ts, api.js, and dist/index.js, then compare the runtime exports with the names imported in HomeView. Reproduce the typescript-axios generation and Vite startup using the shown configuration. Done means the generated package's runtime exports match the imports without the Vite module error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, typescript, vite
- Domain
- api, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100