Fix for missing headers (2.3.0) (#4329)

* Fix for #4322

Signed-off-by: Sebastian Haas <sebastian@haas.tech>

* Run typescript-angular2-petstore-all.sh

Signed-off-by: Sebastian Haas <sebastian@haas.tech>
This commit is contained in:
Sebastian Haas 2016-12-06 17:00:43 +01:00 committed by wing328
parent 4785451bf8
commit 1ee7907aaa
13 changed files with 243 additions and 94 deletions

View File

@ -102,10 +102,9 @@ export class {{classname}} {
}
{{/queryParams}}
{{#headers}}
{{#headerParams}}
headers.set('{{baseName}}', String({{paramName}}));
{{/headers}}
{{/headerParams}}
// to determine the Content-Type header
let consumes: string[] = [

View File

@ -53,6 +53,21 @@ export class PetService {
this.basePath = basePath || configuration.basePath || this.basePath;
}
}
/**
*
* Extends object by coping non-existing properties.
* @param objA object to be extended
* @param objB source object
*/
private extendObj<T1,T2>(objA: T1, objB: T2) {
for(let key in objB){
if(objB.hasOwnProperty(key)){
objA[key] = objB[key];
}
}
return <T1&T2>objA;
}
/**
* Add a new pet to the store
@ -227,9 +242,13 @@ export class PetService {
method: RequestMethod.Post,
headers: headers,
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -250,6 +269,7 @@ export class PetService {
throw new Error('Required parameter petId was null or undefined when calling deletePet.');
}
headers.set('api_key', String(apiKey));
// to determine the Content-Type header
let consumes: string[] = [
@ -274,9 +294,13 @@ export class PetService {
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Delete,
headers: headers,
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -319,9 +343,13 @@ export class PetService {
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Get,
headers: headers,
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -364,9 +392,13 @@ export class PetService {
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Get,
headers: headers,
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -397,17 +429,17 @@ export class PetService {
'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)
{
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
}
// authentication (api_key) required
if (this.configuration.apiKey)
{
headers.set('api_key', this.configuration.apiKey);
}
@ -415,9 +447,13 @@ export class PetService {
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Get,
headers: headers,
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -461,9 +497,13 @@ export class PetService {
method: RequestMethod.Put,
headers: headers,
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -520,9 +560,13 @@ export class PetService {
method: RequestMethod.Post,
headers: headers,
body: formParams.toString(),
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -579,9 +623,13 @@ export class PetService {
method: RequestMethod.Post,
headers: headers,
body: formParams.toString(),
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}

View File

@ -53,6 +53,21 @@ export class StoreService {
this.basePath = basePath || configuration.basePath || this.basePath;
}
}
/**
*
* Extends object by coping non-existing properties.
* @param objA object to be extended
* @param objB source object
*/
private extendObj<T1,T2>(objA: T1, objB: T2) {
for(let key in objB){
if(objB.hasOwnProperty(key)){
objA[key] = objB[key];
}
}
return <T1&T2>objA;
}
/**
* Delete purchase order by ID
@ -151,9 +166,13 @@ export class StoreService {
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Delete,
headers: headers,
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -191,9 +210,13 @@ export class StoreService {
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Get,
headers: headers,
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -231,9 +254,13 @@ export class StoreService {
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Get,
headers: headers,
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -269,9 +296,13 @@ export class StoreService {
method: RequestMethod.Post,
headers: headers,
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}

View File

@ -53,6 +53,21 @@ export class UserService {
this.basePath = basePath || configuration.basePath || this.basePath;
}
}
/**
*
* Extends object by coping non-existing properties.
* @param objA object to be extended
* @param objB source object
*/
private extendObj<T1,T2>(objA: T1, objB: T2) {
for(let key in objB){
if(objB.hasOwnProperty(key)){
objA[key] = objB[key];
}
}
return <T1&T2>objA;
}
/**
* Create user
@ -215,9 +230,13 @@ export class UserService {
method: RequestMethod.Post,
headers: headers,
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -253,9 +272,13 @@ export class UserService {
method: RequestMethod.Post,
headers: headers,
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -291,9 +314,13 @@ export class UserService {
method: RequestMethod.Post,
headers: headers,
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -331,9 +358,13 @@ export class UserService {
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Delete,
headers: headers,
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -371,9 +402,13 @@ export class UserService {
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Get,
headers: headers,
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -414,9 +449,13 @@ export class UserService {
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Get,
headers: headers,
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -449,9 +488,13 @@ export class UserService {
let requestOptions: RequestOptionsArgs = new RequestOptions({
method: RequestMethod.Get,
headers: headers,
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}
@ -492,9 +535,13 @@ export class UserService {
method: RequestMethod.Put,
headers: headers,
body: body == null ? '' : JSON.stringify(body), // https://github.com/angular/angular/issues/10612
search: queryParameters,
responseType: ResponseContentType.Json
search: queryParameters
});
// https://github.com/swagger-api/swagger-codegen/issues/4037
if (extraHttpRequestParams) {
requestOptions = this.extendObj(requestOptions, extraHttpRequestParams);
}
return this.http.request(path, requestOptions);
}

View File

@ -1,4 +1,5 @@
export * from './api/api';
export * from './model/models';
export * from './variables';
export * from './configuration';
export * from './configuration';
export * from './api.module';

View File

@ -1,4 +1,4 @@
## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201611081538
## @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201612061154
### 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.201611081538 --save
npm install @swagger/angular2-typescript-petstore@0.0.1-SNAPSHOT.201612061154 --save
```
_unPublished (not recommended):_
@ -41,4 +41,4 @@ import { BASE_PATH } from './path-to-swagger-gen-service/index';
bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]);
```
```

View File

@ -50,6 +50,7 @@ export class PetService {
}
if (configuration) {
this.configuration = configuration;
this.basePath = basePath || configuration.basePath || this.basePath;
}
}
@ -268,6 +269,7 @@ export class PetService {
throw new Error('Required parameter petId was null or undefined when calling deletePet.');
}
headers.set('api_key', String(apiKey));
// to determine the Content-Type header
let consumes: string[] = [
@ -427,17 +429,17 @@ export class PetService {
'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)
{
headers.set('Authorization', 'Bearer ' + this.configuration.accessToken);
}
// authentication (api_key) required
if (this.configuration.apiKey)
{
headers.set('api_key', this.configuration.apiKey);
}

View File

@ -50,6 +50,7 @@ export class StoreService {
}
if (configuration) {
this.configuration = configuration;
this.basePath = basePath || configuration.basePath || this.basePath;
}
}

View File

@ -50,6 +50,7 @@ export class UserService {
}
if (configuration) {
this.configuration = configuration;
this.basePath = basePath || configuration.basePath || this.basePath;
}
}

View File

@ -1,6 +1,24 @@
export interface ConfigurationParameters {
apiKey?: string;
username?: string;
password?: string;
accessToken?: string;
basePath?: string;
}
export class Configuration {
apiKey: string;
username: string;
password: string;
accessToken: string;
}
apiKey: string;
username: string;
password: string;
accessToken: string;
basePath: string;
constructor(configurationParameters: ConfigurationParameters = {}) {
this.apiKey = configurationParameters.apiKey;
this.username = configurationParameters.username;
this.password = configurationParameters.password;
this.accessToken = configurationParameters.accessToken;
this.basePath = configurationParameters.basePath;
}
}

View File

@ -1,4 +1,5 @@
export * from './api/api';
export * from './model/models';
export * from './variables';
export * from './configuration';
export * from './configuration';
export * from './api.module';

View File

@ -1,6 +1,6 @@
{
"name": "@swagger/angular2-typescript-petstore",
"version": "0.0.1-SNAPSHOT.201611081538",
"version": "0.0.1-SNAPSHOT.201612061154",
"description": "swagger client for @swagger/angular2-typescript-petstore",
"author": "Swagger Codegen Contributors",
"keywords": [
@ -10,8 +10,7 @@
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"build": "typings install && tsc --outDir dist/",
"postinstall": "npm run build"
"build": "typings install && tsc --outDir dist/"
},
"peerDependencies": {
"@angular/core": "^2.0.0",
@ -20,7 +19,7 @@
"@angular/compiler": "^2.0.0",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.17"
},
"devDependencies": {
@ -31,9 +30,9 @@
"@angular/platform-browser": "^2.0.0",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.17",
"typescript": "^1.8.10",
"typescript": "^2.0.0",
"typings": "^1.3.2"
},
"publishConfig":{

View File

@ -1,27 +1,28 @@
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"removeComments": true,
"sourceMap": true,
"outDir": "./lib",
"noLib": false,
"declaration": true
},
"exclude": [
"node_modules",
"typings/main.d.ts",
"typings/main",
"lib"
],
"filesGlob": [
"./model/*.ts",
"./api/*.ts",
"typings/browser.d.ts"
]
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"removeComments": true,
"sourceMap": true,
"outDir": "./lib",
"noLib": false,
"declaration": true
},
"exclude": [
"node_modules",
"typings/main.d.ts",
"typings/main",
"lib",
"dist"
],
"filesGlob": [
"./model/*.ts",
"./api/*.ts",
"typings/browser.d.ts"
]
}