forked from loafle/openapi-generator-original
Merge pull request #1497 from aersamkull/master
Aligns the two typescript generators
This commit is contained in:
commit
40bd4415f9
@ -4,7 +4,7 @@ import io.swagger.codegen.SupportingFile;
|
||||
import java.io.File;
|
||||
|
||||
public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCodegen {
|
||||
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "typescript-angular";
|
||||
|
@ -12,12 +12,12 @@ namespace {{package}} {
|
||||
*/
|
||||
{{/description}}
|
||||
export class {{classname}} {
|
||||
private basePath = '{{basePath}}';
|
||||
protected basePath = '{{basePath}}';
|
||||
public defaultHeaders : any = {};
|
||||
|
||||
static $inject: string[] = ['$http', '$httpParamSerializer'];
|
||||
|
||||
constructor(private $http: ng.IHttpService, basePath?: string, private $httpParamSerializer?: (d: any) => any) {
|
||||
constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
@ -68,7 +68,7 @@ namespace {{package}} {
|
||||
{{/hasFormParams}}
|
||||
{{#formParams}}
|
||||
formParams['{{baseName}}'] = {{paramName}};
|
||||
|
||||
|
||||
{{/formParams}}
|
||||
let httpRequestParams: any = {
|
||||
method: '{{httpMethod}}',
|
||||
|
@ -27,7 +27,7 @@ namespace {{package}} {
|
||||
{{#vars}}
|
||||
{{#isEnum}}
|
||||
|
||||
export enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}}
|
||||
export enum {{datatypeWithEnum}} { {{#allowableValues}}{{#values}}
|
||||
{{.}} = <any> '{{.}}',{{/values}}{{/allowableValues}}
|
||||
}
|
||||
{{/isEnum}}
|
||||
@ -36,4 +36,4 @@ namespace {{package}} {
|
||||
{{/hasEnums}}
|
||||
{{/model}}
|
||||
{{/models}}
|
||||
}
|
||||
}
|
||||
|
@ -95,7 +95,11 @@ class VoidAuth implements Authentication {
|
||||
*/
|
||||
{{/description}}
|
||||
export class {{classname}} {
|
||||
private basePath = '{{basePath}}';
|
||||
protected basePath = '{{basePath}}';
|
||||
protected defaultHeaders : any = {};
|
||||
|
||||
|
||||
|
||||
public authentications = {
|
||||
'default': <Authentication>new VoidAuth(),
|
||||
{{#authMethods}}
|
||||
@ -154,17 +158,21 @@ export class {{classname}} {
|
||||
{{#isOAuth}}
|
||||
{{/isOAuth}}
|
||||
{{/authMethods}}
|
||||
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;
|
||||
}
|
||||
{{#operation}}
|
||||
|
||||
public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : Promise<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}} }> {
|
||||
let path = this.url + this.basePath + '{{path}}';
|
||||
|
||||
{{#pathParams}}
|
||||
path = path.replace('{' + '{{baseName}}' + '}', String({{paramName}}));
|
||||
|
||||
{{/pathParams}}
|
||||
public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) : Promise<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }> {
|
||||
const path = this.url + this.basePath + '{{path}}'{{#pathParams}}
|
||||
.replace('{' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}};
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
let formParams: any = {};
|
||||
|
||||
{{#allParams}}{{#required}}
|
||||
@ -194,7 +202,7 @@ export class {{classname}} {
|
||||
{{/isFile}}
|
||||
|
||||
{{/formParams}}
|
||||
let deferred = promise.defer<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}} }>();
|
||||
let deferred = promise.defer<{ response: http.ClientResponse; {{#returnType}}body: {{{returnType}}}; {{/returnType}}{{^returnType}}body?: any; {{/returnType}} }>();
|
||||
|
||||
let requestOptions: request.Options = {
|
||||
method: '{{httpMethod}}',
|
||||
|
@ -1,13 +1,24 @@
|
||||
/// <reference path="api.d.ts" />
|
||||
|
||||
module API.Client {
|
||||
namespace API.Client {
|
||||
'use strict';
|
||||
|
||||
export class Category {
|
||||
|
||||
|
||||
|
||||
export interface Category {
|
||||
|
||||
|
||||
|
||||
id: number;
|
||||
|
||||
|
||||
|
||||
name: string;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,32 +1,67 @@
|
||||
/// <reference path="api.d.ts" />
|
||||
|
||||
module API.Client {
|
||||
namespace API.Client {
|
||||
'use strict';
|
||||
|
||||
export class Order {
|
||||
|
||||
|
||||
|
||||
export interface Order {
|
||||
|
||||
|
||||
|
||||
id: number;
|
||||
|
||||
|
||||
|
||||
petId: number;
|
||||
|
||||
|
||||
|
||||
quantity: number;
|
||||
|
||||
|
||||
|
||||
shipDate: Date;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Order Status
|
||||
*/
|
||||
|
||||
status: Order.StatusEnum;
|
||||
|
||||
|
||||
|
||||
complete: boolean;
|
||||
|
||||
}
|
||||
|
||||
export module Order {
|
||||
|
||||
export enum StatusEnum {
|
||||
placed = <any> 'placed',
|
||||
approved = <any> 'approved',
|
||||
export namespace Order {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export enum StatusEnum {
|
||||
placed = <any> 'placed',
|
||||
approved = <any> 'approved',
|
||||
delivered = <any> 'delivered',
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,32 +1,67 @@
|
||||
/// <reference path="api.d.ts" />
|
||||
|
||||
module API.Client {
|
||||
namespace API.Client {
|
||||
'use strict';
|
||||
|
||||
export class Pet {
|
||||
|
||||
|
||||
|
||||
export interface Pet {
|
||||
|
||||
|
||||
|
||||
id: number;
|
||||
|
||||
|
||||
|
||||
category: Category;
|
||||
|
||||
|
||||
|
||||
name: string;
|
||||
|
||||
|
||||
|
||||
photoUrls: Array<string>;
|
||||
|
||||
|
||||
|
||||
tags: Array<Tag>;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* pet status in the store
|
||||
*/
|
||||
|
||||
status: Pet.StatusEnum;
|
||||
|
||||
}
|
||||
|
||||
export module Pet {
|
||||
|
||||
export enum StatusEnum {
|
||||
available = <any> 'available',
|
||||
pending = <any> 'pending',
|
||||
export namespace Pet {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export enum StatusEnum {
|
||||
available = <any> 'available',
|
||||
pending = <any> 'pending',
|
||||
sold = <any> 'sold',
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,26 +2,48 @@
|
||||
|
||||
/* tslint:disable:no-unused-variable member-ordering */
|
||||
|
||||
module API.Client {
|
||||
|
||||
namespace API.Client {
|
||||
'use strict';
|
||||
|
||||
|
||||
export class PetApi {
|
||||
private basePath = 'http://petstore.swagger.io/v2';
|
||||
protected basePath = 'http://petstore.swagger.io/v2';
|
||||
public defaultHeaders : any = {};
|
||||
|
||||
static $inject: string[] = ['$http', '$httpParamSerializer'];
|
||||
|
||||
constructor(private $http: ng.IHttpService, basePath?: string, private $httpParamSerializer?: (any) => any) {
|
||||
constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
|
||||
if (basePath) {
|
||||
this.basePath = basePath;
|
||||
}
|
||||
}
|
||||
|
||||
public updatePet (body?: Pet, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/pet';
|
||||
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;
|
||||
}
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headerParams: any = {};
|
||||
var httpRequestParams: any = {
|
||||
|
||||
|
||||
public updatePet (body?: Pet, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
const path = this.basePath + '/pet';
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'PUT',
|
||||
url: path,
|
||||
json: true,
|
||||
@ -33,22 +55,27 @@ module API.Client {
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams) {
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public addPet (body?: Pet, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/pet';
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headerParams: any = {};
|
||||
var httpRequestParams: any = {
|
||||
public addPet (body?: Pet, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
const path = this.basePath + '/pet';
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: true,
|
||||
@ -60,26 +87,32 @@ module API.Client {
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams) {
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public findPetsByStatus (status?: Array<string>, extraHttpRequestParams?: any ) : ng.IHttpPromise<Array<Pet>> {
|
||||
var path = this.basePath + '/pet/findByStatus';
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headerParams: any = {};
|
||||
public findPetsByStatus (status?: Array<string>, extraHttpRequestParams?: any ) : ng.IHttpPromise<Array<Pet>> {
|
||||
const path = this.basePath + '/pet/findByStatus';
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (status !== undefined) {
|
||||
queryParameters['status'] = status;
|
||||
}
|
||||
|
||||
var httpRequestParams: any = {
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
@ -90,26 +123,32 @@ module API.Client {
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams) {
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
public findPetsByTags (tags?: Array<string>, extraHttpRequestParams?: any ) : ng.IHttpPromise<Array<Pet>> {
|
||||
var path = this.basePath + '/pet/findByTags';
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headerParams: any = {};
|
||||
public findPetsByTags (tags?: Array<string>, extraHttpRequestParams?: any ) : ng.IHttpPromise<Array<Pet>> {
|
||||
const path = this.basePath + '/pet/findByTags';
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (tags !== undefined) {
|
||||
queryParameters['tags'] = tags;
|
||||
}
|
||||
|
||||
var httpRequestParams: any = {
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
@ -120,29 +159,33 @@ module API.Client {
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams) {
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
|
||||
public getPetById (petId: number, extraHttpRequestParams?: any ) : ng.IHttpPromise<Pet> {
|
||||
var path = this.basePath + '/pet/{petId}';
|
||||
const path = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
path = path.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headerParams: any = {};
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling getPetById');
|
||||
}
|
||||
|
||||
var httpRequestParams: any = {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
json: true,
|
||||
@ -153,37 +196,49 @@ module API.Client {
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams) {
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
|
||||
public updatePetWithForm (petId: string, name?: string, status?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/pet/{petId}';
|
||||
const path = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
path = path.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headerParams: any = {};
|
||||
var formParams: any = {};
|
||||
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling updatePetWithForm');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
|
||||
|
||||
|
||||
formParams['name'] = name;
|
||||
|
||||
|
||||
|
||||
formParams['status'] = status;
|
||||
|
||||
var httpRequestParams: any = {
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: false,
|
||||
@ -195,31 +250,38 @@ module API.Client {
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams) {
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
|
||||
public deletePet (petId: number, apiKey?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/pet/{petId}';
|
||||
const path = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
path = path.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headerParams: any = {};
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling deletePet');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
headerParams['api_key'] = apiKey;
|
||||
|
||||
var httpRequestParams: any = {
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'DELETE',
|
||||
url: path,
|
||||
json: true,
|
||||
@ -230,37 +292,49 @@ module API.Client {
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams) {
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
|
||||
public uploadFile (petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
var path = this.basePath + '/pet/{petId}/uploadImage';
|
||||
const path = this.basePath + '/pet/{petId}/uploadImage'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
let formParams: any = {};
|
||||
|
||||
|
||||
path = path.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
var queryParameters: any = {};
|
||||
var headerParams: any = {};
|
||||
var formParams: any = {};
|
||||
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling uploadFile');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
|
||||
|
||||
|
||||
|
||||
formParams['additionalMetadata'] = additionalMetadata;
|
||||
|
||||
|
||||
|
||||
formParams['file'] = file;
|
||||
|
||||
var httpRequestParams: any = {
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
json: false,
|
||||
@ -272,14 +346,12 @@ module API.Client {
|
||||
};
|
||||
|
||||
if (extraHttpRequestParams) {
|
||||
for (var k in extraHttpRequestParams) {
|
||||
if (extraHttpRequestParams.hasOwnProperty(k)) {
|
||||
httpRequestParams[k] = extraHttpRequestParams[k];
|
||||
}
|
||||
}
|
||||
httpRequestParams = this.extendObj(httpRequestParams, extraHttpRequestParams);
|
||||
}
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,13 +1,24 @@
|
||||
/// <reference path="api.d.ts" />
|
||||
|
||||
module API.Client {
|
||||
namespace API.Client {
|
||||
'use strict';
|
||||
|
||||
export class Tag {
|
||||
|
||||
|
||||
|
||||
export interface Tag {
|
||||
|
||||
|
||||
|
||||
id: number;
|
||||
|
||||
|
||||
|
||||
name: string;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,28 +1,52 @@
|
||||
/// <reference path="api.d.ts" />
|
||||
|
||||
module API.Client {
|
||||
namespace API.Client {
|
||||
'use strict';
|
||||
|
||||
export class User {
|
||||
|
||||
|
||||
|
||||
export interface User {
|
||||
|
||||
|
||||
|
||||
id: number;
|
||||
|
||||
|
||||
|
||||
username: string;
|
||||
|
||||
|
||||
|
||||
firstName: string;
|
||||
|
||||
|
||||
|
||||
lastName: string;
|
||||
|
||||
|
||||
|
||||
email: string;
|
||||
|
||||
|
||||
|
||||
password: string;
|
||||
|
||||
|
||||
|
||||
phone: string;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* User Status
|
||||
*/
|
||||
|
||||
userStatus: number;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,18 +1,19 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"noImplicitAny": true,
|
||||
"out": "client.js"
|
||||
},
|
||||
"files": [
|
||||
"API/Client/Category.ts",
|
||||
"API/Client/Pet.ts",
|
||||
"API/Client/StoreApi.ts",
|
||||
"API/Client/User.ts",
|
||||
"API/Client/api.d.ts",
|
||||
"API/Client/Order.ts",
|
||||
"API/Client/PetApi.ts",
|
||||
"API/Client/Tag.ts",
|
||||
"API/Client/UserApi.ts",
|
||||
"typings/tsd.d.ts"
|
||||
]
|
||||
"compilerOptions": {
|
||||
"noImplicitAny": true,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"out": "client.js"
|
||||
},
|
||||
"files": [
|
||||
"API/Client/Category.ts",
|
||||
"API/Client/Pet.ts",
|
||||
"API/Client/StoreApi.ts",
|
||||
"API/Client/User.ts",
|
||||
"API/Client/api.d.ts",
|
||||
"API/Client/Order.ts",
|
||||
"API/Client/PetApi.ts",
|
||||
"API/Client/Tag.ts",
|
||||
"API/Client/UserApi.ts",
|
||||
"typings/tsd.d.ts"
|
||||
]
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +1,7 @@
|
||||
import api = require('./api');
|
||||
import fs = require('fs');
|
||||
|
||||
var petApi = new api.PetApi('http://petstore.swagger.io');
|
||||
var petApi = new api.PetApi('http://petstore.swagger.io/');
|
||||
petApi.apiKey = 'special-key';
|
||||
|
||||
var pet = new api.Pet();
|
||||
@ -13,39 +13,39 @@ var exitCode = 0;
|
||||
|
||||
// Test various API calls to the petstore
|
||||
petApi.addPet(pet)
|
||||
.then((res) => {
|
||||
var newPet = <api.Pet>(<any>res.response).body;
|
||||
petId = (<any>res.response).body.id;
|
||||
console.log(`Created pet with ID ${petId}`);
|
||||
newPet.status = api.Pet.StatusEnum.available;
|
||||
return petApi.updatePet(newPet);
|
||||
})
|
||||
.then((res) => {
|
||||
console.log('Updated pet using POST body');
|
||||
return petApi.updatePetWithForm(petId, undefined, "pending");
|
||||
})
|
||||
.then((res) => {
|
||||
console.log('Updated pet using POST form');
|
||||
return petApi.uploadFile(petId, undefined, fs.createReadStream('sample.png'));
|
||||
})
|
||||
.then((res) => {
|
||||
console.log('Uploaded image');
|
||||
return petApi.getPetById(petId);
|
||||
})
|
||||
.then((res) => {
|
||||
console.log('Got pet by ID: ' + JSON.stringify(res.body));
|
||||
if (res.body.status != api.Pet.StatusEnum.pending) {
|
||||
throw new Error("Unexpected pet status");
|
||||
}
|
||||
})
|
||||
.catch((err:any) => {
|
||||
console.error(err);
|
||||
exitCode = 1;
|
||||
})
|
||||
.finally(() => {
|
||||
return petApi.deletePet(petId);
|
||||
})
|
||||
.then((res) => {
|
||||
console.log('Deleted pet');
|
||||
process.exit(exitCode);
|
||||
});
|
||||
.then((res) => {
|
||||
var newPet = <api.Pet>res.body;
|
||||
petId = newPet.id;
|
||||
console.log(`Created pet with ID ${petId}`);
|
||||
newPet.status = api.Pet.StatusEnum.available;
|
||||
return petApi.updatePet(newPet);
|
||||
})
|
||||
.then((res) => {
|
||||
console.log('Updated pet using POST body');
|
||||
return petApi.updatePetWithForm(petId, undefined, "pending");
|
||||
})
|
||||
.then((res) => {
|
||||
console.log('Updated pet using POST form');
|
||||
return petApi.uploadFile(petId, undefined, fs.createReadStream('sample.png'));
|
||||
})
|
||||
.then((res) => {
|
||||
console.log('Uploaded image');
|
||||
return petApi.getPetById(petId);
|
||||
})
|
||||
.then((res) => {
|
||||
console.log('Got pet by ID: ' + JSON.stringify(res.body));
|
||||
if (res.body.status != api.Pet.StatusEnum.pending) {
|
||||
throw new Error("Unexpected pet status");
|
||||
}
|
||||
})
|
||||
.catch((err: any) => {
|
||||
console.error(err);
|
||||
exitCode = 1;
|
||||
})
|
||||
.finally(() => {
|
||||
return petApi.deletePet(petId);
|
||||
})
|
||||
.then((res) => {
|
||||
console.log('Deleted pet');
|
||||
process.exit(exitCode);
|
||||
});
|
||||
|
@ -2,6 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"noImplicitAny": true,
|
||||
"suppressImplicitAnyIndexErrors": true,
|
||||
"target": "ES5"
|
||||
},
|
||||
"files": [
|
||||
|
Loading…
x
Reference in New Issue
Block a user