-
Notifications
You must be signed in to change notification settings - Fork 6k
PR-1334 Improved angular 2 - typescript generation #5695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
648b889
597fa02
99a73d3
80ffbac
47794d8
999e2a5
36774e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import { {{{injectionToken}}} } from '@angular/core'; | ||
|
||
export const BASE_PATH = new {{{injectionToken}}}('basePath'); | ||
export const BASE_PATH = new {{{injectionToken}}}<String>('basePath'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you elaborate on this change? Shouldn't it be There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please see: https://angular.io/docs/ts/latest/api/core/index/InjectionToken-class.html There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's weird. Can you post a minimum working example which doesn't compile? |
||
export const COLLECTION_FORMATS = { | ||
'csv': ',', | ||
'tsv': ' ', | ||
'ssv': ' ', | ||
'pipes': '|' | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.2.3-SNAPSHOT |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
/** | ||
* Swagger Petstore | ||
* This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. | ||
* This is a sample server Petstore server. You can find out more about Swagger at <a href=\"http://swagger.io\">http://swagger.io</a> or on irc.freenode.net, #swagger. For this sample, you can use the api key \"special-key\" to test the authorization filters | ||
* | ||
* OpenAPI spec version: 1.0.0 | ||
* Contact: apiteam@swagger.io | ||
* Contact: apiteam@wordnik.com | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change was probably not intended. Could you please revert it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The latest master is using |
||
* | ||
* NOTE: This class is auto generated by the swagger code generator program. | ||
* https://github.com/swagger-api/swagger-codegen.git | ||
|
@@ -45,7 +45,7 @@ export class PetApi { | |
* | ||
* @param body Pet object that needs to be added to the store | ||
*/ | ||
public addPet(body: models.Pet, extraHttpRequestParams?: any): Observable<{}> { | ||
public addPet(body?: models.Pet, extraHttpRequestParams?: any): Observable<{}> { | ||
return this.addPetWithHttpInfo(body, extraHttpRequestParams) | ||
.map((response: Response) => { | ||
if (response.status === 204) { | ||
|
@@ -78,7 +78,7 @@ export class PetApi { | |
* Multiple status values can be provided with comma separated strings | ||
* @param status Status values that need to be considered for filter | ||
*/ | ||
public findPetsByStatus(status: Array<string>, extraHttpRequestParams?: any): Observable<Array<models.Pet>> { | ||
public findPetsByStatus(status?: Array<string>, extraHttpRequestParams?: any): Observable<Array<models.Pet>> { | ||
return this.findPetsByStatusWithHttpInfo(status, extraHttpRequestParams) | ||
.map((response: Response) => { | ||
if (response.status === 204) { | ||
|
@@ -94,7 +94,7 @@ export class PetApi { | |
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. | ||
* @param tags Tags to filter by | ||
*/ | ||
public findPetsByTags(tags: Array<string>, extraHttpRequestParams?: any): Observable<Array<models.Pet>> { | ||
public findPetsByTags(tags?: Array<string>, extraHttpRequestParams?: any): Observable<Array<models.Pet>> { | ||
return this.findPetsByTagsWithHttpInfo(tags, extraHttpRequestParams) | ||
.map((response: Response) => { | ||
if (response.status === 204) { | ||
|
@@ -107,8 +107,8 @@ export class PetApi { | |
|
||
/** | ||
* Find pet by ID | ||
* Returns a single pet | ||
* @param petId ID of pet to return | ||
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions | ||
* @param petId ID of pet that needs to be fetched | ||
*/ | ||
public getPetById(petId: number, extraHttpRequestParams?: any): Observable<models.Pet> { | ||
return this.getPetByIdWithHttpInfo(petId, extraHttpRequestParams) | ||
|
@@ -126,7 +126,7 @@ export class PetApi { | |
* | ||
* @param body Pet object that needs to be added to the store | ||
*/ | ||
public updatePet(body: models.Pet, extraHttpRequestParams?: any): Observable<{}> { | ||
public updatePet(body?: models.Pet, extraHttpRequestParams?: any): Observable<{}> { | ||
return this.updatePetWithHttpInfo(body, extraHttpRequestParams) | ||
.map((response: Response) => { | ||
if (response.status === 204) { | ||
|
@@ -144,7 +144,7 @@ export class PetApi { | |
* @param name Updated name of the pet | ||
* @param status Updated status of the pet | ||
*/ | ||
public updatePetWithForm(petId: number, name?: string, status?: string, extraHttpRequestParams?: any): Observable<{}> { | ||
public updatePetWithForm(petId: string, name?: string, status?: string, extraHttpRequestParams?: any): Observable<{}> { | ||
return this.updatePetWithFormWithHttpInfo(petId, name, status, extraHttpRequestParams) | ||
.map((response: Response) => { | ||
if (response.status === 204) { | ||
|
@@ -162,7 +162,7 @@ export class PetApi { | |
* @param additionalMetadata Additional data to pass to server | ||
* @param file file to upload | ||
*/ | ||
public uploadFile(petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any): Observable<models.ApiResponse> { | ||
public uploadFile(petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any): Observable<{}> { | ||
return this.uploadFileWithHttpInfo(petId, additionalMetadata, file, extraHttpRequestParams) | ||
.map((response: Response) => { | ||
if (response.status === 204) { | ||
|
@@ -179,15 +179,11 @@ export class PetApi { | |
* | ||
* @param body Pet object that needs to be added to the store | ||
*/ | ||
public addPetWithHttpInfo(body: models.Pet, extraHttpRequestParams?: any): Observable<Response> { | ||
public addPetWithHttpInfo(body?: models.Pet, extraHttpRequestParams?: any): Observable<Response> { | ||
const path = this.basePath + '/pet'; | ||
|
||
let queryParameters = new URLSearchParams(); | ||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 | ||
// verify required parameter 'body' is not null or undefined | ||
if (body === null || body === undefined) { | ||
throw new Error('Required parameter body was null or undefined when calling addPet.'); | ||
} | ||
// to determine the Content-Type header | ||
let consumes: string[] = [ | ||
'application/json', | ||
|
@@ -196,8 +192,8 @@ export class PetApi { | |
|
||
// to determine the Accept header | ||
let produces: string[] = [ | ||
'application/xml', | ||
'application/json' | ||
'application/json', | ||
'application/xml' | ||
]; | ||
|
||
// authentication (petstore_auth) required | ||
|
@@ -250,8 +246,8 @@ export class PetApi { | |
|
||
// to determine the Accept header | ||
let produces: string[] = [ | ||
'application/xml', | ||
'application/json' | ||
'application/json', | ||
'application/xml' | ||
]; | ||
|
||
// authentication (petstore_auth) required | ||
|
@@ -282,17 +278,15 @@ export class PetApi { | |
* Multiple status values can be provided with comma separated strings | ||
* @param status Status values that need to be considered for filter | ||
*/ | ||
public findPetsByStatusWithHttpInfo(status: Array<string>, extraHttpRequestParams?: any): Observable<Response> { | ||
public findPetsByStatusWithHttpInfo(status?: Array<string>, extraHttpRequestParams?: any): Observable<Response> { | ||
const path = this.basePath + '/pet/findByStatus'; | ||
|
||
let queryParameters = new URLSearchParams(); | ||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 | ||
// verify required parameter 'status' is not null or undefined | ||
if (status === null || status === undefined) { | ||
throw new Error('Required parameter status was null or undefined when calling findPetsByStatus.'); | ||
} | ||
if (status) { | ||
queryParameters.set('status', status.join(COLLECTION_FORMATS['csv'])); | ||
status.forEach((element) => { | ||
queryParameters.append('status', <any>element); | ||
}) | ||
} | ||
|
||
// to determine the Content-Type header | ||
|
@@ -301,8 +295,8 @@ export class PetApi { | |
|
||
// to determine the Accept header | ||
let produces: string[] = [ | ||
'application/xml', | ||
'application/json' | ||
'application/json', | ||
'application/xml' | ||
]; | ||
|
||
// authentication (petstore_auth) required | ||
|
@@ -333,17 +327,15 @@ export class PetApi { | |
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. | ||
* @param tags Tags to filter by | ||
*/ | ||
public findPetsByTagsWithHttpInfo(tags: Array<string>, extraHttpRequestParams?: any): Observable<Response> { | ||
public findPetsByTagsWithHttpInfo(tags?: Array<string>, extraHttpRequestParams?: any): Observable<Response> { | ||
const path = this.basePath + '/pet/findByTags'; | ||
|
||
let queryParameters = new URLSearchParams(); | ||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 | ||
// verify required parameter 'tags' is not null or undefined | ||
if (tags === null || tags === undefined) { | ||
throw new Error('Required parameter tags was null or undefined when calling findPetsByTags.'); | ||
} | ||
if (tags) { | ||
queryParameters.set('tags', tags.join(COLLECTION_FORMATS['csv'])); | ||
tags.forEach((element) => { | ||
queryParameters.append('tags', <any>element); | ||
}) | ||
} | ||
|
||
// to determine the Content-Type header | ||
|
@@ -352,8 +344,8 @@ export class PetApi { | |
|
||
// to determine the Accept header | ||
let produces: string[] = [ | ||
'application/xml', | ||
'application/json' | ||
'application/json', | ||
'application/xml' | ||
]; | ||
|
||
// authentication (petstore_auth) required | ||
|
@@ -381,8 +373,8 @@ export class PetApi { | |
|
||
/** | ||
* Find pet by ID | ||
* Returns a single pet | ||
* @param petId ID of pet to return | ||
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions | ||
* @param petId ID of pet that needs to be fetched | ||
*/ | ||
public getPetByIdWithHttpInfo(petId: number, extraHttpRequestParams?: any): Observable<Response> { | ||
const path = this.basePath + '/pet/${petId}' | ||
|
@@ -400,15 +392,24 @@ export class PetApi { | |
|
||
// to determine the Accept header | ||
let produces: string[] = [ | ||
'application/xml', | ||
'application/json' | ||
'application/json', | ||
'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) { | ||
let accessToken = typeof this.configuration.accessToken === 'function' | ||
? this.configuration.accessToken() | ||
: this.configuration.accessToken; | ||
headers.set('Authorization', 'Bearer ' + accessToken); | ||
} | ||
|
||
let requestOptions: RequestOptionsArgs = new RequestOptions({ | ||
method: RequestMethod.Get, | ||
headers: headers, | ||
|
@@ -428,15 +429,11 @@ export class PetApi { | |
* | ||
* @param body Pet object that needs to be added to the store | ||
*/ | ||
public updatePetWithHttpInfo(body: models.Pet, extraHttpRequestParams?: any): Observable<Response> { | ||
public updatePetWithHttpInfo(body?: models.Pet, extraHttpRequestParams?: any): Observable<Response> { | ||
const path = this.basePath + '/pet'; | ||
|
||
let queryParameters = new URLSearchParams(); | ||
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845 | ||
// verify required parameter 'body' is not null or undefined | ||
if (body === null || body === undefined) { | ||
throw new Error('Required parameter body was null or undefined when calling updatePet.'); | ||
} | ||
// to determine the Content-Type header | ||
let consumes: string[] = [ | ||
'application/json', | ||
|
@@ -445,8 +442,8 @@ export class PetApi { | |
|
||
// to determine the Accept header | ||
let produces: string[] = [ | ||
'application/xml', | ||
'application/json' | ||
'application/json', | ||
'application/xml' | ||
]; | ||
|
||
// authentication (petstore_auth) required | ||
|
@@ -482,7 +479,7 @@ export class PetApi { | |
* @param name Updated name of the pet | ||
* @param status Updated status of the pet | ||
*/ | ||
public updatePetWithFormWithHttpInfo(petId: number, name?: string, status?: string, extraHttpRequestParams?: any): Observable<Response> { | ||
public updatePetWithFormWithHttpInfo(petId: string, name?: string, status?: string, extraHttpRequestParams?: any): Observable<Response> { | ||
const path = this.basePath + '/pet/${petId}' | ||
.replace('${' + 'petId' + '}', String(petId)); | ||
|
||
|
@@ -501,8 +498,8 @@ export class PetApi { | |
|
||
// to determine the Accept header | ||
let produces: string[] = [ | ||
'application/xml', | ||
'application/json' | ||
'application/json', | ||
'application/xml' | ||
]; | ||
|
||
// authentication (petstore_auth) required | ||
|
@@ -565,7 +562,8 @@ export class PetApi { | |
|
||
// to determine the Accept header | ||
let produces: string[] = [ | ||
'application/json' | ||
'application/json', | ||
'application/xml' | ||
]; | ||
|
||
// authentication (petstore_auth) required | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a space between
}
andcatch
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure thing.