mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 10:58:55 +00:00
With this change, users providing custom configuration must provide an exported Configuration factory, rather than just an object. This is needed to be Angular AoT compatible. Example use: import * as api from '../api'; /** Configuration settings for the backend API */ export function backendConfigurationFactory(): api.Configuration { return new api.Configuration({basePath: '/api'}); } @NgModule({ imports: [api.ApiModule.forConfig(backendConfigurationFactory)], ...
This commit is contained in:
parent
d0d9650c13
commit
fb04b5a26a
@ -16,10 +16,10 @@ import { {{classname}} } from './{{importPath}}';
|
||||
providers: [ {{#apiInfo}}{{#apis}}{{classname}}{{#hasMore}}, {{/hasMore}}{{/apis}}{{/apiInfo}} ]
|
||||
})
|
||||
export class ApiModule {
|
||||
public static forConfig(configuration: Configuration): ModuleWithProviders {
|
||||
public static forConfig(configurationFactory: () => Configuration): ModuleWithProviders {
|
||||
return {
|
||||
ngModule: ApiModule,
|
||||
providers: [ {provide: Configuration, useValue: configuration}]
|
||||
providers: [ {provide: Configuration, useFactory: configurationFactory}]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,10 @@ import { UserService } from './api/user.service';
|
||||
providers: [ PetService, StoreService, UserService ]
|
||||
})
|
||||
export class ApiModule {
|
||||
public static forConfig(configuration: Configuration): ModuleWithProviders {
|
||||
public static forConfig(configurationFactory: () => Configuration): ModuleWithProviders {
|
||||
return {
|
||||
ngModule: ApiModule,
|
||||
providers: [ {provide: Configuration, useValue: configuration}]
|
||||
providers: [ {provide: Configuration, useFactory: configurationFactory}]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,10 +14,10 @@ import { UserService } from './api/user.service';
|
||||
providers: [ PetService, StoreService, UserService ]
|
||||
})
|
||||
export class ApiModule {
|
||||
public static forConfig(configuration: Configuration): ModuleWithProviders {
|
||||
public static forConfig(configurationFactory: () => Configuration): ModuleWithProviders {
|
||||
return {
|
||||
ngModule: ApiModule,
|
||||
providers: [ {provide: Configuration, useValue: configuration}]
|
||||
providers: [ {provide: Configuration, useFactory: configurationFactory}]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user