[BUG] Getting “inject() must be called from an injection context” after upgrading to Angular 11
See original GitHub issueDescription
After having generated an API-client under the org.openapi.generator:5.0.0
using the org.springdoc.openapi-gradle-plugin:1.3.0
, my web application crashes, giving me the following error:
main.ts:12 Error: inject() must be called from an injection context
at injectInjectorOnly (core.js:4901)
at Module.ɵɵinject (core.js:4911)
at Object.ApiModule_Factory [as factory] (meditation-rest-client.js:2885)
at R3Injector.hydrate (core.js:11158)
at R3Injector.get (core.js:10979)
at core.js:11016
at Set.forEach (<anonymous>)
at R3Injector._resolveInjectorDefTypes (core.js:11016)
at new NgModuleRef$1 (core.js:25046)
at NgModuleFactory$1.create (core.js:25100)
openapi-generator version
5.0.0
OpenAPI declaration file content or url
openapi: 3.0.1
info:
title: OpenAPI definition
version: v0
servers:
- url: http://127.0.0.1:8080
description: Generated server url
paths:
// ...
Generation Details
I am using the openapi-generator-gradle-plugin
:
openApiGenerate {
generatorName = 'typescript-angular'
inputSpec = swaggerFilePath
outputDir = apiClientOutputDir
configOptions = [
npmName : 'meditation-rest-client', // Api-client name
npmVersion: '0.0.1', // Api-client version
ngVersion : '11.0.6'
]
}
Steps to reproduce
- Build an API-Client from a Spring Boot Application
- Reference the API-Client in your Angular 11 Web-Application
ng serve
- Find the error in your console
Related issues/PRs
I have tried to apply suggestions from
- https://github.com/angular/angular/issues/25813
- https://github.com/OpenAPITools/openapi-generator/issues/5246
without success.
Issue Analytics
- State:
- Created 3 years ago
- Comments:26 (13 by maintainers)
Top Results From Across the Web
Error: inject() must be called from an injection context | Angular
Error: inject() must be called from an injection context ... I am trying to use AngularJS Grid, but getting the error and data...
Read more >inject() must be called from an injection context at ... - You.com
When I build the library, and try to use the pipe it in the app. I get an "Error: inject() must be called...
Read more >After Updating Angular From 8 To 11 Got Error In Ssr - ADocLib
After Updating Angular From 8 To 11 Got Error In Ssr: "Error: Inject() Must Be Called From An Injection Context". This subscription function...
Read more >SSR Error: inject() must be called from an injection context
SSR Error: inject() must be called from an injection context. AngularJS ... Bug, feature request, or proposal: Bug ...
Read more >[SOLVED] properly understanding inject in angular14 – inject() must ...
... inject in angular14 – inject() must be called from an injection context ... before when i tried to have a supporting function...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Falls ich mal in der Schweiz bin 😉
glad it works.