cyclosproject / ng-openapi-gen

An OpenAPI 3.0 codegen for Angular
MIT License
397 stars 132 forks source link

@Injectable({providedIn:'root'}) #63

Closed fromnowhereuser closed 4 years ago

fromnowhereuser commented 4 years ago

Hello,

I am using ng-openapi-gen like this: "scripts": { [blabla], "gen": "ng-openapi-gen --input http://localhost:8889/api-json --output ./src/app/modules/project/api" }

The code is generated, but i have this created:

{ @Injectable({ providedIn: 'root', }) export class ApiService extends BaseService }

The problem is that, when i want to inject the module like this: ApiModule.forRoot({ rootUrl: 'http://localhost:8889' }), This service ignore my rooUrl conf because of the providedIn: 'root', if i manually remove it, it works. Maybe, i am doing it wrong, but... imho, ApiService shouldn't have the providedIn: 'root' param.

Regards,

fromnowhereuser commented 4 years ago

Sorry, The proper way to assign the rootURL is to set it via the ApiConfiguration service. sry.