Merge branch 'ts_angular2_typings' of https://github.com/wing328/swagger-codegen into wing328-ts_angular2_typings

This commit is contained in:
wing328 2017-07-02 22:01:10 +08:00
commit 15382f5b77
22 changed files with 329 additions and 181 deletions

View File

@ -28,9 +28,37 @@ _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 {{npmName}}@{{npmVersion}}
```
In your angular2 project:
TODO: paste example.
```
import { DefaultApi } from '{{npmName}}/api/api';
@NgModule({
imports: [],
declarations: [],
exports: [],
providers: [AppModule]
})
export class CoreModule {}
```
```
import { DefaultApi } from '{{npmName}}/api/api';
export class AppComponent {
constructor(private apiGateway: DefaultApi) { }
}
```
### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service.
@ -42,3 +70,29 @@ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]);
```
#### 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 '{{npmName}}';
import { environment } from '../environments/environment';
@NgModule({
declarations: [
AppComponent,
],
imports: [ ],
providers: [{ provide: BASE_PATH, useValue: useValue: environment.API_BASE_PATH }],
bootstrap: [AppComponent]
})
export class AppModule { }
```

View File

@ -10,30 +10,29 @@
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"build": "typings install && tsc --outDir dist/"
"build": "tsc --outDir dist/",
"postinstall": "npm run build"
},
"peerDependencies": {
"@angular/core": "^2.0.0",
"@angular/http": "^2.0.0",
"@angular/common": "^2.0.0",
"@angular/compiler": "^2.0.0",
"@angular/core": "^2.2.2",
"@angular/http": "^2.2.2",
"@angular/common": "^2.2.2",
"@angular/compiler": "^2.2.2",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.17"
"rxjs": "^5.1.0",
"zone.js": "^0.7.6"
},
"devDependencies": {
"@angular/core": "^2.0.0",
"@angular/http": "^2.0.0",
"@angular/common": "^2.0.0",
"@angular/compiler": "^2.0.0",
"@angular/platform-browser": "^2.0.0",
"core-js": "^2.4.0",
"@angular/core": "^2.2.2",
"@angular/http": "^2.2.2",
"@angular/common": "^2.2.2",
"@angular/compiler": "^2.2.2",
"@angular/platform-browser": "^2.2.2",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.17",
"typescript": "^2.0.0",
"typings": "^1.3.2"
"rxjs": "5.1.0",
"zone.js": "^0.7.6",
"typescript": "^2.1.5"
}{{#npmRepository}},{{/npmRepository}}
{{#npmRepository}}
"publishConfig":{

View File

@ -5,23 +5,21 @@
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"target": "es5",
"module": "commonjs",
"module": "es6",
"moduleResolution": "node",
"removeComments": true,
"sourceMap": true,
"outDir": "./dist",
"noLib": false,
"declaration": true
"declaration": true,
"lib": [ "es6", "dom" ]
},
"exclude": [
"node_modules",
"typings/main.d.ts",
"typings/main",
"dist"
],
"filesGlob": [
"./model/*.ts",
"./api/*.ts",
"typings/browser.d.ts"
"./api/*.ts"
]
}

View File

@ -1,9 +1,9 @@
/**
* Swagger Petstore
* 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
* 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.
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@wordnik.com
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@ -20,6 +20,7 @@ import { Response, ResponseContentType } from '@angular/http
import { Observable } from 'rxjs/Observable';
import '../rxjs-operators';
import { ApiResponse } from '../model/apiResponse';
import { Pet } from '../model/pet';
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
@ -77,7 +78,7 @@ export class PetService {
*
* @param body Pet object that needs to be added to the store
*/
public addPet(body?: Pet, extraHttpRequestParams?: any): Observable<{}> {
public addPet(body: Pet, extraHttpRequestParams?: any): Observable<{}> {
return this.addPetWithHttpInfo(body, extraHttpRequestParams)
.map((response: Response) => {
if (response.status === 204) {
@ -110,7 +111,7 @@ export class PetService {
* 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<Pet>> {
public findPetsByStatus(status: Array<string>, extraHttpRequestParams?: any): Observable<Array<Pet>> {
return this.findPetsByStatusWithHttpInfo(status, extraHttpRequestParams)
.map((response: Response) => {
if (response.status === 204) {
@ -126,7 +127,7 @@ export class PetService {
* 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<Pet>> {
public findPetsByTags(tags: Array<string>, extraHttpRequestParams?: any): Observable<Array<Pet>> {
return this.findPetsByTagsWithHttpInfo(tags, extraHttpRequestParams)
.map((response: Response) => {
if (response.status === 204) {
@ -139,8 +140,8 @@ export class PetService {
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* Returns a single pet
* @param petId ID of pet to return
*/
public getPetById(petId: number, extraHttpRequestParams?: any): Observable<Pet> {
return this.getPetByIdWithHttpInfo(petId, extraHttpRequestParams)
@ -158,7 +159,7 @@ export class PetService {
*
* @param body Pet object that needs to be added to the store
*/
public updatePet(body?: Pet, extraHttpRequestParams?: any): Observable<{}> {
public updatePet(body: Pet, extraHttpRequestParams?: any): Observable<{}> {
return this.updatePetWithHttpInfo(body, extraHttpRequestParams)
.map((response: Response) => {
if (response.status === 204) {
@ -176,7 +177,7 @@ export class PetService {
* @param name Updated name of the pet
* @param status Updated status of the pet
*/
public updatePetWithForm(petId: string, name?: string, status?: string, extraHttpRequestParams?: any): Observable<{}> {
public updatePetWithForm(petId: number, name?: string, status?: string, extraHttpRequestParams?: any): Observable<{}> {
return this.updatePetWithFormWithHttpInfo(petId, name, status, extraHttpRequestParams)
.map((response: Response) => {
if (response.status === 204) {
@ -194,7 +195,7 @@ export class PetService {
* @param additionalMetadata Additional data to pass to server
* @param file file to upload
*/
public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, extraHttpRequestParams?: any): Observable<{}> {
public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, extraHttpRequestParams?: any): Observable<ApiResponse> {
return this.uploadFileWithHttpInfo(petId, additionalMetadata, file, extraHttpRequestParams)
.map((response: Response) => {
if (response.status === 204) {
@ -211,17 +212,21 @@ export class PetService {
*
* @param body Pet object that needs to be added to the store
*/
public addPetWithHttpInfo(body?: Pet, extraHttpRequestParams?: any): Observable<Response> {
public addPetWithHttpInfo(body: 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 Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];
// authentication (petstore_auth) required
@ -275,8 +280,8 @@ export class PetService {
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];
// authentication (petstore_auth) required
@ -308,23 +313,25 @@ export class PetService {
* 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) {
status.forEach((element) => {
queryParameters.append('status', <any>element);
})
queryParameters.set('status', status.join(COLLECTION_FORMATS['csv']));
}
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];
// authentication (petstore_auth) required
@ -356,23 +363,25 @@ export class PetService {
* 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) {
tags.forEach((element) => {
queryParameters.append('tags', <any>element);
})
queryParameters.set('tags', tags.join(COLLECTION_FORMATS['csv']));
}
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];
// authentication (petstore_auth) required
@ -401,8 +410,8 @@ export class PetService {
/**
* Find pet by ID
* Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
* @param petId ID of pet that needs to be fetched
* Returns a single pet
* @param petId ID of pet to return
*/
public getPetByIdWithHttpInfo(petId: number, extraHttpRequestParams?: any): Observable<Response> {
const path = this.basePath + '/pet/${petId}'
@ -418,8 +427,8 @@ export class PetService {
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];
// authentication (api_key) required
@ -427,15 +436,6 @@ export class PetService {
headers.set('api_key', this.configuration.apiKeys["api_key"]);
}
// 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,
@ -456,17 +456,21 @@ export class PetService {
*
* @param body Pet object that needs to be added to the store
*/
public updatePetWithHttpInfo(body?: Pet, extraHttpRequestParams?: any): Observable<Response> {
public updatePetWithHttpInfo(body: 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 Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];
// authentication (petstore_auth) required
@ -503,7 +507,7 @@ export class PetService {
* @param name Updated name of the pet
* @param status Updated status of the pet
*/
public updatePetWithFormWithHttpInfo(petId: string, name?: string, status?: string, extraHttpRequestParams?: any): Observable<Response> {
public updatePetWithFormWithHttpInfo(petId: number, name?: string, status?: string, extraHttpRequestParams?: any): Observable<Response> {
const path = this.basePath + '/pet/${petId}'
.replace('${' + 'petId' + '}', String(petId));
@ -526,8 +530,8 @@ export class PetService {
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];
// authentication (petstore_auth) required
@ -594,8 +598,7 @@ export class PetService {
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/json'
];
// authentication (petstore_auth) required

View File

@ -1,9 +1,9 @@
/**
* Swagger Petstore
* 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
* 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.
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@wordnik.com
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@ -108,7 +108,7 @@ export class StoreService {
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched
*/
public getOrderById(orderId: string, extraHttpRequestParams?: any): Observable<Order> {
public getOrderById(orderId: number, extraHttpRequestParams?: any): Observable<Order> {
return this.getOrderByIdWithHttpInfo(orderId, extraHttpRequestParams)
.map((response: Response) => {
if (response.status === 204) {
@ -124,7 +124,7 @@ export class StoreService {
*
* @param body order placed for purchasing the pet
*/
public placeOrder(body?: Order, extraHttpRequestParams?: any): Observable<Order> {
public placeOrder(body: Order, extraHttpRequestParams?: any): Observable<Order> {
return this.placeOrderWithHttpInfo(body, extraHttpRequestParams)
.map((response: Response) => {
if (response.status === 204) {
@ -155,8 +155,8 @@ export class StoreService {
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];
@ -187,8 +187,7 @@ export class StoreService {
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/json'
];
// authentication (api_key) required
@ -216,7 +215,7 @@ export class StoreService {
* For valid response try integer IDs with value &lt;&#x3D; 5 or &gt; 10. Other values will generated exceptions
* @param orderId ID of pet that needs to be fetched
*/
public getOrderByIdWithHttpInfo(orderId: string, extraHttpRequestParams?: any): Observable<Response> {
public getOrderByIdWithHttpInfo(orderId: number, extraHttpRequestParams?: any): Observable<Response> {
const path = this.basePath + '/store/order/${orderId}'
.replace('${' + 'orderId' + '}', String(orderId));
@ -230,8 +229,8 @@ export class StoreService {
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];
@ -254,17 +253,21 @@ export class StoreService {
*
* @param body order placed for purchasing the pet
*/
public placeOrderWithHttpInfo(body?: Order, extraHttpRequestParams?: any): Observable<Response> {
public placeOrderWithHttpInfo(body: Order, extraHttpRequestParams?: any): Observable<Response> {
const path = this.basePath + '/store/order';
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 placeOrder.');
}
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];

View File

@ -1,9 +1,9 @@
/**
* Swagger Petstore
* 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
* 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.
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@wordnik.com
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@ -77,7 +77,7 @@ export class UserService {
* This can only be done by the logged in user.
* @param body Created user object
*/
public createUser(body?: User, extraHttpRequestParams?: any): Observable<{}> {
public createUser(body: User, extraHttpRequestParams?: any): Observable<{}> {
return this.createUserWithHttpInfo(body, extraHttpRequestParams)
.map((response: Response) => {
if (response.status === 204) {
@ -93,7 +93,7 @@ export class UserService {
*
* @param body List of user object
*/
public createUsersWithArrayInput(body?: Array<User>, extraHttpRequestParams?: any): Observable<{}> {
public createUsersWithArrayInput(body: Array<User>, extraHttpRequestParams?: any): Observable<{}> {
return this.createUsersWithArrayInputWithHttpInfo(body, extraHttpRequestParams)
.map((response: Response) => {
if (response.status === 204) {
@ -109,7 +109,7 @@ export class UserService {
*
* @param body List of user object
*/
public createUsersWithListInput(body?: Array<User>, extraHttpRequestParams?: any): Observable<{}> {
public createUsersWithListInput(body: Array<User>, extraHttpRequestParams?: any): Observable<{}> {
return this.createUsersWithListInputWithHttpInfo(body, extraHttpRequestParams)
.map((response: Response) => {
if (response.status === 204) {
@ -158,7 +158,7 @@ export class UserService {
* @param username The user name for login
* @param password The password for login in clear text
*/
public loginUser(username?: string, password?: string, extraHttpRequestParams?: any): Observable<string> {
public loginUser(username: string, password: string, extraHttpRequestParams?: any): Observable<string> {
return this.loginUserWithHttpInfo(username, password, extraHttpRequestParams)
.map((response: Response) => {
if (response.status === 204) {
@ -190,7 +190,7 @@ export class UserService {
* @param username name that need to be deleted
* @param body Updated user object
*/
public updateUser(username: string, body?: User, extraHttpRequestParams?: any): Observable<{}> {
public updateUser(username: string, body: User, extraHttpRequestParams?: any): Observable<{}> {
return this.updateUserWithHttpInfo(username, body, extraHttpRequestParams)
.map((response: Response) => {
if (response.status === 204) {
@ -207,17 +207,21 @@ export class UserService {
* This can only be done by the logged in user.
* @param body Created user object
*/
public createUserWithHttpInfo(body?: User, extraHttpRequestParams?: any): Observable<Response> {
public createUserWithHttpInfo(body: User, extraHttpRequestParams?: any): Observable<Response> {
const path = this.basePath + '/user';
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 createUser.');
}
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];
@ -243,17 +247,21 @@ export class UserService {
*
* @param body List of user object
*/
public createUsersWithArrayInputWithHttpInfo(body?: Array<User>, extraHttpRequestParams?: any): Observable<Response> {
public createUsersWithArrayInputWithHttpInfo(body: Array<User>, extraHttpRequestParams?: any): Observable<Response> {
const path = this.basePath + '/user/createWithArray';
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 createUsersWithArrayInput.');
}
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];
@ -279,17 +287,21 @@ export class UserService {
*
* @param body List of user object
*/
public createUsersWithListInputWithHttpInfo(body?: Array<User>, extraHttpRequestParams?: any): Observable<Response> {
public createUsersWithListInputWithHttpInfo(body: Array<User>, extraHttpRequestParams?: any): Observable<Response> {
const path = this.basePath + '/user/createWithList';
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 createUsersWithListInput.');
}
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];
@ -329,8 +341,8 @@ export class UserService {
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];
@ -367,8 +379,8 @@ export class UserService {
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];
@ -392,12 +404,20 @@ export class UserService {
* @param username The user name for login
* @param password The password for login in clear text
*/
public loginUserWithHttpInfo(username?: string, password?: string, extraHttpRequestParams?: any): Observable<Response> {
public loginUserWithHttpInfo(username: string, password: string, extraHttpRequestParams?: any): Observable<Response> {
const path = this.basePath + '/user/login';
let queryParameters = new URLSearchParams();
let headers = new Headers(this.defaultHeaders.toJSON()); // https://github.com/angular/angular/issues/6845
// verify required parameter 'username' is not null or undefined
if (username === null || username === undefined) {
throw new Error('Required parameter username was null or undefined when calling loginUser.');
}
// verify required parameter 'password' is not null or undefined
if (password === null || password === undefined) {
throw new Error('Required parameter password was null or undefined when calling loginUser.');
}
if (username !== undefined) {
queryParameters.set('username', <any>username);
}
@ -409,8 +429,8 @@ export class UserService {
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];
@ -441,8 +461,8 @@ export class UserService {
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];
@ -466,7 +486,7 @@ export class UserService {
* @param username name that need to be deleted
* @param body Updated user object
*/
public updateUserWithHttpInfo(username: string, body?: User, extraHttpRequestParams?: any): Observable<Response> {
public updateUserWithHttpInfo(username: string, body: User, extraHttpRequestParams?: any): Observable<Response> {
const path = this.basePath + '/user/${username}'
.replace('${' + 'username' + '}', String(username));
@ -477,11 +497,15 @@ export class UserService {
if (username === null || username === undefined) {
throw new Error('Required parameter username was null or undefined when calling updateUser.');
}
// 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 updateUser.');
}
// to determine the Accept header
let produces: string[] = [
'application/json',
'application/xml'
'application/xml',
'application/json'
];

View File

@ -1,9 +1,9 @@
/**
* Swagger Petstore
* 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
* 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.
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@wordnik.com
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@ -12,6 +12,9 @@
/**
* A category for a pet
*/
export interface Category {
id?: number;

View File

@ -1,3 +1,4 @@
export * from './apiResponse';
export * from './category';
export * from './order';
export * from './pet';

View File

@ -1,9 +1,9 @@
/**
* Swagger Petstore
* 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
* 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.
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@wordnik.com
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@ -12,6 +12,9 @@
/**
* An order for a pets from the pet store
*/
export interface Order {
id?: number;

View File

@ -1,9 +1,9 @@
/**
* Swagger Petstore
* 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
* 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.
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@wordnik.com
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@ -14,6 +14,9 @@ import { Category } from './category';
import { Tag } from './tag';
/**
* A pet for sale in the pet store
*/
export interface Pet {
id?: number;

View File

@ -1,9 +1,9 @@
/**
* Swagger Petstore
* 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
* 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.
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@wordnik.com
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@ -12,6 +12,9 @@
/**
* A tag for a pet
*/
export interface Tag {
id?: number;

View File

@ -1,9 +1,9 @@
/**
* Swagger Petstore
* 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
* 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.
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@wordnik.com
* Contact: apiteam@swagger.io
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
@ -12,6 +12,9 @@
/**
* A User who is purchasing from the pet store
*/
export interface User {
id?: number;

View File

@ -28,9 +28,37 @@ _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 @swagger/angular2-typescript-petstore@0.0.1
```
In your angular2 project:
TODO: paste example.
```
import { DefaultApi } from '@swagger/angular2-typescript-petstore/api/api';
@NgModule({
imports: [],
declarations: [],
exports: [],
providers: [AppModule]
})
export class CoreModule {}
```
```
import { DefaultApi } from '@swagger/angular2-typescript-petstore/api/api';
export class AppComponent {
constructor(private apiGateway: DefaultApi) { }
}
```
### Set service base path
If different than the generated base path, during app bootstrap, you can provide the base path to your service.
@ -42,3 +70,29 @@ bootstrap(AppComponent, [
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' },
]);
```
#### 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 '@swagger/angular2-typescript-petstore';
import { environment } from '../environments/environment';
@NgModule({
declarations: [
AppComponent,
],
imports: [ ],
providers: [{ provide: BASE_PATH, useValue: useValue: environment.API_BASE_PATH }],
bootstrap: [AppComponent]
})
export class AppModule { }
```

