[TypeScript - Angular] Add syntax highlighting to code blocks and correct heading levels in README.mustache (#19837)

* Improve typescript-angular README.mustache

- Add syntax highlighting to code blocks
- Correct heading levels

* Add space between heading and convert bare url to angle brackets link

* Update samples
This commit is contained in:
Ben Meyrick 2024-10-10 16:57:16 +01:00 committed by GitHub
parent a84946bdb3
commit 368b9b7e37
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 544 additions and 442 deletions

View File

@ -1,34 +1,35 @@
## {{npmName}}@{{npmVersion}} # {{npmName}}@{{npmVersion}}
{{{appDescription}}} {{{appDescription}}}
{{#version}}The version of the OpenAPI document: {{{.}}}{{/version}} {{#version}}The version of the OpenAPI document: {{{.}}}{{/version}}
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install {{npmName}}@{{npmVersion}} --save npm install {{npmName}}@{{npmVersion}} --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link {{npmName}} npm link {{npmName}}
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { {{apiModuleClassName}} } from '{{npmName}}'; import { {{apiModuleClassName}} } from '{{npmName}}';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { {{apiModuleClassName}}, {{configurationClassName}}, {{configurationParametersInterfaceName}} } from '{{npmName}}'; import { {{apiModuleClassName}}, {{configurationClassName}}, {{configurationParametersInterfaceName}} } from '{{npmName}}';
@ -95,7 +96,7 @@ export function apiConfigFactory (): {{configurationClassName}} {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { {{apiModuleClassName}}, {{configurationClassName}} } from '{{npmName}}'; import { {{apiModuleClassName}}, {{configurationClassName}} } from '{{npmName}}';
@ -120,7 +121,7 @@ import { {{apiModuleClassName}}, {{configurationClassName}} } from '{{npmName}}'
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from '{{npmName}}'; import { DefaultApi } from '{{npmName}}';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The {{apiModuleClassName}} is restricted to being instantiated once app wide. Note: The {{apiModuleClassName}} is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / {{apiModuleClassName}}s ### Using multiple OpenAPI files / APIs / {{apiModuleClassName}}s
In order to use multiple `{{apiModuleClassName}}s` generated from different OpenAPI files, In order to use multiple `{{apiModuleClassName}}s` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { {{apiModuleClassName}} } from 'my-api-path'; import { {{apiModuleClassName}} } from 'my-api-path';
import { {{apiModuleClassName}} as OtherApiModule } from 'my-other-api-path'; import { {{apiModuleClassName}} as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from '{{npmName}}'; import { BASE_PATH } from '{{npmName}}';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from '{{npmName}}'; import { BASE_PATH } from '{{npmName}}';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '{{npmName}}';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from '{{npmName}}'; import { BASE_PATH } from '{{npmName}}';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),

View File

@ -1,34 +1,35 @@
## @ # @
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: 1.0.0 The version of the OpenAPI document: 1.0.0
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install @ --save npm install @ --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link npm link
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { ApiModule } from ''; import { ApiModule } from '';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from ''; import { ApiModule, Configuration, ConfigurationParameters } from '';
@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from ''; import { ApiModule, Configuration } from '';
@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from ''; import { DefaultApi } from '';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / ApiModules ### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { ApiModule } from 'my-api-path'; import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path'; import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),

View File

@ -1,34 +1,35 @@
## @ # @
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: 1.0.0 The version of the OpenAPI document: 1.0.0
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install @ --save npm install @ --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link npm link
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { ApiModule } from ''; import { ApiModule } from '';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from ''; import { ApiModule, Configuration, ConfigurationParameters } from '';
@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from ''; import { ApiModule, Configuration } from '';
@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from ''; import { DefaultApi } from '';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / ApiModules ### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { ApiModule } from 'my-api-path'; import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path'; import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),

View File

@ -1,34 +1,35 @@
## @ # @
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: 0.0.1 The version of the OpenAPI document: 0.0.1
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install @ --save npm install @ --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link npm link
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { ApiModule } from ''; import { ApiModule } from '';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from ''; import { ApiModule, Configuration, ConfigurationParameters } from '';
@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from ''; import { ApiModule, Configuration } from '';
@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from ''; import { DefaultApi } from '';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / ApiModules ### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { ApiModule } from 'my-api-path'; import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path'; import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),

View File

@ -1,34 +1,35 @@
## @ # @
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0 The version of the OpenAPI document: 1.0.0
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install @ --save npm install @ --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link npm link
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { ApiModule } from ''; import { ApiModule } from '';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from ''; import { ApiModule, Configuration, ConfigurationParameters } from '';
@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from ''; import { ApiModule, Configuration } from '';
@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from ''; import { DefaultApi } from '';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / ApiModules ### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { ApiModule } from 'my-api-path'; import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path'; import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),

View File

@ -1,34 +1,35 @@
## @ # @
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0 The version of the OpenAPI document: 1.0.0
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install @ --save npm install @ --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link npm link
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { ApiModule } from ''; import { ApiModule } from '';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from ''; import { ApiModule, Configuration, ConfigurationParameters } from '';
@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from ''; import { ApiModule, Configuration } from '';
@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from ''; import { DefaultApi } from '';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / ApiModules ### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { ApiModule } from 'my-api-path'; import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path'; import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),

View File

@ -1,34 +1,35 @@
## @openapitools/typescript-angular-petstore@1.0.0 # @openapitools/typescript-angular-petstore@1.0.0
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0 The version of the OpenAPI document: 1.0.0
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install @openapitools/typescript-angular-petstore@1.0.0 --save npm install @openapitools/typescript-angular-petstore@1.0.0 --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link @openapitools/typescript-angular-petstore npm link @openapitools/typescript-angular-petstore
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { ApiModule } from '@openapitools/typescript-angular-petstore'; import { ApiModule } from '@openapitools/typescript-angular-petstore';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from '@openapitools/typescript-angular-petstore'; import { ApiModule, Configuration, ConfigurationParameters } from '@openapitools/typescript-angular-petstore';
@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from '@openapitools/typescript-angular-petstore'; import { ApiModule, Configuration } from '@openapitools/typescript-angular-petstore';
@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '@openapitools/typescript-angular-petst
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from '@openapitools/typescript-angular-petstore'; import { DefaultApi } from '@openapitools/typescript-angular-petstore';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / ApiModules ### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { ApiModule } from 'my-api-path'; import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path'; import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from '@openapitools/typescript-angular-petstore'; import { BASE_PATH } from '@openapitools/typescript-angular-petstore';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from '@openapitools/typescript-angular-petstore'; import { BASE_PATH } from '@openapitools/typescript-angular-petstore';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '@openapitools/typescript-angular-petstore';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from '@openapitools/typescript-angular-petstore'; import { BASE_PATH } from '@openapitools/typescript-angular-petstore';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),

View File

@ -1,34 +1,35 @@
## @ # @
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: 0.0.1 The version of the OpenAPI document: 0.0.1
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install @ --save npm install @ --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link npm link
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { ApiModule } from ''; import { ApiModule } from '';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from ''; import { ApiModule, Configuration, ConfigurationParameters } from '';
@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from ''; import { ApiModule, Configuration } from '';
@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from ''; import { DefaultApi } from '';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / ApiModules ### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { ApiModule } from 'my-api-path'; import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path'; import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),

View File

@ -1,34 +1,35 @@
## @ # @
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0 The version of the OpenAPI document: 1.0.0
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install @ --save npm install @ --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link npm link
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { ApiModule } from ''; import { ApiModule } from '';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from ''; import { ApiModule, Configuration, ConfigurationParameters } from '';
@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from ''; import { ApiModule, Configuration } from '';
@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from ''; import { DefaultApi } from '';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / ApiModules ### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { ApiModule } from 'my-api-path'; import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path'; import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),

View File

@ -1,34 +1,35 @@
## @ # @
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0 The version of the OpenAPI document: 1.0.0
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install @ --save npm install @ --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link npm link
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { ApiModule } from ''; import { ApiModule } from '';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from ''; import { ApiModule, Configuration, ConfigurationParameters } from '';
@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from ''; import { ApiModule, Configuration } from '';
@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from ''; import { DefaultApi } from '';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / ApiModules ### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { ApiModule } from 'my-api-path'; import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path'; import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),

View File

@ -1,34 +1,35 @@
## @openapitools/typescript-angular-petstore@1.0.0 # @openapitools/typescript-angular-petstore@1.0.0
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0 The version of the OpenAPI document: 1.0.0
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install @openapitools/typescript-angular-petstore@1.0.0 --save npm install @openapitools/typescript-angular-petstore@1.0.0 --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link @openapitools/typescript-angular-petstore npm link @openapitools/typescript-angular-petstore
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { ApiModule } from '@openapitools/typescript-angular-petstore'; import { ApiModule } from '@openapitools/typescript-angular-petstore';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from '@openapitools/typescript-angular-petstore'; import { ApiModule, Configuration, ConfigurationParameters } from '@openapitools/typescript-angular-petstore';
@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from '@openapitools/typescript-angular-petstore'; import { ApiModule, Configuration } from '@openapitools/typescript-angular-petstore';
@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '@openapitools/typescript-angular-petst
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from '@openapitools/typescript-angular-petstore'; import { DefaultApi } from '@openapitools/typescript-angular-petstore';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / ApiModules ### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { ApiModule } from 'my-api-path'; import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path'; import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from '@openapitools/typescript-angular-petstore'; import { BASE_PATH } from '@openapitools/typescript-angular-petstore';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from '@openapitools/typescript-angular-petstore'; import { BASE_PATH } from '@openapitools/typescript-angular-petstore';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '@openapitools/typescript-angular-petstore';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from '@openapitools/typescript-angular-petstore'; import { BASE_PATH } from '@openapitools/typescript-angular-petstore';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),

View File

@ -1,34 +1,35 @@
## @ # @
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0 The version of the OpenAPI document: 1.0.0
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install @ --save npm install @ --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link npm link
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { ApiModule } from ''; import { ApiModule } from '';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from ''; import { ApiModule, Configuration, ConfigurationParameters } from '';
@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from ''; import { ApiModule, Configuration } from '';
@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from ''; import { DefaultApi } from '';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / ApiModules ### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { ApiModule } from 'my-api-path'; import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path'; import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),

View File

@ -1,34 +1,35 @@
## @ # @
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0 The version of the OpenAPI document: 1.0.0
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install @ --save npm install @ --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link npm link
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { ApiModule } from ''; import { ApiModule } from '';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from ''; import { ApiModule, Configuration, ConfigurationParameters } from '';
@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from ''; import { ApiModule, Configuration } from '';
@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from ''; import { DefaultApi } from '';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / ApiModules ### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { ApiModule } from 'my-api-path'; import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path'; import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),

View File

@ -1,34 +1,35 @@
## @ # @
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0 The version of the OpenAPI document: 1.0.0
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install @ --save npm install @ --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link npm link
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { ApiModule } from ''; import { ApiModule } from '';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from ''; import { ApiModule, Configuration, ConfigurationParameters } from '';
@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from ''; import { ApiModule, Configuration } from '';
@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from ''; import { DefaultApi } from '';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / ApiModules ### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { ApiModule } from 'my-api-path'; import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path'; import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),

View File

@ -1,34 +1,35 @@
## @ # @
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0 The version of the OpenAPI document: 1.0.0
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install @ --save npm install @ --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link npm link
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { ApiModule } from ''; import { ApiModule } from '';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from ''; import { ApiModule, Configuration, ConfigurationParameters } from '';
@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from ''; import { ApiModule, Configuration } from '';
@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from ''; import { DefaultApi } from '';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / ApiModules ### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { ApiModule } from 'my-api-path'; import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path'; import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),

View File

@ -1,34 +1,35 @@
## @ # @
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0 The version of the OpenAPI document: 1.0.0
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install @ --save npm install @ --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link npm link
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { ApiModule } from ''; import { ApiModule } from '';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from ''; import { ApiModule, Configuration, ConfigurationParameters } from '';
@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from ''; import { ApiModule, Configuration } from '';
@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from ''; import { DefaultApi } from '';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / ApiModules ### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { ApiModule } from 'my-api-path'; import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path'; import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),

View File

@ -1,34 +1,35 @@
## @ # @
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
The version of the OpenAPI document: 1.0.0 The version of the OpenAPI document: 1.0.0
### Building ## Building
To install the required dependencies and to build the typescript sources run: To install the required dependencies and to build the typescript sources run:
```
```console
npm install npm install
npm run build npm run build
``` ```
### publishing ## Publishing
First build the package then run ```npm publish dist``` (don't forget to specify the `dist` folder!) First build the package then run `npm publish dist` (don't forget to specify the `dist` folder!)
### consuming ## Consuming
Navigate to the folder of your consuming project and run one of next commands. Navigate to the folder of your consuming project and run one of next commands.
_published:_ _published:_
``` ```console
npm install @ --save npm install @ --save
``` ```
_without publishing (not recommended):_ _without publishing (not recommended):_
``` ```console
npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save npm install PATH_TO_GENERATED_PACKAGE/dist.tgz --save
``` ```
@ -37,26 +38,26 @@ _It's important to take the tgz file, otherwise you'll get trouble with links on
_using `npm link`:_ _using `npm link`:_
In PATH_TO_GENERATED_PACKAGE/dist: In PATH_TO_GENERATED_PACKAGE/dist:
```
```console
npm link npm link
``` ```
In your project: In your project:
```
```console
npm link npm link
``` ```
__Note for Windows users:__ The Angular CLI has troubles to use linked npm packages. __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. 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. Published packages are not effected by this issue.
### General usage
#### General usage
In your Angular project: In your Angular project:
```typescript
```
// without configuring providers // without configuring providers
import { ApiModule } from ''; import { ApiModule } from '';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -75,7 +76,7 @@ import { HttpClientModule } from '@angular/common/http';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers // configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from ''; import { ApiModule, Configuration, ConfigurationParameters } from '';
@ -95,7 +96,7 @@ export function apiConfigFactory (): Configuration {
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
// configuring providers with an authentication service that manages your access tokens // configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from ''; import { ApiModule, Configuration } from '';
@ -120,7 +121,7 @@ import { ApiModule, Configuration } from '';
export class AppModule {} export class AppModule {}
``` ```
``` ```typescript
import { DefaultApi } from ''; import { DefaultApi } from '';
export class AppComponent { export class AppComponent {
@ -131,11 +132,13 @@ export class AppComponent {
Note: The ApiModule is restricted to being instantiated once app wide. Note: The ApiModule is restricted to being instantiated once app wide.
This is to ensure that all services are treated as singletons. This is to ensure that all services are treated as singletons.
#### Using multiple OpenAPI files / APIs / ApiModules ### Using multiple OpenAPI files / APIs / ApiModules
In order to use multiple `ApiModules` generated from different OpenAPI files, In order to use multiple `ApiModules` generated from different OpenAPI files,
you can create an alias name when importing the modules you can create an alias name when importing the modules
in order to avoid naming conflicts: in order to avoid naming conflicts:
```
```typescript
import { ApiModule } from 'my-api-path'; import { ApiModule } from 'my-api-path';
import { ApiModule as OtherApiModule } from 'my-other-api-path'; import { ApiModule as OtherApiModule } from 'my-other-api-path';
import { HttpClientModule } from '@angular/common/http'; import { HttpClientModule } from '@angular/common/http';
@ -154,20 +157,21 @@ export class AppModule {
} }
``` ```
### Set service base path ### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service. If different than the generated base path, during app bootstrap, you can provide the base path to your service.
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
bootstrap(AppComponent, [ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, { provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]); ]);
``` ```
or or
``` ```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
@NgModule({ @NgModule({
@ -179,11 +183,11 @@ import { BASE_PATH } from '';
export class AppModule {} export class AppModule {}
``` ```
### Using @angular/cli
#### Using @angular/cli
First extend your `src/environments/*.ts` files by adding the corresponding base path: First extend your `src/environments/*.ts` files by adding the corresponding base path:
``` ```typescript
export const environment = { export const environment = {
production: false, production: false,
API_BASE_PATH: 'http://127.0.0.1:8080' API_BASE_PATH: 'http://127.0.0.1:8080'
@ -191,7 +195,8 @@ export const environment = {
``` ```
In the src/app/app.module.ts: In the src/app/app.module.ts:
```
```typescript
import { BASE_PATH } from ''; import { BASE_PATH } from '';
import { environment } from '../environments/environment'; import { environment } from '../environments/environment';
@ -219,6 +224,7 @@ pass an arrow-function or method-reference to the `encodeParam` property of the
(see [General Usage](#general-usage) above). (see [General Usage](#general-usage) above).
Example value for use in your Configuration-Provider: Example value for use in your Configuration-Provider:
```typescript ```typescript
new Configuration({ new Configuration({
encodeParam: (param: Param) => myFancyParamEncoder(param), encodeParam: (param: Param) => myFancyParamEncoder(param),