0.6.196 • Published 5 years ago

@apaleo/angular-api-proxy-fiscalization v0.6.196

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
5 years ago

@

Building

To install the required dependencies and to build the typescript sources run:

npm install
npm run build

publishing

First build the package than run npm publish

consuming

Navigate to the folder of your consuming project and run one of next commands.

published:

npm install @ --save

without publishing (not recommended):

npm install PATH_TO_GENERATED_PACKAGE --save

using npm link:

In PATH_TO_GENERATED_PACKAGE:

npm link

In your project:

npm link 

Note for Windows users: The Angular CLI has troubles to use linked npm packages. Please refer to this issue https://github.com/angular/angular-cli/issues/8284 for a solution / workaround. Published packages are not effected by this issue.

General usage

In your Angular project:

// without configuring providers
import { ApiModule } from '';
import { HttpClientModule } from '@angular/common/http';


@NgModule({
    imports: [
        ApiModule,
        // make sure to import the HttpClientModule in the AppModule only,
        // see https://github.com/angular/angular/issues/20575
        HttpClientModule
    ],
    declarations: [ AppComponent ],
    providers: [],
    bootstrap: [ AppComponent ]
})
export class AppModule {}
// configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from '';

export function apiConfigFactory (): Configuration => {
  const params: ConfigurationParameters = {
    // set configuration parameters here.
  }
  return new Configuration(params);
}

@NgModule({
    imports: [ ApiModule.forRoot(apiConfigFactory) ],
    declarations: [ AppComponent ],
    providers: [],
    bootstrap: [ AppComponent ]
})
export class AppModule {}
import { DefaultApi } from '';

export class AppComponent {
	 constructor(private apiGateway: DefaultApi) { }
}

Note: The ApiModule is restricted to being instantiated once app wide. This is to ensure that all services are treated as singletons.

Using multiple swagger files / APIs / ApiModules

In order to use multiple ApiModules generated from different swagger files, you can create an alias name when importing the modules in order to avoid naming conflicts:

import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http';


@NgModule({
  imports: [
    ApiModule,
    OtherApiModule,
    // make sure to import the HttpClientModule in the AppModule only,
    // see https://github.com/angular/angular/issues/20575
    HttpClientModule
  ]
})
export class AppModule {

}

Set service base path

If different than the generated base path, during app bootstrap, you can provide the base path to your service.

import { BASE_PATH } from '';

bootstrap(AppComponent, [
    { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]);

or

import { BASE_PATH } from '';

@NgModule({
    imports: [],
    declarations: [ AppComponent ],
    providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ],
    bootstrap: [ AppComponent ]
})
export class AppModule {}

Using @angular/cli

First extend your src/environments/*.ts files by adding the corresponding base path:

export const environment = {
  production: false,
  API_BASE_PATH: 'http://127.0.0.1:8080'
};

In the src/app/app.module.ts:

import { BASE_PATH } from '';
import { environment } from '../environments/environment';

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [ ],
  providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }],
  bootstrap: [ AppComponent ]
})
export class AppModule { }
0.6.196

5 years ago

0.6.195

5 years ago

0.6.194

5 years ago

0.6.193

5 years ago

0.6.192

5 years ago

0.6.191

5 years ago

0.6.190

5 years ago

2.0.3

5 years ago

0.6.189

5 years ago

0.6.188

5 years ago

0.6.187

5 years ago

0.6.186

5 years ago

0.6.184

5 years ago

0.6.183

5 years ago

0.6.185

5 years ago

0.6.182

5 years ago

0.6.181

5 years ago

0.6.180

5 years ago

0.6.179

5 years ago

0.6.178

5 years ago

0.6.177

5 years ago

0.6.176

5 years ago

0.6.175

5 years ago

0.6.173

5 years ago

0.6.174

5 years ago

0.6.172

5 years ago

0.6.171

5 years ago

0.6.170

5 years ago

0.6.169

5 years ago

0.6.168

5 years ago

2.0.2

5 years ago

0.6.167

5 years ago

0.6.166

5 years ago

0.6.165

5 years ago

0.6.164

5 years ago

0.6.163

5 years ago

0.6.162

5 years ago

0.6.161

5 years ago

0.6.160

5 years ago

0.6.159

5 years ago

0.6.158

5 years ago

0.6.157

5 years ago

0.6.156

5 years ago

0.6.155

5 years ago

0.6.154

5 years ago

2.0.1

5 years ago

0.6.153

5 years ago

0.6.152

5 years ago

2.0.0

5 years ago

0.6.151

5 years ago

0.6.150

5 years ago

0.6.149

5 years ago

0.6.148

5 years ago