View File

@ -10,30 +10,29 @@
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"scripts": {
"build": "typings install && tsc --outDir dist/"
"build": "tsc --outDir dist/",
"postinstall": "npm run build"
},
"peerDependencies": {
"@angular/core": "^2.0.0",
"@angular/http": "^2.0.0",
"@angular/common": "^2.0.0",
"@angular/compiler": "^2.0.0",
"@angular/core": "^2.2.2",
"@angular/http": "^2.2.2",
"@angular/common": "^2.2.2",
"@angular/compiler": "^2.2.2",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.17"
"rxjs": "^5.1.0",
"zone.js": "^0.7.6"
},
"devDependencies": {
"@angular/core": "^2.0.0",
"@angular/http": "^2.0.0",
"@angular/common": "^2.0.0",
"@angular/compiler": "^2.0.0",
"@angular/platform-browser": "^2.0.0",
"core-js": "^2.4.0",
"@angular/core": "^2.2.2",
"@angular/http": "^2.2.2",
"@angular/common": "^2.2.2",
"@angular/compiler": "^2.2.2",
"@angular/platform-browser": "^2.2.2",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.12",
"zone.js": "^0.6.17",
"typescript": "^2.0.0",
"typings": "^1.3.2"
"rxjs": "5.1.0",
"zone.js": "^0.7.6",
"typescript": "^2.1.5"
},
"publishConfig":{
"registry":"https://skimdb.npmjs.com/registry"

View File

@ -5,23 +5,21 @@
"noImplicitAny": false,
"suppressImplicitAnyIndexErrors": true,
"target": "es5",
"module": "commonjs",
"module": "es6",
"moduleResolution": "node",
"removeComments": true,
"sourceMap": true,
"outDir": "./dist",
"noLib": false,
"declaration": true
"declaration": true,
"lib": [ "es6", "dom" ]
},
"exclude": [
"node_modules",
"typings/main.d.ts",
"typings/main",
"dist"
],
"filesGlob": [
"./model/*.ts",
"./api/*.ts",
"typings/browser.d.ts"
"./api/*.ts"
]
}

View File

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

View File

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