Since this week-end the client code generation for angular 8.2.7 typescript from a swagger open-api 3 spec file stopped working:
------------------------------------------------------------------------------
Building entry point '@my-company/my-api'
------------------------------------------------------------------------------
Compiling TypeScript sources through ngc
Bundling to FESM2015
WARNING: 'HttpResponse', 'HttpEvent' and 'HttpParameterCodec' are imported from external module '@angular/common/http' but never used
Bundling to FESM5
WARNING: 'HttpResponse', 'HttpEvent' and 'HttpParameterCodec' are imported from external module '@angular/common/http' but never used
Bundling to UMD
ERROR: Could not resolve './my.service' from dist\fesm5\my-generated-api-name.js
I tried to revert to previous version of "@openapitools/openapi-generator-cli": "0.0.19-4.1.2" to version "0.0.19-4.1.1"
I also tried a dummy open-api 3 spec test file at https://petstore.swagger.io/ and I got the same error
The debug log says nothing I'm clueless
Here is the npm command I run:
"generate-front": "openapi-generator generate -i http://localhost:22953/swagger/v1/swagger.json -g typescript-angular -o ./code-front -c options-front.json"
Here is the option file:
{
"npmName": "@my-company/my-api",
"npmVersion": "0.18.0",
"ngVersion": "8.2.7",
"serviceSuffix": "Repository",
"modelSuffix": "Model"
}
It should build without error
The problem was with ng-packagr it installed the latest version who has a breaking change
"ng-packagr": "^5.4.0"
I removed the hat and everything went fine:
"ng-packagr": "5.4.0"
Voilà!
------------------------------------------------------------------------------
Building entry point '@my-company/my-api'
------------------------------------------------------------------------------
Compiling TypeScript sources through ngc
Bundling to FESM2015
Bundling to FESM5
Bundling to UMD
Minifying UMD bundle
Copying declaration files
Writing package metadata
Removing scripts section in package.json as it's considered a potential security vulnerability.
Built @my-company/my-api
------------------------------------------------------------------------------
Built Angular Package!
- from: D:\my-dev-repo\openapi-codegen\code-front
- to: D:\my-dev-repo\openapi-codegen\code-front\dist
------------------------------------------------------------------------------