I am not able to compile the generated client because the TypeScript version is not compatible with Angular 11:
ERROR: The Angular Compiler requires TypeScript >=4.0.0 and <4.1.0 but 3.5.3 was found instead.
How can I set the correct TypeScript version while I generate the code? This is how I defined the gradle task:
openApiGenerate {
generatorName = 'typescript-angular'
inputSpec = swaggerFilePath
outputDir = apiClientOutputDir
configOptions = [
npmName : 'rest-client',
npmVersion: '0.0.0',
ngVersion: '11.0.6'
]
}
This is what gets written into the package.json
-file of the rest-client
module.
"devDependencies": {
"@angular/common": "^11.0.6",
"@angular/compiler": "^11.0.6",
"@angular/compiler-cli": "^11.0.6",
"@angular/core": "^11.0.6",
"@angular/platform-browser": "^11.0.6",
"ng-packagr": "^5.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "^6.5.0",
"tsickle": "^0.35.0",
"typescript": ">=3.4.0 <3.6.0",
"zone.js": "^0.9.1"
}
My dependencies:
// Spring Docs
implementation 'org.springdoc:springdoc-openapi-ui:1.5.2'
implementation 'org.springdoc:springdoc-openapi-data-rest:1.5.2'
The problem was that I was using an outdated version of the OpenAPI Generator that didn't know about Angular 11.
Changing
id 'org.openapi.generator' version '4.2.2'
to
id 'org.openapi.generator' version '5.0.0'
resolved the issue.
I also upgraded my Spring Doc dependencies to the latest version at this time:
// Spring Docs
implementation 'org.springdoc:springdoc-openapi-ui:1.5.2'
implementation 'org.springdoc:springdoc-openapi-data-rest:1.5.2'