Our team is currently using Swagger to automatically generate our API models and we are looking for a more convenient way to import them into our project.
Currently, we are importing them like this: tsconfig.ts
"paths": {
"apimodel/*": ["frontend/swagger-api-definition/model/*"]
}
Example of importing random data-source classes:
import { ExampleDtoQuery } from 'apimodel/exampleDtoQuery ';
import { ExampleUserDtosUserManagerDashboardResponseUserProject } from 'apimodel/exampleUserDtosUserManagerDashboardResponseUserProject ';
Please note that the names used above are randomly generated and should not be judged :)
However, I would like to set up an alias in the tsconfig file and utilize the barrel file generated in the root directory. Something like this: tsconfig.ts
"paths": {
"@apimodel": ["frontend/swagger-api-definition/index.ts"]
},
Example of importing random data-source classes with the alias:
import { ExampleDtoQuery } from '@apimodel';
import { ExampleUserDtosUserManagerDashboardResponseUserProject } from '@apimodel ';
Unfortunately, when trying this approach, the compiler throws an error message:
Cannot find module '@apimodel'.ts(2307)
Any suggestions on how to resolve this issue?