Updating typescript-angular to export api classes (#4589)

* Updating typescript-angular to export api classes

* Fixing tsconfig for typescript-angular test case
This commit is contained in:
Damien Pontifex 2017-01-21 17:02:11 +08:00 committed by wing328
parent 22688f57c0
commit 1f0ecb5180
31 changed files with 880 additions and 947 deletions

View File

@ -3,6 +3,8 @@ package io.swagger.codegen.languages;
import java.io.File; import java.io.File;
import io.swagger.codegen.SupportingFile; import io.swagger.codegen.SupportingFile;
import io.swagger.codegen.CodegenParameter;
import io.swagger.models.properties.Property;
public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCodegen { public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCodegen {
@ -19,7 +21,10 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
@Override @Override
public void processOpts() { public void processOpts() {
super.processOpts(); super.processOpts();
supportingFiles.add(new SupportingFile("api.d.mustache", apiPackage().replace('.', File.separatorChar), "api.d.ts")); supportingFiles.add(new SupportingFile("models.mustache", modelPackage().replace('.', File.separatorChar), "models.ts"));
supportingFiles.add(new SupportingFile("apis.mustache", apiPackage().replace('.', File.separatorChar), "api.ts"));
supportingFiles.add(new SupportingFile("index.mustache", getIndexDirectory(), "index.ts"));
supportingFiles.add(new SupportingFile("api.module.mustache", getIndexDirectory(), "api.module.ts"));
supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh")); supportingFiles.add(new SupportingFile("git_push.sh.mustache", "", "git_push.sh"));
supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore")); supportingFiles.add(new SupportingFile("gitignore", "", ".gitignore"));
@ -29,9 +34,56 @@ public class TypeScriptAngularClientCodegen extends AbstractTypeScriptClientCode
super(); super();
outputFolder = "generated-code/typescript-angular"; outputFolder = "generated-code/typescript-angular";
modelTemplateFiles.put("model.mustache", ".ts"); modelTemplateFiles.put("model.mustache", ".ts");
apiTemplateFiles.put("api.mustache", ".ts"); apiTemplateFiles.put("api.mustache", ".ts");
embeddedTemplateDir = templateDir = "typescript-angular"; embeddedTemplateDir = templateDir = "typescript-angular";
apiPackage = "API.Client"; apiPackage = "api";
modelPackage = "API.Client"; modelPackage = "model";
} }
@Override
public String getSwaggerType(Property p) {
String swaggerType = super.getSwaggerType(p);
if(isLanguagePrimitive(swaggerType) || isLanguageGenericType(swaggerType)) {
return swaggerType;
}
return addModelPrefix(swaggerType);
}
@Override
public void postProcessParameter(CodegenParameter parameter) {
super.postProcessParameter(parameter);
parameter.dataType = addModelPrefix(parameter.dataType);
}
private String getIndexDirectory() {
String indexPackage = modelPackage.substring(0, Math.max(0, modelPackage.lastIndexOf('.')));
return indexPackage.replace('.', File.separatorChar);
}
private String addModelPrefix(String swaggerType) {
String type = null;
if (typeMapping.containsKey(swaggerType)) {
type = typeMapping.get(swaggerType);
} else {
type = swaggerType;
}
if (!isLanguagePrimitive(type) && !isLanguageGenericType(type)) {
type = "models." + swaggerType;
}
return type;
}
private boolean isLanguagePrimitive(String type) {
return languageSpecificPrimitives.contains(type);
}
private boolean isLanguageGenericType(String type) {
for (String genericType: languageGenericTypes) {
if (type.startsWith(genericType + "<")) {
return true;
}
}
return false;
}
} }

View File

@ -1,13 +0,0 @@
{{#models}}
{{#model}}
/// <reference path="{{{classname}}}.ts" />
{{/model}}
{{/models}}
{{#apiInfo}}
{{#apis}}
{{#operations}}
/// <reference path="{{classname}}.ts" />
{{/operations}}
{{/apis}}
{{/apiInfo}}

View File

@ -0,0 +1,13 @@
import * as api from './api/api';
import * as angular from 'angular';
{{#apiInfo}}
const apiModule = angular.module('api', [])
{{#apis}}
{{#operations}}
.service('{{classname}}', api.{{classname}})
{{/operations}}
{{/apis}}
export default apiModule;
{{/apiInfo}}

View File

@ -1,89 +1,85 @@
{{>licenseInfo}} {{>licenseInfo}}
/// <reference path="api.d.ts" /> import * as models from '../model/models';
/* tslint:disable:no-unused-variable member-ordering */ /* tslint:disable:no-unused-variable member-ordering */
{{#operations}} {{#operations}}
namespace {{package}} {
'use strict';
{{#description}} {{#description}}
/** /**
* {{&description}} * {{&description}}
*/ */
{{/description}} {{/description}}
export class {{classname}} { export class {{classname}} {
protected basePath = '{{basePath}}'; protected basePath = '{{basePath}}';
public defaultHeaders : any = {}; public defaultHeaders : any = {};
static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath']; static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath'];
constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) { constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
if (basePath !== undefined) { if (basePath !== undefined) {
this.basePath = basePath; this.basePath = basePath;
}
} }
}
{{#operation}} {{#operation}}
/** /**
* {{summary}} * {{summary}}
* {{notes}} * {{notes}}
{{#allParams}}* @param {{paramName}} {{description}} {{#allParams}}* @param {{paramName}} {{description}}
{{/allParams}}*/ {{/allParams}}*/
public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: any ) : ng.IHttpPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> { public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: any ) : ng.IHttpPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> {
const localVarPath = this.basePath + '{{path}}'{{#pathParams}} const localVarPath = this.basePath + '{{path}}'{{#pathParams}}
.replace('{' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}}; .replace('{' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}};
let queryParameters: any = {}; let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders); let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
{{#hasFormParams}} {{#hasFormParams}}
let formParams: any = {}; let formParams: any = {};
{{/hasFormParams}} {{/hasFormParams}}
{{#allParams}} {{#allParams}}
{{#required}} {{#required}}
// verify required parameter '{{paramName}}' is not null or undefined // verify required parameter '{{paramName}}' is not null or undefined
if ({{paramName}} === null || {{paramName}} === undefined) { if ({{paramName}} === null || {{paramName}} === undefined) {
throw new Error('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.'); throw new Error('Required parameter {{paramName}} was null or undefined when calling {{nickname}}.');
} }
{{/required}} {{/required}}
{{/allParams}} {{/allParams}}
{{#queryParams}} {{#queryParams}}
if ({{paramName}} !== undefined) { if ({{paramName}} !== undefined) {
queryParameters['{{baseName}}'] = {{paramName}}; queryParameters['{{baseName}}'] = {{paramName}};
} }
{{/queryParams}} {{/queryParams}}
{{#headerParams}} {{#headerParams}}
headerParams['{{baseName}}'] = {{paramName}}; headerParams['{{baseName}}'] = {{paramName}};
{{/headerParams}} {{/headerParams}}
{{#hasFormParams}} {{#hasFormParams}}
headerParams['Content-Type'] = 'application/x-www-form-urlencoded'; headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
{{/hasFormParams}} {{/hasFormParams}}
{{#formParams}} {{#formParams}}
formParams['{{baseName}}'] = {{paramName}}; formParams['{{baseName}}'] = {{paramName}};
{{/formParams}} {{/formParams}}
let httpRequestParams: ng.IRequestConfig = { let httpRequestParams: ng.IRequestConfig = {
method: '{{httpMethod}}', method: '{{httpMethod}}',
url: localVarPath, url: localVarPath,
{{#bodyParam}}data: {{paramName}}, {{#bodyParam}}data: {{paramName}},
{{/bodyParam}} {{/bodyParam}}
{{#hasFormParams}}data: this.$httpParamSerializer(formParams), {{#hasFormParams}}data: this.$httpParamSerializer(formParams),
{{/hasFormParams}} {{/hasFormParams}}
params: queryParameters, params: queryParameters,
headers: headerParams headers: headerParams
}; };
if (extraHttpRequestParams) { if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams); httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
} }
{{/operation}}
return this.$http(httpRequestParams);
} }
{{/operation}}
} }
{{/operations}} {{/operations}}

View File

@ -0,0 +1,9 @@
{{#apiInfo}}
{{#apis}}
{{#operations}}
export * from './{{ classname }}';
import { {{ classname }} } from './{{ classname }}';
{{/operations}}
{{/apis}}
export const APIS = [ {{#apis}}{{#operations}}{{ classname }}, {{/operations}}{{/apis}}];
{{/apiInfo}}

View File

@ -0,0 +1,2 @@
export * from './api/api';
export * from './model/models';

View File

@ -1,43 +1,38 @@
{{>licenseInfo}} {{>licenseInfo}}
/// <reference path="api.d.ts" /> import * as models from './models';
namespace {{package}} {
'use strict';
{{#models}} {{#models}}
{{#model}} {{#model}}
{{#description}}
/**
* {{{description}}}
*/
{{/description}}
export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
{{#vars}}
{{#description}} {{#description}}
/** /**
* {{{description}}} * {{{description}}}
*/ */
{{/description}} {{/description}}
export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{ "{{name}}"{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
{{#vars}}
{{#description}}
/**
* {{{description}}}
*/
{{/description}}
"{{name}}"{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{datatype}}}{{/isEnum}};
{{/vars}} {{/vars}}
} }
{{#hasEnums}} {{#hasEnums}}
export namespace {{classname}} { export namespace {{classname}} {
{{#vars}} {{#vars}}
{{#isEnum}} {{#isEnum}}
export enum {{enumName}} { export enum {{enumName}} {
{{#allowableValues}} {{#allowableValues}}
{{#enumVars}} {{#enumVars}}
{{{name}}} = <any> {{{value}}}{{^-last}},{{/-last}} {{{name}}} = <any> {{{value}}}{{^-last}},{{/-last}}
{{/enumVars}} {{/enumVars}}
{{/allowableValues}} {{/allowableValues}}
} }
{{/isEnum}} {{/isEnum}}
{{/vars}} {{/vars}}
} }
{{/hasEnums}} {{/hasEnums}}
{{/model}} {{/model}}
{{/models}} {{/models}}
}

View File

@ -0,0 +1,5 @@
{{#models}}
{{#model}}
export * from './{{{ classname }}}';
{{/model}}
{{/models}}

View File

@ -118,10 +118,10 @@ public class TypeScriptAngularModelTest {
final CodegenProperty property1 = cm.vars.get(0); final CodegenProperty property1 = cm.vars.get(0);
Assert.assertEquals(property1.baseName, "children"); Assert.assertEquals(property1.baseName, "children");
Assert.assertEquals(property1.datatype, "Children"); Assert.assertEquals(property1.datatype, "models.Children");
Assert.assertEquals(property1.name, "children"); Assert.assertEquals(property1.name, "children");
Assert.assertEquals(property1.defaultValue, "null"); Assert.assertEquals(property1.defaultValue, "null");
Assert.assertEquals(property1.baseType, "Children"); Assert.assertEquals(property1.baseType, "models.Children");
Assert.assertFalse(property1.required); Assert.assertFalse(property1.required);
Assert.assertTrue(property1.isNotContainer); Assert.assertTrue(property1.isNotContainer);
} }
@ -142,8 +142,8 @@ public class TypeScriptAngularModelTest {
final CodegenProperty property1 = cm.vars.get(0); final CodegenProperty property1 = cm.vars.get(0);
Assert.assertEquals(property1.baseName, "children"); Assert.assertEquals(property1.baseName, "children");
Assert.assertEquals(property1.complexType, "Children"); Assert.assertEquals(property1.complexType, "models.Children");
Assert.assertEquals(property1.datatype, "Array<Children>"); Assert.assertEquals(property1.datatype, "Array<models.Children>");
Assert.assertEquals(property1.name, "children"); Assert.assertEquals(property1.name, "children");
Assert.assertEquals(property1.baseType, "Array"); Assert.assertEquals(property1.baseType, "Array");
Assert.assertFalse(property1.required); Assert.assertFalse(property1.required);
@ -177,6 +177,6 @@ public class TypeScriptAngularModelTest {
Assert.assertEquals(cm.description, "a map model"); Assert.assertEquals(cm.description, "a map model");
Assert.assertEquals(cm.vars.size(), 0); Assert.assertEquals(cm.vars.size(), 0);
Assert.assertEquals(cm.imports.size(), 1); Assert.assertEquals(cm.imports.size(), 1);
Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1); Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("models.Children")).size(), 1);
} }
} }

View File

@ -1,32 +0,0 @@
/// <reference path="api.d.ts" />
namespace API.Client {
'use strict';
export interface InlineResponse200 {
"tags"?: Array<Tag>;
"id": number;
"category"?: any;
/**
* pet status in the store
*/
"status"?: InlineResponse200.StatusEnum;
"name"?: string;
"photoUrls"?: Array<string>;
}
export namespace InlineResponse200 {
export enum StatusEnum {
available = <any> 'available',
pending = <any> 'pending',
sold = <any> 'sold'
}
}
}

View File

@ -1,11 +0,0 @@
/// <reference path="api.d.ts" />
namespace API.Client {
'use strict';
export interface Model200Response {
"name"?: number;
}
}

View File

@ -1,11 +0,0 @@
/// <reference path="api.d.ts" />
namespace API.Client {
'use strict';
export interface ModelReturn {
"return"?: number;
}
}

View File

@ -1,11 +0,0 @@
/// <reference path="api.d.ts" />
namespace API.Client {
'use strict';
export interface Name {
"name"?: number;
}
}

View File

@ -1,272 +0,0 @@
/**
* 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
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@wordnik.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/// <reference path="api.d.ts" />
/* tslint:disable:no-unused-variable member-ordering */
namespace API.Client {
'use strict';
export class PetApi {
protected basePath = 'http://petstore.swagger.io/v2';
public defaultHeaders : any = {};
static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath'];
constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
if (basePath !== undefined) {
this.basePath = basePath;
}
}
/**
* Add a new pet to the store
*
* @param body Pet object that needs to be added to the store
*/
public addPet (body?: Pet, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/pet';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let httpRequestParams: ng.IRequestConfig = {
method: 'POST',
url: localVarPath,
data: body,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Deletes a pet
*
* @param petId Pet id to delete
* @param apiKey
*/
public deletePet (petId: number, apiKey?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/pet/{petId}'
.replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
// verify required parameter 'petId' is not null or undefined
if (petId === null || petId === undefined) {
throw new Error('Required parameter petId was null or undefined when calling deletePet.');
}
headerParams['api_key'] = apiKey;
let httpRequestParams: ng.IRequestConfig = {
method: 'DELETE',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Finds Pets by status
* 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 ) : ng.IHttpPromise<Array<Pet>> {
const localVarPath = this.basePath + '/pet/findByStatus';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
if (status !== undefined) {
queryParameters['status'] = status;
}
let httpRequestParams: ng.IRequestConfig = {
method: 'GET',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Finds Pets by tags
* 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 ) : ng.IHttpPromise<Array<Pet>> {
const localVarPath = this.basePath + '/pet/findByTags';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
if (tags !== undefined) {
queryParameters['tags'] = tags;
}
let httpRequestParams: ng.IRequestConfig = {
method: 'GET',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* 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
*/
public getPetById (petId: number, extraHttpRequestParams?: any ) : ng.IHttpPromise<Pet> {
const localVarPath = this.basePath + '/pet/{petId}'
.replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
// verify required parameter 'petId' is not null or undefined
if (petId === null || petId === undefined) {
throw new Error('Required parameter petId was null or undefined when calling getPetById.');
}
let httpRequestParams: ng.IRequestConfig = {
method: 'GET',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Update an existing pet
*
* @param body Pet object that needs to be added to the store
*/
public updatePet (body?: Pet, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/pet';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let httpRequestParams: ng.IRequestConfig = {
method: 'PUT',
url: localVarPath,
data: body,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Updates a pet in the store with form data
*
* @param petId ID of pet that needs to be updated
* @param name Updated name of the pet
* @param status Updated status of the pet
*/
public updatePetWithForm (petId: string, name?: string, status?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/pet/{petId}'
.replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let formParams: any = {};
// verify required parameter 'petId' is not null or undefined
if (petId === null || petId === undefined) {
throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.');
}
headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
formParams['name'] = name;
formParams['status'] = status;
let httpRequestParams: ng.IRequestConfig = {
method: 'POST',
url: localVarPath,
data: this.$httpParamSerializer(formParams),
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* uploads an image
*
* @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server
* @param file file to upload
*/
public uploadFile (petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/pet/{petId}/uploadImage'
.replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let formParams: any = {};
// verify required parameter 'petId' is not null or undefined
if (petId === null || petId === undefined) {
throw new Error('Required parameter petId was null or undefined when calling uploadFile.');
}
headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
formParams['additionalMetadata'] = additionalMetadata;
formParams['file'] = file;
let httpRequestParams: ng.IRequestConfig = {
method: 'POST',
url: localVarPath,
data: this.$httpParamSerializer(formParams),
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
}
}

View File

@ -1,11 +0,0 @@
/// <reference path="api.d.ts" />
namespace API.Client {
'use strict';
export interface SpecialModelName {
"$Special[propertyName]"?: number;
}
}

View File

@ -1,135 +0,0 @@
/**
* 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
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@wordnik.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/// <reference path="api.d.ts" />
/* tslint:disable:no-unused-variable member-ordering */
namespace API.Client {
'use strict';
export class StoreApi {
protected basePath = 'http://petstore.swagger.io/v2';
public defaultHeaders : any = {};
static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath'];
constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
if (basePath !== undefined) {
this.basePath = basePath;
}
}
/**
* Delete purchase order by ID
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
* @param orderId ID of the order that needs to be deleted
*/
public deleteOrder (orderId: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/store/order/{orderId}'
.replace('{' + 'orderId' + '}', String(orderId));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
// verify required parameter 'orderId' is not null or undefined
if (orderId === null || orderId === undefined) {
throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.');
}
let httpRequestParams: ng.IRequestConfig = {
method: 'DELETE',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
*/
public getInventory (extraHttpRequestParams?: any ) : ng.IHttpPromise<{ [key: string]: number; }> {
const localVarPath = this.basePath + '/store/inventory';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let httpRequestParams: ng.IRequestConfig = {
method: 'GET',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Find purchase order by ID
* 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 ) : ng.IHttpPromise<Order> {
const localVarPath = this.basePath + '/store/order/{orderId}'
.replace('{' + 'orderId' + '}', String(orderId));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
// verify required parameter 'orderId' is not null or undefined
if (orderId === null || orderId === undefined) {
throw new Error('Required parameter orderId was null or undefined when calling getOrderById.');
}
let httpRequestParams: ng.IRequestConfig = {
method: 'GET',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Place an order for a pet
*
* @param body order placed for purchasing the pet
*/
public placeOrder (body?: Order, extraHttpRequestParams?: any ) : ng.IHttpPromise<Order> {
const localVarPath = this.basePath + '/store/order';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let httpRequestParams: ng.IRequestConfig = {
method: 'POST',
url: localVarPath,
data: body,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
}
}

View File

@ -1,245 +0,0 @@
/**
* 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
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@wordnik.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
/// <reference path="api.d.ts" />
/* tslint:disable:no-unused-variable member-ordering */
namespace API.Client {
'use strict';
export class UserApi {
protected basePath = 'http://petstore.swagger.io/v2';
public defaultHeaders : any = {};
static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath'];
constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
if (basePath !== undefined) {
this.basePath = basePath;
}
}
/**
* Create user
* This can only be done by the logged in user.
* @param body Created user object
*/
public createUser (body?: User, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/user';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let httpRequestParams: ng.IRequestConfig = {
method: 'POST',
url: localVarPath,
data: body,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Creates list of users with given input array
*
* @param body List of user object
*/
public createUsersWithArrayInput (body?: Array<User>, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/user/createWithArray';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let httpRequestParams: ng.IRequestConfig = {
method: 'POST',
url: localVarPath,
data: body,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Creates list of users with given input array
*
* @param body List of user object
*/
public createUsersWithListInput (body?: Array<User>, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/user/createWithList';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let httpRequestParams: ng.IRequestConfig = {
method: 'POST',
url: localVarPath,
data: body,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Delete user
* This can only be done by the logged in user.
* @param username The name that needs to be deleted
*/
public deleteUser (username: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/user/{username}'
.replace('{' + 'username' + '}', String(username));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
// 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 deleteUser.');
}
let httpRequestParams: ng.IRequestConfig = {
method: 'DELETE',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing.
*/
public getUserByName (username: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<User> {
const localVarPath = this.basePath + '/user/{username}'
.replace('{' + 'username' + '}', String(username));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
// 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 getUserByName.');
}
let httpRequestParams: ng.IRequestConfig = {
method: 'GET',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Logs user into the system
*
* @param username The user name for login
* @param password The password for login in clear text
*/
public loginUser (username?: string, password?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<string> {
const localVarPath = this.basePath + '/user/login';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
if (username !== undefined) {
queryParameters['username'] = username;
}
if (password !== undefined) {
queryParameters['password'] = password;
}
let httpRequestParams: ng.IRequestConfig = {
method: 'GET',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Logs out current logged in user session
*
*/
public logoutUser (extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/user/logout';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let httpRequestParams: ng.IRequestConfig = {
method: 'GET',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Updated user
* This can only be done by the logged in user.
* @param username name that need to be deleted
* @param body Updated user object
*/
public updateUser (username: string, body?: User, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/user/{username}'
.replace('{' + 'username' + '}', String(username));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
// 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 updateUser.');
}
let httpRequestParams: ng.IRequestConfig = {
method: 'PUT',
url: localVarPath,
data: body,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
}
}

View File

@ -1,9 +0,0 @@
/// <reference path="Category.ts" />
/// <reference path="Order.ts" />
/// <reference path="Pet.ts" />
/// <reference path="Tag.ts" />
/// <reference path="User.ts" />
/// <reference path="PetApi.ts" />
/// <reference path="StoreApi.ts" />
/// <reference path="UserApi.ts" />

View File

@ -0,0 +1,9 @@
import * as api from './api/api';
import * as angular from 'angular';
const apiModule = angular.module('api', [])
.service('PetApi', api.PetApi)
.service('StoreApi', api.StoreApi)
.service('UserApi', api.UserApi)
export default apiModule;

View File

@ -0,0 +1,268 @@
/**
* 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
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@wordnik.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import * as models from '../model/models';
/* tslint:disable:no-unused-variable member-ordering */
export class PetApi {
protected basePath = 'http://petstore.swagger.io/v2';
public defaultHeaders : any = {};
static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath'];
constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
if (basePath !== undefined) {
this.basePath = basePath;
}
}
/**
* Add a new pet to the store
*
* @param body Pet object that needs to be added to the store
*/
public addPet (body?: models.Pet, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/pet';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let httpRequestParams: ng.IRequestConfig = {
method: 'POST',
url: localVarPath,
data: body,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Deletes a pet
*
* @param petId Pet id to delete
* @param apiKey
*/
public deletePet (petId: number, apiKey?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/pet/{petId}'
.replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
// verify required parameter 'petId' is not null or undefined
if (petId === null || petId === undefined) {
throw new Error('Required parameter petId was null or undefined when calling deletePet.');
}
headerParams['api_key'] = apiKey;
let httpRequestParams: ng.IRequestConfig = {
method: 'DELETE',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Finds Pets by status
* 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 ) : ng.IHttpPromise<Array<models.Pet>> {
const localVarPath = this.basePath + '/pet/findByStatus';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
if (status !== undefined) {
queryParameters['status'] = status;
}
let httpRequestParams: ng.IRequestConfig = {
method: 'GET',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Finds Pets by tags
* 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 ) : ng.IHttpPromise<Array<models.Pet>> {
const localVarPath = this.basePath + '/pet/findByTags';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
if (tags !== undefined) {
queryParameters['tags'] = tags;
}
let httpRequestParams: ng.IRequestConfig = {
method: 'GET',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* 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
*/
public getPetById (petId: number, extraHttpRequestParams?: any ) : ng.IHttpPromise<models.Pet> {
const localVarPath = this.basePath + '/pet/{petId}'
.replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
// verify required parameter 'petId' is not null or undefined
if (petId === null || petId === undefined) {
throw new Error('Required parameter petId was null or undefined when calling getPetById.');
}
let httpRequestParams: ng.IRequestConfig = {
method: 'GET',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Update an existing pet
*
* @param body Pet object that needs to be added to the store
*/
public updatePet (body?: models.Pet, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/pet';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let httpRequestParams: ng.IRequestConfig = {
method: 'PUT',
url: localVarPath,
data: body,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Updates a pet in the store with form data
*
* @param petId ID of pet that needs to be updated
* @param name Updated name of the pet
* @param status Updated status of the pet
*/
public updatePetWithForm (petId: string, name?: string, status?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/pet/{petId}'
.replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let formParams: any = {};
// verify required parameter 'petId' is not null or undefined
if (petId === null || petId === undefined) {
throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.');
}
headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
formParams['name'] = name;
formParams['status'] = status;
let httpRequestParams: ng.IRequestConfig = {
method: 'POST',
url: localVarPath,
data: this.$httpParamSerializer(formParams),
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* uploads an image
*
* @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server
* @param file file to upload
*/
public uploadFile (petId: number, additionalMetadata?: string, file?: any, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/pet/{petId}/uploadImage'
.replace('{' + 'petId' + '}', String(petId));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let formParams: any = {};
// verify required parameter 'petId' is not null or undefined
if (petId === null || petId === undefined) {
throw new Error('Required parameter petId was null or undefined when calling uploadFile.');
}
headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
formParams['additionalMetadata'] = additionalMetadata;
formParams['file'] = file;
let httpRequestParams: ng.IRequestConfig = {
method: 'POST',
url: localVarPath,
data: this.$httpParamSerializer(formParams),
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
}

View File

@ -0,0 +1,131 @@
/**
* 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
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@wordnik.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import * as models from '../model/models';
/* tslint:disable:no-unused-variable member-ordering */
export class StoreApi {
protected basePath = 'http://petstore.swagger.io/v2';
public defaultHeaders : any = {};
static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath'];
constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
if (basePath !== undefined) {
this.basePath = basePath;
}
}
/**
* Delete purchase order by ID
* For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
* @param orderId ID of the order that needs to be deleted
*/
public deleteOrder (orderId: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/store/order/{orderId}'
.replace('{' + 'orderId' + '}', String(orderId));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
// verify required parameter 'orderId' is not null or undefined
if (orderId === null || orderId === undefined) {
throw new Error('Required parameter orderId was null or undefined when calling deleteOrder.');
}
let httpRequestParams: ng.IRequestConfig = {
method: 'DELETE',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
*/
public getInventory (extraHttpRequestParams?: any ) : ng.IHttpPromise<{ [key: string]: number; }> {
const localVarPath = this.basePath + '/store/inventory';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let httpRequestParams: ng.IRequestConfig = {
method: 'GET',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Find purchase order by ID
* 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 ) : ng.IHttpPromise<models.Order> {
const localVarPath = this.basePath + '/store/order/{orderId}'
.replace('{' + 'orderId' + '}', String(orderId));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
// verify required parameter 'orderId' is not null or undefined
if (orderId === null || orderId === undefined) {
throw new Error('Required parameter orderId was null or undefined when calling getOrderById.');
}
let httpRequestParams: ng.IRequestConfig = {
method: 'GET',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Place an order for a pet
*
* @param body order placed for purchasing the pet
*/
public placeOrder (body?: models.Order, extraHttpRequestParams?: any ) : ng.IHttpPromise<models.Order> {
const localVarPath = this.basePath + '/store/order';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let httpRequestParams: ng.IRequestConfig = {
method: 'POST',
url: localVarPath,
data: body,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
}

View File

@ -0,0 +1,241 @@
/**
* 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
*
* OpenAPI spec version: 1.0.0
* Contact: apiteam@wordnik.com
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*/
import * as models from '../model/models';
/* tslint:disable:no-unused-variable member-ordering */
export class UserApi {
protected basePath = 'http://petstore.swagger.io/v2';
public defaultHeaders : any = {};
static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath'];
constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) {
if (basePath !== undefined) {
this.basePath = basePath;
}
}
/**
* Create user
* This can only be done by the logged in user.
* @param body Created user object
*/
public createUser (body?: models.User, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/user';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let httpRequestParams: ng.IRequestConfig = {
method: 'POST',
url: localVarPath,
data: body,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Creates list of users with given input array
*
* @param body List of user object
*/
public createUsersWithArrayInput (body?: Array<models.User>, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/user/createWithArray';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let httpRequestParams: ng.IRequestConfig = {
method: 'POST',
url: localVarPath,
data: body,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Creates list of users with given input array
*
* @param body List of user object
*/
public createUsersWithListInput (body?: Array<models.User>, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/user/createWithList';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let httpRequestParams: ng.IRequestConfig = {
method: 'POST',
url: localVarPath,
data: body,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Delete user
* This can only be done by the logged in user.
* @param username The name that needs to be deleted
*/
public deleteUser (username: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/user/{username}'
.replace('{' + 'username' + '}', String(username));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
// 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 deleteUser.');
}
let httpRequestParams: ng.IRequestConfig = {
method: 'DELETE',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Get user by user name
*
* @param username The name that needs to be fetched. Use user1 for testing.
*/
public getUserByName (username: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<models.User> {
const localVarPath = this.basePath + '/user/{username}'
.replace('{' + 'username' + '}', String(username));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
// 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 getUserByName.');
}
let httpRequestParams: ng.IRequestConfig = {
method: 'GET',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Logs user into the system
*
* @param username The user name for login
* @param password The password for login in clear text
*/
public loginUser (username?: string, password?: string, extraHttpRequestParams?: any ) : ng.IHttpPromise<string> {
const localVarPath = this.basePath + '/user/login';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
if (username !== undefined) {
queryParameters['username'] = username;
}
if (password !== undefined) {
queryParameters['password'] = password;
}
let httpRequestParams: ng.IRequestConfig = {
method: 'GET',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Logs out current logged in user session
*
*/
public logoutUser (extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/user/logout';
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
let httpRequestParams: ng.IRequestConfig = {
method: 'GET',
url: localVarPath,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
/**
* Updated user
* This can only be done by the logged in user.
* @param username name that need to be deleted
* @param body Updated user object
*/
public updateUser (username: string, body?: models.User, extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
const localVarPath = this.basePath + '/user/{username}'
.replace('{' + 'username' + '}', String(username));
let queryParameters: any = {};
let headerParams: any = (<any>Object).assign({}, this.defaultHeaders);
// 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 updateUser.');
}
let httpRequestParams: ng.IRequestConfig = {
method: 'PUT',
url: localVarPath,
data: body,
params: queryParameters,
headers: headerParams
};
if (extraHttpRequestParams) {
httpRequestParams = (<any>Object).assign(httpRequestParams, extraHttpRequestParams);
}
return this.$http(httpRequestParams);
}
}

View File

@ -0,0 +1,7 @@
export * from './PetApi';
import { PetApi } from './PetApi';
export * from './StoreApi';
import { StoreApi } from './StoreApi';
export * from './UserApi';
import { UserApi } from './UserApi';
export const APIS = [ PetApi, StoreApi, UserApi, ];

View File

@ -0,0 +1,2 @@
export * from './api/api';
export * from './model/models';

View File

@ -10,16 +10,10 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
/// <reference path="api.d.ts" /> import * as models from './models';
namespace API.Client {
'use strict';
export interface Category {
"id"?: number;
"name"?: string;
}
export interface Category {
"id"?: number;
"name"?: string;
} }

View File

@ -10,34 +10,24 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
/// <reference path="api.d.ts" /> import * as models from './models';
namespace API.Client { export interface Order {
'use strict'; "id"?: number;
"petId"?: number;
"quantity"?: number;
"shipDate"?: Date;
/**
* Order Status
*/
"status"?: Order.StatusEnum;
"complete"?: boolean;
}
export interface Order { export namespace Order {
"id"?: number; export enum StatusEnum {
Placed = <any> 'placed',
"petId"?: number; Approved = <any> 'approved',
Delivered = <any> 'delivered'
"quantity"?: number;
"shipDate"?: Date;
/**
* Order Status
*/
"status"?: Order.StatusEnum;
"complete"?: boolean;
}
export namespace Order {
export enum StatusEnum {
Placed = <any> 'placed',
Approved = <any> 'approved',
Delivered = <any> 'delivered'
}
} }
} }

View File

@ -10,34 +10,24 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
/// <reference path="api.d.ts" /> import * as models from './models';
namespace API.Client { export interface Pet {
'use strict'; "id"?: number;
"category"?: models.Category;
"name": string;
"photoUrls": Array<string>;
"tags"?: Array<models.Tag>;
/**
* pet status in the store
*/
"status"?: Pet.StatusEnum;
}
export interface Pet { export namespace Pet {
"id"?: number; export enum StatusEnum {
Available = <any> 'available',
"category"?: Category; Pending = <any> 'pending',
Sold = <any> 'sold'
"name": string;
"photoUrls": Array<string>;
"tags"?: Array<Tag>;
/**
* pet status in the store
*/
"status"?: Pet.StatusEnum;
}
export namespace Pet {
export enum StatusEnum {
Available = <any> 'available',
Pending = <any> 'pending',
Sold = <any> 'sold'
}
} }
} }

View File

@ -10,16 +10,10 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
/// <reference path="api.d.ts" /> import * as models from './models';
namespace API.Client {
'use strict';
export interface Tag {
"id"?: number;
"name"?: string;
}
export interface Tag {
"id"?: number;
"name"?: string;
} }

View File

@ -10,31 +10,19 @@
* Do not edit the class manually. * Do not edit the class manually.
*/ */
/// <reference path="api.d.ts" /> import * as models from './models';
namespace API.Client {
'use strict';
export interface User {
"id"?: number;
"username"?: string;
"firstName"?: string;
"lastName"?: string;
"email"?: string;
"password"?: string;
"phone"?: string;
/**
* User Status
*/
"userStatus"?: number;
}
export interface User {
"id"?: number;
"username"?: string;
"firstName"?: string;
"lastName"?: string;
"email"?: string;
"password"?: string;
"phone"?: string;
/**
* User Status
*/
"userStatus"?: number;
} }

View File

@ -0,0 +1,5 @@
export * from './Category';
export * from './Order';
export * from './Pet';
export * from './Tag';
export * from './User';

View File

@ -5,15 +5,7 @@
"out": "client.js" "out": "client.js"
}, },
"files": [ "files": [
"API/Client/Category.ts", "./index.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" "typings/tsd.d.ts"
] ]
} }