[typescript-angular2] change OpaqueToken to InjectionToken<string> (Issue #5565) (#5569)

* change OpaqueToken to InjectionToken<string> and add useOpaqueToken option for typescript-angular2 (#5565)

* run security shell
This commit is contained in:
Takuro Wada
2017-05-08 19:08:54 +09:00
committed by wing328
parent adb213bc00
commit a81cff0ed0
12 changed files with 38 additions and 23 deletions

View File

@@ -91,9 +91,9 @@ export class FakeApi {
method: RequestMethod.Put,
headers: headers,
body: formParams.toString(),
search: queryParameters
search: queryParameters,
withCredentials:this.configuration.withCredentials
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = (<any>Object).assign(requestOptions, extraHttpRequestParams);

View File

@@ -3,4 +3,5 @@ export class Configuration {
username: string;
password: string;
accessToken: string | (() => string);
withCredentials: boolean;
}

View File

@@ -1,6 +1,6 @@
import { OpaqueToken } from '@angular/core';
import { InjectionToken<string> } from '@angular/core';
export const BASE_PATH = new OpaqueToken('basePath');
export const BASE_PATH = new InjectionToken<string>('basePath');
export const COLLECTION_FORMATS = {
'csv': ',',
'tsv': ' ',

View File

@@ -396,6 +396,11 @@ export class PetApi {
'application/xml'
];
// authentication (api_key) required
if (this.configuration.apiKey) {
headers.set('api_key', this.configuration.apiKey);
}
// authentication (petstore_auth) required
// oauth required
if (this.configuration.accessToken) {
@@ -405,11 +410,6 @@ export class PetApi {
headers.set('Authorization', 'Bearer ' + accessToken);
}
// authentication (api_key) required
if (this.configuration.apiKey) {
headers.set('api_key', this.configuration.apiKey);
}
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Get,
headers: headers,

View File

@@ -1,6 +1,6 @@
import { OpaqueToken } from '@angular/core';
import { InjectionToken<string> } from '@angular/core';
export const BASE_PATH = new OpaqueToken('basePath');
export const BASE_PATH = new InjectionToken<string>('basePath');
export const COLLECTION_FORMATS = {
'csv': ',',
'tsv': ' ',

View File

@@ -1,4 +1,4 @@
## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201704272137
## @swagger/angular2-typescript-petstore@0.0.1
### Building
@@ -19,7 +19,7 @@ navigate to the folder of your consuming project and run one of next commando's.
_published:_
```
npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201704272137 --save
npm install @swagger/angular2-typescript-petstore@0.0.1 --save
```
_unPublished (not recommended):_

View File

@@ -396,6 +396,11 @@ export class PetApi {
'application/xml'
];
// authentication (api_key) required
if (this.configuration.apiKey) {
headers.set('api_key', this.configuration.apiKey);
}
// authentication (petstore_auth) required
// oauth required
if (this.configuration.accessToken) {
@@ -405,11 +410,6 @@ export class PetApi {
headers.set('Authorization', 'Bearer ' + accessToken);
}
// authentication (api_key) required
if (this.configuration.apiKey) {
headers.set('api_key', this.configuration.apiKey);
}
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Get,
headers: headers,

View File

@@ -1,6 +1,6 @@
{
"name": "@swagger/angular2-typescript-petstore",
"version": "0.0.1-SNAPSHOT.201704272137",
"version": "0.0.1",
"description": "swagger client for @swagger/angular2-typescript-petstore",
"author": "Swagger Codegen Contributors",
"keywords": [

View File

@@ -1,6 +1,6 @@
import { OpaqueToken } from '@angular/core';
import { InjectionToken<string> } from '@angular/core';
export const BASE_PATH = new OpaqueToken('basePath');
export const BASE_PATH = new InjectionToken<string>('basePath');
export const COLLECTION_FORMATS = {
'csv': ',',
'tsv': ' ',