forked from swagger-api/swagger-codegen
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
691 additions
and
56 deletions.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
samples/client/petstore-security-test/typescript-angular/.swagger-codegen/VERSION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.3.0 | ||
2.4.0-SNAPSHOT |
171 changes: 171 additions & 0 deletions
171
samples/client/petstore-security-test/typescript-angular/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
## @ | ||
|
||
### Building | ||
|
||
To build an compile the typescript sources to javascript use: | ||
``` | ||
npm install | ||
npm run build | ||
``` | ||
|
||
### publishing | ||
|
||
First build the package than run ```npm publish``` | ||
|
||
### consuming | ||
|
||
navigate to the folder of your consuming project and run one of next commando's. | ||
|
||
_published:_ | ||
|
||
``` | ||
npm install @ --save | ||
``` | ||
|
||
_unPublished (not recommended):_ | ||
|
||
``` | ||
npm install PATH_TO_GENERATED_PACKAGE --save | ||
``` | ||
|
||
_using `npm link`:_ | ||
|
||
In PATH_TO_GENERATED_PACKAGE: | ||
``` | ||
npm link | ||
``` | ||
|
||
In your project: | ||
``` | ||
npm link @ | ||
``` | ||
|
||
In your Angular project: | ||
|
||
|
||
``` | ||
// without configuring providers | ||
import { ApiModule } from ''; | ||
import { HttpClientModule } from '@angular/common/http'; | ||
@NgModule({ | ||
imports: [ | ||
ApiModule, | ||
// make sure to import the HttpClientModule in the AppModule only, | ||
// see https://github.com/angular/angular/issues/20575 | ||
HttpClientModule | ||
], | ||
declarations: [ AppComponent ], | ||
providers: [], | ||
bootstrap: [ AppComponent ] | ||
}) | ||
export class AppModule {} | ||
``` | ||
|
||
``` | ||
// configuring providers | ||
import { ApiModule, Configuration, ConfigurationParameters } from ''; | ||
export function apiConfigFactory (): Configuration => { | ||
const params: ConfigurationParameters = { | ||
// set configuration parameters here. | ||
} | ||
return new Configuration(params); | ||
} | ||
@NgModule({ | ||
imports: [ ApiModule.forRoot(apiConfigFactory) ], | ||
declarations: [ AppComponent ], | ||
providers: [], | ||
bootstrap: [ AppComponent ] | ||
}) | ||
export class AppModule {} | ||
``` | ||
|
||
``` | ||
import { DefaultApi } from ''; | ||
export class AppComponent { | ||
constructor(private apiGateway: DefaultApi) { } | ||
} | ||
``` | ||
|
||
Note: The ApiModule is restricted to being instantiated once app wide. | ||
This is to ensure that all services are treated as singletons. | ||
|
||
#### Using multiple swagger files / APIs / ApiModules | ||
In order to use multiple `ApiModules` generated from different swagger files, | ||
you can create an alias name when importing the modules | ||
in order to avoid naming conflicts: | ||
``` | ||
import { ApiModule } from 'my-api-path'; | ||
import { ApiModule as OtherApiModule } from 'my-other-api-path'; | ||
import { HttpClientModule } from '@angular/common/http'; | ||
@NgModule({ | ||
imports: [ | ||
ApiModule, | ||
OtherApiModule, | ||
// make sure to import the HttpClientModule in the AppModule only, | ||
// see https://github.com/angular/angular/issues/20575 | ||
HttpClientModule | ||
] | ||
}) | ||
export class AppModule { | ||
} | ||
``` | ||
|
||
|
||
### Set service base path | ||
If different than the generated base path, during app bootstrap, you can provide the base path to your service. | ||
|
||
``` | ||
import { BASE_PATH } from ''; | ||
bootstrap(AppComponent, [ | ||
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' }, | ||
]); | ||
``` | ||
or | ||
|
||
``` | ||
import { BASE_PATH } from ''; | ||
@NgModule({ | ||
imports: [], | ||
declarations: [ AppComponent ], | ||
providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ], | ||
bootstrap: [ AppComponent ] | ||
}) | ||
export class AppModule {} | ||
``` | ||
|
||
|
||
#### Using @angular/cli | ||
First extend your `src/environments/*.ts` files by adding the corresponding base path: | ||
|
||
``` | ||
export const environment = { | ||
production: false, | ||
API_BASE_PATH: 'http://127.0.0.1:8080' | ||
}; | ||
``` | ||
|
||
In the src/app/app.module.ts: | ||
``` | ||
import { BASE_PATH } from ''; | ||
import { environment } from '../environments/environment'; | ||
@NgModule({ | ||
declarations: [ | ||
AppComponent | ||
], | ||
imports: [ ], | ||
providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }], | ||
bootstrap: [ AppComponent ] | ||
}) | ||
export class AppModule { } | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
samples/client/petstore-security-test/typescript-angular/model/modelReturn.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Swagger Petstore *_/ ' \" =end -- \\r\\n \\n \\r | ||
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end -- | ||
* | ||
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r | ||
* Contact: apiteam@swagger.io *_/ ' \" =end -- \\r\\n \\n \\r | ||
* | ||
* NOTE: This class is auto generated by the swagger code generator program. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
* Do not edit the class manually. | ||
*/ | ||
|
||
|
||
/** | ||
* Model for testing reserved words *_/ ' \" =end -- \\r\\n \\n \\r | ||
*/ | ||
export interface ModelReturn { | ||
/** | ||
* property description *_/ ' \" =end -- \\r\\n \\n \\r | ||
*/ | ||
_return?: number; | ||
} |
2 changes: 1 addition & 1 deletion
2
samples/client/petstore-security-test/typescript-angular2/.swagger-codegen/VERSION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.3.0-SNAPSHOT | ||
2.4.0-SNAPSHOT |
Oops, something went wrong.