mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
3ca7ce6ce6
@ -497,7 +497,7 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
allowableValues.put("enumVars", enumVars);
|
||||
// handle default value for enum, e.g. available => StatusEnum.AVAILABLE
|
||||
if (var.defaultValue != null && !"null".equals(var.defaultValue)) {
|
||||
if (var.defaultValue != null) {
|
||||
String enumName = null;
|
||||
for (Map<String, String> enumVar : enumVars) {
|
||||
if (var.defaultValue.equals(enumVar.get("value"))) {
|
||||
@ -505,10 +505,9 @@ public class JavaClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (enumName == null) {
|
||||
throw new RuntimeException("default value of property \"" + var.baseName + "\" is not in allowed values: " + var.defaultValue);
|
||||
if (enumName != null) {
|
||||
var.defaultValue = var.datatypeWithEnum + "." + enumName;
|
||||
}
|
||||
var.defaultValue = var.datatypeWithEnum + "." + enumName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package {{invokerPackage}}.auth;
|
||||
|
||||
import static java.net.HttpURLConnection.HTTP_UNAUTHORIZED;
|
||||
import static java.net.HttpURLConnection.HTTP_FORBIDDEN;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
@ -85,42 +86,55 @@ public class OAuth implements Interceptor {
|
||||
updateAccessToken(null);
|
||||
}
|
||||
|
||||
// Build the request
|
||||
Builder rb = request.newBuilder();
|
||||
|
||||
String requestAccessToken = new String(getAccessToken());
|
||||
try {
|
||||
oAuthRequest = new OAuthBearerClientRequest(request.urlString())
|
||||
.setAccessToken(requestAccessToken)
|
||||
.buildHeaderMessage();
|
||||
} catch (OAuthSystemException e) {
|
||||
throw new IOException(e);
|
||||
if (getAccessToken() != null) {
|
||||
// Build the request
|
||||
Builder rb = request.newBuilder();
|
||||
|
||||
String requestAccessToken = new String(getAccessToken());
|
||||
try {
|
||||
oAuthRequest = new OAuthBearerClientRequest(request.urlString())
|
||||
.setAccessToken(requestAccessToken)
|
||||
.buildHeaderMessage();
|
||||
} catch (OAuthSystemException e) {
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
||||
for ( Map.Entry<String, String> header : oAuthRequest.getHeaders().entrySet() ) {
|
||||
rb.addHeader(header.getKey(), header.getValue());
|
||||
}
|
||||
rb.url( oAuthRequest.getLocationUri());
|
||||
|
||||
//Execute the request
|
||||
Response response = chain.proceed(rb.build());
|
||||
|
||||
// 401 most likely indicates that access token has expired.
|
||||
// Time to refresh and resend the request
|
||||
if ( response != null && (response.code() == HTTP_UNAUTHORIZED | response.code() == HTTP_FORBIDDEN) ) {
|
||||
if (updateAccessToken(requestAccessToken)) {
|
||||
return intercept( chain );
|
||||
}
|
||||
}
|
||||
return response;
|
||||
} else {
|
||||
return chain.proceed(chain.request());
|
||||
}
|
||||
|
||||
for ( Map.Entry<String, String> header : oAuthRequest.getHeaders().entrySet() ) {
|
||||
rb.addHeader(header.getKey(), header.getValue());
|
||||
}
|
||||
rb.url( oAuthRequest.getLocationUri());
|
||||
|
||||
//Execute the request
|
||||
Response response = chain.proceed(rb.build());
|
||||
|
||||
// 401 most likely indicates that access token has expired.
|
||||
// Time to refresh and resend the request
|
||||
if ( response.code() == HTTP_UNAUTHORIZED ) {
|
||||
updateAccessToken(requestAccessToken);
|
||||
return intercept( chain );
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
public synchronized void updateAccessToken(String requestAccessToken) throws IOException {
|
||||
/*
|
||||
* Returns true if the access token has been updated
|
||||
*/
|
||||
public synchronized boolean updateAccessToken(String requestAccessToken) throws IOException {
|
||||
if (getAccessToken() == null || getAccessToken().equals(requestAccessToken)) {
|
||||
try {
|
||||
OAuthJSONAccessTokenResponse accessTokenResponse = oauthClient.accessToken(this.tokenRequestBuilder.buildBodyMessage());
|
||||
setAccessToken(accessTokenResponse.getAccessToken());
|
||||
if (accessTokenListener != null) {
|
||||
accessTokenListener.notify((BasicOAuthToken) accessTokenResponse.getOAuthToken());
|
||||
if (accessTokenResponse != null && accessTokenResponse.getAccessToken() != null) {
|
||||
setAccessToken(accessTokenResponse.getAccessToken());
|
||||
if (accessTokenListener != null) {
|
||||
accessTokenListener.notify((BasicOAuthToken) accessTokenResponse.getOAuthToken());
|
||||
}
|
||||
return getAccessToken().equals(requestAccessToken);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} catch (OAuthSystemException e) {
|
||||
throw new IOException(e);
|
||||
@ -128,6 +142,7 @@ public class OAuth implements Interceptor {
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public void registerAccessTokenListener(AccessTokenListener accessTokenListener) {
|
||||
|
@ -33,7 +33,12 @@ namespace {{package}} {
|
||||
}
|
||||
|
||||
{{#operation}}
|
||||
|
||||
/**
|
||||
* {{summary}}
|
||||
* {{notes}}
|
||||
{{#allParams}}* @param {{paramName}} {{description}}
|
||||
{{/allParams}}
|
||||
*/
|
||||
public {{nickname}} ({{#allParams}}{{paramName}}{{^required}}?{{/required}}: {{{dataType}}}, {{/allParams}}extraHttpRequestParams?: any ) : ng.IHttpPromise<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}{}{{/returnType}}> {
|
||||
const path = this.basePath + '{{path}}'{{#pathParams}}
|
||||
.replace('{' + '{{baseName}}' + '}', String({{paramName}})){{/pathParams}};
|
||||
|
@ -167,7 +167,12 @@ export class {{classname}} {
|
||||
return <T1&T2>objA;
|
||||
}
|
||||
{{#operation}}
|
||||
|
||||
/**
|
||||
* {{summary}}
|
||||
* {{notes}}
|
||||
{{#allParams}}* @param {{paramName}} {{description}}
|
||||
{{/allParams}}
|
||||
*/
|
||||
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}};
|
||||
|
@ -73,7 +73,7 @@ public class UserApiTest {
|
||||
private User createUser() {
|
||||
User user = new User();
|
||||
user.setId(System.currentTimeMillis());
|
||||
user.setUsername("fred");
|
||||
user.setUsername("fred" + user.getId());
|
||||
user.setFirstName("Fred");
|
||||
user.setLastName("Meyer");
|
||||
user.setEmail("fred@fredmeyer.com");
|
||||
|
@ -73,7 +73,7 @@ public class UserApiTest {
|
||||
private User createUser() {
|
||||
User user = new User();
|
||||
user.setId(System.currentTimeMillis());
|
||||
user.setUsername("fred");
|
||||
user.setUsername("fred" + user.getId());
|
||||
user.setFirstName("Fred");
|
||||
user.setLastName("Meyer");
|
||||
user.setEmail("fred@fredmeyer.com");
|
||||
|
@ -73,7 +73,7 @@ public class UserApiTest {
|
||||
private User createUser() {
|
||||
User user = new User();
|
||||
user.setId(System.currentTimeMillis());
|
||||
user.setUsername("fred");
|
||||
user.setUsername("fred" + user.getId());
|
||||
user.setFirstName("Fred");
|
||||
user.setLastName("Meyer");
|
||||
user.setEmail("fred@fredmeyer.com");
|
||||
|
@ -71,7 +71,7 @@ public class UserApiTest {
|
||||
private User createUser() {
|
||||
User user = new User();
|
||||
user.setId(System.currentTimeMillis());
|
||||
user.setUsername("fred");
|
||||
user.setUsername("fred" + user.getId());
|
||||
user.setFirstName("Fred");
|
||||
user.setLastName("Meyer");
|
||||
user.setEmail("fred@fredmeyer.com");
|
||||
|
@ -11,21 +11,41 @@ import scala.collection.JavaConverters._
|
||||
import scala.beans.BeanProperty
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class UserApiTest extends FlatSpec with Matchers {
|
||||
class UserApiTest extends FlatSpec with Matchers with BeforeAndAfterAll {
|
||||
behavior of "UserApi"
|
||||
val api = new UserApi
|
||||
api.apiInvoker.defaultHeaders += "api_key" -> "special-key"
|
||||
|
||||
// preparation before running a test
|
||||
override def beforeAll() {
|
||||
val user = User(
|
||||
11222,
|
||||
"scala-test-username",
|
||||
"scala-test-first",
|
||||
"scala-test-last",
|
||||
"scala_test@fail.com",
|
||||
"SCALATEST",
|
||||
"408-867-5309",
|
||||
1)
|
||||
|
||||
api.createUser(user)
|
||||
}
|
||||
|
||||
// cleanup after running a test
|
||||
override def afterAll() {
|
||||
api.deleteUser("scala-test-username")
|
||||
}
|
||||
|
||||
it should "fetch a user" in {
|
||||
api.getUserByName("user1") match {
|
||||
api.getUserByName("scala-test-username") match {
|
||||
case Some(user) => {
|
||||
user.id should be(1)
|
||||
user.username should be("user1")
|
||||
user.password should be("XXXXXXXXXXX")
|
||||
user.email should be("email1@test.com")
|
||||
user.firstName should be("first name 1")
|
||||
user.lastName should be("last name 1")
|
||||
user.phone should be("123-456-7890")
|
||||
user.id should be(11222)
|
||||
user.username should be("scala-test-username")
|
||||
user.password should be("SCALATEST")
|
||||
user.email should be("scala_test@fail.com")
|
||||
user.firstName should be("scala-test-first")
|
||||
user.lastName should be("scala-test-last")
|
||||
user.phone should be("408-867-5309")
|
||||
user.userStatus should be(1)
|
||||
}
|
||||
case None =>
|
||||
@ -33,7 +53,7 @@ class UserApiTest extends FlatSpec with Matchers {
|
||||
}
|
||||
|
||||
it should "authenticate a user" in {
|
||||
api.loginUser("user1", "XXXXXXXXXXX") match {
|
||||
api.loginUser("scala-test-username", "SCALATEST") match {
|
||||
case Some(status) => status.startsWith("logged in user session") match {
|
||||
case true => // success!
|
||||
case _ => fail("didn't get expected message " + status)
|
||||
@ -46,28 +66,6 @@ class UserApiTest extends FlatSpec with Matchers {
|
||||
api.logoutUser
|
||||
}
|
||||
|
||||
it should "create a user" in {
|
||||
val user = User(
|
||||
1002,
|
||||
"johnny",
|
||||
"Johnny",
|
||||
"Rocket",
|
||||
"johnny@fail.com",
|
||||
"XXXXXXXXXXX",
|
||||
"408-867-5309",
|
||||
1)
|
||||
|
||||
api.createUser(user)
|
||||
|
||||
api.getUserByName("johnny") match {
|
||||
case Some(user) => {
|
||||
user.id should be(1002)
|
||||
user.username should be("johnny")
|
||||
}
|
||||
case None =>
|
||||
}
|
||||
}
|
||||
|
||||
it should "create 2 users" in {
|
||||
val userArray = (for (i <- (1 to 2)) yield {
|
||||
User(
|
||||
@ -149,4 +147,4 @@ class UserApiTest extends FlatSpec with Matchers {
|
||||
case None =>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,22 @@
|
||||
namespace API.Client {
|
||||
'use strict';
|
||||
|
||||
|
||||
|
||||
|
||||
export interface Category {
|
||||
|
||||
|
||||
|
||||
id?: number;
|
||||
|
||||
|
||||
|
||||
name?: string;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,30 +3,65 @@
|
||||
namespace API.Client {
|
||||
'use strict';
|
||||
|
||||
|
||||
|
||||
|
||||
export interface Order {
|
||||
|
||||
|
||||
|
||||
id?: number;
|
||||
|
||||
|
||||
|
||||
petId?: number;
|
||||
|
||||
|
||||
|
||||
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',
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,30 +3,65 @@
|
||||
namespace API.Client {
|
||||
'use strict';
|
||||
|
||||
|
||||
|
||||
|
||||
export interface Pet {
|
||||
|
||||
|
||||
|
||||
id?: number;
|
||||
|
||||
|
||||
|
||||
category?: Category;
|
||||
|
||||
|
||||
|
||||
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',
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,11 @@
|
||||
|
||||
/* 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 = {};
|
||||
@ -27,11 +29,25 @@ namespace API.Client {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 path = this.basePath + '/pet';
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'PUT',
|
||||
url: path,
|
||||
@ -50,11 +66,25 @@ namespace API.Client {
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 path = this.basePath + '/pet';
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
@ -73,15 +103,30 @@ namespace API.Client {
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by status
|
||||
* Multiple status values can be provided with comma seperated strings
|
||||
* @param status Status values that need to be considered for filter
|
||||
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
@ -99,15 +144,30 @@ namespace API.Client {
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
* Muliple tags can be provided with comma seperated 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 path = this.basePath + '/pet/findByTags';
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (tags !== undefined) {
|
||||
queryParameters['tags'] = tags;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
@ -125,16 +185,31 @@ namespace API.Client {
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find pet by ID
|
||||
* Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
* @param petId ID of pet that needs to be fetched
|
||||
|
||||
*/
|
||||
public getPetById (petId: number, extraHttpRequestParams?: any ) : ng.IHttpPromise<Pet> {
|
||||
const path = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling getPetById');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
@ -152,24 +227,49 @@ namespace API.Client {
|
||||
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 path = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
let 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;
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
@ -188,18 +288,37 @@ namespace API.Client {
|
||||
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 path = this.basePath + '/pet/{petId}'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
// verify required parameter 'petId' is set
|
||||
if (!petId) {
|
||||
throw new Error('Missing required parameter petId when calling deletePet');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
headerParams['api_key'] = apiKey;
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'DELETE',
|
||||
url: path,
|
||||
@ -217,24 +336,49 @@ namespace API.Client {
|
||||
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 path = this.basePath + '/pet/{petId}/uploadImage'
|
||||
.replace('{' + 'petId' + '}', String(petId));
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
let 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;
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
@ -252,5 +396,7 @@ namespace API.Client {
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,11 @@
|
||||
|
||||
/* 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 = {};
|
||||
@ -27,11 +29,22 @@ namespace API.Client {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
* Returns a map of status codes to quantities
|
||||
|
||||
*/
|
||||
public getInventory (extraHttpRequestParams?: any ) : ng.IHttpPromise<{ [key: string]: number; }> {
|
||||
const path = this.basePath + '/store/inventory';
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
@ -49,11 +62,25 @@ namespace API.Client {
|
||||
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 path = this.basePath + '/store/order';
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
@ -72,16 +99,31 @@ namespace API.Client {
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
* For valid response try integer IDs with value <= 5 or > 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 path = this.basePath + '/store/order/{orderId}'
|
||||
.replace('{' + 'orderId' + '}', String(orderId));
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
// verify required parameter 'orderId' is set
|
||||
if (!orderId) {
|
||||
throw new Error('Missing required parameter orderId when calling getOrderById');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
@ -99,16 +141,31 @@ namespace API.Client {
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
* For valid response try integer IDs with value < 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 path = this.basePath + '/store/order/{orderId}'
|
||||
.replace('{' + 'orderId' + '}', String(orderId));
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
// verify required parameter 'orderId' is set
|
||||
if (!orderId) {
|
||||
throw new Error('Missing required parameter orderId when calling deleteOrder');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'DELETE',
|
||||
url: path,
|
||||
@ -125,5 +182,7 @@ namespace API.Client {
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,22 @@
|
||||
namespace API.Client {
|
||||
'use strict';
|
||||
|
||||
|
||||
|
||||
|
||||
export interface Tag {
|
||||
|
||||
|
||||
|
||||
id?: number;
|
||||
|
||||
|
||||
|
||||
name?: string;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -3,26 +3,50 @@
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -2,9 +2,11 @@
|
||||
|
||||
/* 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 = {};
|
||||
@ -27,11 +29,25 @@ namespace API.Client {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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 path = this.basePath + '/user';
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
@ -50,11 +66,25 @@ namespace API.Client {
|
||||
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 path = this.basePath + '/user/createWithArray';
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
@ -73,11 +103,25 @@ namespace API.Client {
|
||||
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 path = this.basePath + '/user/createWithList';
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'POST',
|
||||
url: path,
|
||||
@ -96,19 +140,38 @@ namespace API.Client {
|
||||
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 path = this.basePath + '/user/login';
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if (username !== undefined) {
|
||||
queryParameters['username'] = username;
|
||||
}
|
||||
|
||||
|
||||
if (password !== undefined) {
|
||||
queryParameters['password'] = password;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
@ -126,11 +189,22 @@ namespace API.Client {
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
|
||||
*/
|
||||
public logoutUser (extraHttpRequestParams?: any ) : ng.IHttpPromise<{}> {
|
||||
const path = this.basePath + '/user/logout';
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
@ -148,16 +222,31 @@ namespace API.Client {
|
||||
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 path = this.basePath + '/user/{username}'
|
||||
.replace('{' + 'username' + '}', String(username));
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
// verify required parameter 'username' is set
|
||||
if (!username) {
|
||||
throw new Error('Missing required parameter username when calling getUserByName');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'GET',
|
||||
url: path,
|
||||
@ -175,16 +264,34 @@ namespace API.Client {
|
||||
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 path = this.basePath + '/user/{username}'
|
||||
.replace('{' + 'username' + '}', String(username));
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
// verify required parameter 'username' is set
|
||||
if (!username) {
|
||||
throw new Error('Missing required parameter username when calling updateUser');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'PUT',
|
||||
url: path,
|
||||
@ -203,16 +310,31 @@ namespace API.Client {
|
||||
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 path = this.basePath + '/user/{username}'
|
||||
.replace('{' + 'username' + '}', String(username));
|
||||
|
||||
let queryParameters: any = {};
|
||||
let headerParams: any = this.extendObj({}, this.defaultHeaders);
|
||||
|
||||
|
||||
|
||||
// verify required parameter 'username' is set
|
||||
if (!username) {
|
||||
throw new Error('Missing required parameter username when calling deleteUser');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
let httpRequestParams: any = {
|
||||
method: 'DELETE',
|
||||
url: path,
|
||||
@ -229,5 +351,7 @@ namespace API.Client {
|
||||
|
||||
return this.$http(httpRequestParams);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,37 @@
|
||||
|
||||
|
||||
/// <reference path="User.ts" />
|
||||
|
||||
|
||||
|
||||
/// <reference path="Category.ts" />
|
||||
|
||||
|
||||
|
||||
/// <reference path="Pet.ts" />
|
||||
|
||||
|
||||
|
||||
/// <reference path="Tag.ts" />
|
||||
|
||||
|
||||
|
||||
/// <reference path="Order.ts" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <reference path="UserApi.ts" />
|
||||
/// <reference path="PetApi.ts" />
|
||||
|
||||
|
||||
|
||||
/// <reference path="StoreApi.ts" />
|
||||
|
||||
|
||||
|
||||
/// <reference path="PetApi.ts" />
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user