Skip to content

Commit ffb3bda

Browse files
feikedewing328
authored andcommitted
typescript-angular: added Interfaces to api exports if withInterfaces is selected (#7975)
* added Interfaces to api exports if withInterfaces is selected * removed import of interface classes * added gererated petstore example api.ts * Fix Issue 8014 * Adapted to work with Angular2 Http and Angular 4.3+ HttpClient * removed unnecessary (others) for ng HttpClient from Interface
1 parent ba7adcc commit ffb3bda

File tree

10 files changed

+36
-10
lines changed

10 files changed

+36
-10
lines changed

modules/swagger-codegen/src/main/resources/typescript-angular/api.service.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { {{classname}} } from '../{{filename}}';
2626
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
2727
import { Configuration } from '../configuration';
2828
{{#withInterfaces}}
29-
import { {{classname}}Interface } from './{{classname}}Interface';
29+
import { {{classname}}Interface } from './{{classFilename}}Interface';
3030
{{/withInterfaces}}
3131

3232
{{#operations}}

modules/swagger-codegen/src/main/resources/typescript-angular/apiInterface.mustache

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
{{>licenseInfo}}
2+
{{#useHttpClient}}
3+
import { HttpHeaders } from '@angular/common/http';
4+
{{/useHttpClient}}
5+
{{^useHttpClient}}
26
import { Headers } from '@angular/http';
7+
{{/useHttpClient}}
38

49
import { Observable } from 'rxjs/Observable';
510

6-
import * as models from '../model/models';
11+
12+
{{#imports}}
13+
import { {{classname}} } from '../{{filename}}';
14+
{{/imports}}
15+
16+
717
import { Configuration } from '../configuration';
818

919
{{#operations}}
@@ -14,9 +24,9 @@ import { Configuration } from '../configurat
1424
*/
1525
{{/description}}
1626
export interface {{classname}}Interface {
17-
defaultHeaders: Headers;
27+
defaultHeaders: {{#useHttpClient}}Http{{/useHttpClient}}Headers;
1828
configuration: Configuration;
19-
[others: string]: any;
29+
{{^useHttpClient}}[others: string]: any;{{/useHttpClient}}
2030

2131
{{#operation}}
2232
/**

modules/swagger-codegen/src/main/resources/typescript-angular/apis.mustache

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
export * from './{{ classFilename }}';
55
import { {{ classname }} } from './{{ classFilename }}';
66
{{/operations}}
7+
{{#withInterfaces}}
8+
export * from './{{ classFilename }}Interface'
9+
{{/withInterfaces}}
710
{{/apis}}
811
export const APIS = [{{#apis}}{{#operations}}{{ classname }}{{/operations}}{{^-last}}, {{/-last}}{{/apis}}];
912
{{/apiInfo}}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
export * from './pet.service';
22
import { PetService } from './pet.service';
3+
export * from './pet.serviceInterface'
34
export * from './store.service';
45
import { StoreService } from './store.service';
6+
export * from './store.serviceInterface'
57
export * from './user.service';
68
import { UserService } from './user.service';
9+
export * from './user.serviceInterface'
710
export const APIS = [PetService, StoreService, UserService];

samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { Pet } from '../model/pet';
2525

2626
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
2727
import { Configuration } from '../configuration';
28-
import { PetServiceInterface } from './PetServiceInterface';
28+
import { PetServiceInterface } from './pet.serviceInterface';
2929

3030

3131
@Injectable()

samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.serviceInterface.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ import { Headers } from '@angular/http
1313

1414
import { Observable } from 'rxjs/Observable';
1515

16-
import * as models from '../model/models';
16+
17+
import { ApiResponse } from '../model/apiResponse';
18+
import { Pet } from '../model/pet';
19+
20+
1721
import { Configuration } from '../configuration';
1822

1923

samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { Order } from '../model/order';
2424

2525
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
2626
import { Configuration } from '../configuration';
27-
import { StoreServiceInterface } from './StoreServiceInterface';
27+
import { StoreServiceInterface } from './store.serviceInterface';
2828

2929

3030
@Injectable()

samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.serviceInterface.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import { Headers } from '@angular/http
1313

1414
import { Observable } from 'rxjs/Observable';
1515

16-
import * as models from '../model/models';
16+
17+
import { Order } from '../model/order';
18+
19+
1720
import { Configuration } from '../configuration';
1821

1922

samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { User } from '../model/user';
2424

2525
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
2626
import { Configuration } from '../configuration';
27-
import { UserServiceInterface } from './UserServiceInterface';
27+
import { UserServiceInterface } from './user.serviceInterface';
2828

2929

3030
@Injectable()

samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.serviceInterface.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ import { Headers } from '@angular/http
1313

1414
import { Observable } from 'rxjs/Observable';
1515

16-
import * as models from '../model/models';
16+
17+
import { User } from '../model/user';
18+
19+
1720
import { Configuration } from '../configuration';
1821

1922

0 commit comments

Comments
 (0)