forked from loafle/openapi-generator-original
Added comments
This commit is contained in:
parent
5f163da848
commit
64b8505010
@ -10,9 +10,15 @@ import {isCodeInRange} from '../util';
|
||||
import { ApiResponse } from '../models/ApiResponse';
|
||||
import { Pet } from '../models/Pet';
|
||||
|
||||
/**
|
||||
* no description
|
||||
*/
|
||||
export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
||||
// TODO: allow passing of Configuration via Options (=> overwrites config set for this request factory
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
* @param pet Pet object that needs to be added to the store
|
||||
*/
|
||||
public addPet(pet: Pet, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -53,6 +59,11 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
* @param petId Pet id to delete
|
||||
* @param apiKey
|
||||
*/
|
||||
public deletePet(petId: number, apiKey?: string, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -91,6 +102,11 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
* Finds Pets by status
|
||||
* @param status Status values that need to be considered for filter
|
||||
*/
|
||||
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -129,6 +145,11 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
* Finds Pets by tags
|
||||
* @param tags Tags to filter by
|
||||
*/
|
||||
public findPetsByTags(tags: Array<string>, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -167,6 +188,11 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single pet
|
||||
* Find pet by ID
|
||||
* @param petId ID of pet to return
|
||||
*/
|
||||
public getPetById(petId: number, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -203,6 +229,10 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
* @param pet Pet object that needs to be added to the store
|
||||
*/
|
||||
public updatePet(pet: Pet, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -243,6 +273,12 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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: number, name?: string, status?: string, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -291,6 +327,12 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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?: HttpFile, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -341,14 +383,15 @@ export class PetApiRequestFactory extends BaseAPIRequestFactory {
|
||||
|
||||
}
|
||||
|
||||
// TODO: find way to split these two files (both dependent on apitemplatefiles)
|
||||
|
||||
|
||||
|
||||
export class PetApiResponseProcessor {
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public addPet(response: ResponseContext): void {
|
||||
@ -365,7 +408,10 @@ export class PetApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public deletePet(response: ResponseContext): void {
|
||||
@ -382,7 +428,10 @@ export class PetApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public findPetsByStatus(response: ResponseContext): Array<Pet> {
|
||||
@ -406,7 +455,10 @@ export class PetApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public findPetsByTags(response: ResponseContext): Array<Pet> {
|
||||
@ -430,7 +482,10 @@ export class PetApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public getPetById(response: ResponseContext): Pet {
|
||||
@ -457,7 +512,10 @@ export class PetApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public updatePet(response: ResponseContext): void {
|
||||
@ -480,7 +538,10 @@ export class PetApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public updatePetWithForm(response: ResponseContext): void {
|
||||
@ -497,7 +558,10 @@ export class PetApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public uploadFile(response: ResponseContext): ApiResponse {
|
||||
|
@ -9,9 +9,16 @@ import {isCodeInRange} from '../util';
|
||||
|
||||
import { Order } from '../models/Order';
|
||||
|
||||
/**
|
||||
* no description
|
||||
*/
|
||||
export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
||||
// TODO: allow passing of Configuration via Options (=> overwrites config set for this request factory
|
||||
|
||||
/**
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
* Delete purchase order by ID
|
||||
* @param orderId ID of the order that needs to be deleted
|
||||
*/
|
||||
public deleteOrder(orderId: string, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -43,6 +50,10 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a map of status codes to quantities
|
||||
* Returns pet inventories by status
|
||||
*/
|
||||
public getInventory(options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -72,6 +83,11 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
* Find purchase order by ID
|
||||
* @param orderId ID of pet that needs to be fetched
|
||||
*/
|
||||
public getOrderById(orderId: number, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -103,6 +119,10 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Place an order for a pet
|
||||
* @param order order placed for purchasing the pet
|
||||
*/
|
||||
public placeOrder(order: Order, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -140,14 +160,15 @@ export class StoreApiRequestFactory extends BaseAPIRequestFactory {
|
||||
|
||||
}
|
||||
|
||||
// TODO: find way to split these two files (both dependent on apitemplatefiles)
|
||||
|
||||
|
||||
|
||||
export class StoreApiResponseProcessor {
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public deleteOrder(response: ResponseContext): void {
|
||||
@ -167,7 +188,10 @@ export class StoreApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public getInventory(response: ResponseContext): { [key: string]: number; } {
|
||||
@ -188,7 +212,10 @@ export class StoreApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public getOrderById(response: ResponseContext): Order {
|
||||
@ -215,7 +242,10 @@ export class StoreApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public placeOrder(response: ResponseContext): Order {
|
||||
|
@ -9,9 +9,16 @@ import {isCodeInRange} from '../util';
|
||||
|
||||
import { User } from '../models/User';
|
||||
|
||||
/**
|
||||
* no description
|
||||
*/
|
||||
export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
||||
// TODO: allow passing of Configuration via Options (=> overwrites config set for this request factory
|
||||
|
||||
/**
|
||||
* This can only be done by the logged in user.
|
||||
* Create user
|
||||
* @param user Created user object
|
||||
*/
|
||||
public createUser(user: User, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -47,6 +54,10 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param user List of user object
|
||||
*/
|
||||
public createUsersWithArrayInput(user: Array<User>, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -82,6 +93,10 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param user List of user object
|
||||
*/
|
||||
public createUsersWithListInput(user: Array<User>, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -117,6 +132,11 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* This can only be done by the logged in user.
|
||||
* Delete user
|
||||
* @param username The name that needs to be deleted
|
||||
*/
|
||||
public deleteUser(username: string, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -148,6 +168,10 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user by user name
|
||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||
*/
|
||||
public getUserByName(username: string, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -179,6 +203,11 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -221,6 +250,9 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
*/
|
||||
public logoutUser(options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -245,6 +277,12 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
||||
return requestContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* This can only be done by the logged in user.
|
||||
* Updated user
|
||||
* @param username name that need to be deleted
|
||||
* @param user Updated user object
|
||||
*/
|
||||
public updateUser(username: string, user: User, options?: Configuration): RequestContext {
|
||||
let config = options || this.configuration;
|
||||
|
||||
@ -289,14 +327,15 @@ export class UserApiRequestFactory extends BaseAPIRequestFactory {
|
||||
|
||||
}
|
||||
|
||||
// TODO: find way to split these two files (both dependent on apitemplatefiles)
|
||||
|
||||
|
||||
|
||||
export class UserApiResponseProcessor {
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public createUser(response: ResponseContext): void {
|
||||
@ -313,7 +352,10 @@ export class UserApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public createUsersWithArrayInput(response: ResponseContext): void {
|
||||
@ -330,7 +372,10 @@ export class UserApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public createUsersWithListInput(response: ResponseContext): void {
|
||||
@ -347,7 +392,10 @@ export class UserApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public deleteUser(response: ResponseContext): void {
|
||||
@ -367,7 +415,10 @@ export class UserApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public getUserByName(response: ResponseContext): User {
|
||||
@ -394,7 +445,10 @@ export class UserApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public loginUser(response: ResponseContext): string {
|
||||
@ -418,7 +472,10 @@ export class UserApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public logoutUser(response: ResponseContext): void {
|
||||
@ -435,7 +492,10 @@ export class UserApiResponseProcessor {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Unwraps the actual response sent by the server from the response context and deserializes the response content
|
||||
* to the expected objects
|
||||
*
|
||||
* @params response Response returned by the server for a request to
|
||||
* @throws ApiException if the response code was not in [200, 299]
|
||||
*/
|
||||
public updateUser(response: ResponseContext): void {
|
||||
|
@ -1,3 +1,12 @@
|
||||
/**
|
||||
* Represents an error caused by an api call i.e. it has attributes for a HTTP status code
|
||||
* and the returned body object.
|
||||
*
|
||||
* Example
|
||||
* API returns a ErrorMessageObject whenever HTTP status code is not in [200, 299]
|
||||
* => ApiException(404, someErrorMessageObject)
|
||||
*
|
||||
*/
|
||||
export class ApiException<T> extends Error {
|
||||
public constructor(public code: number, public body: T) {
|
||||
super("HTTP-Code: " + code + "\nMessage: " + JSON.stringify(body))
|
||||
|
@ -3,6 +3,10 @@ import {RequestContext} from '../http/http';
|
||||
//@ts-ignore
|
||||
import * as btoa from "btoa";
|
||||
|
||||
/**
|
||||
* Base class for all authentication schemes.
|
||||
*
|
||||
*/
|
||||
export abstract class SecurityAuthentication {
|
||||
|
||||
public constructor(private name: string) {
|
||||
@ -17,10 +21,19 @@ export abstract class SecurityAuthentication {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the authentication scheme to the request context
|
||||
*
|
||||
* @params context the request context which should use this authentication scheme
|
||||
*/
|
||||
public abstract applySecurityAuthentication(context: RequestContext): void;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies no authentication.
|
||||
*
|
||||
*/
|
||||
export class NoAuthentication extends SecurityAuthentication {
|
||||
|
||||
public constructor() {
|
||||
@ -32,12 +45,24 @@ export class NoAuthentication extends SecurityAuthentication {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies an api key to the request context.
|
||||
*
|
||||
*/
|
||||
export class APIKeyAuthentication extends SecurityAuthentication {
|
||||
|
||||
/**
|
||||
* Configures this api key authentication with the necessary properties
|
||||
*
|
||||
* @param authName: name of this authentication scheme as specified in the swagger.json
|
||||
* @param paramName: Parameter name used for the api key
|
||||
* @param keyLocation: Parameter location, either query, header or cookie.
|
||||
* @param apiKey: The api key to be used for every request
|
||||
*/
|
||||
public constructor(authName: string, private paramName: string, private keyLocation: "query" | "header" | "cookie", private apiKey: string) {
|
||||
super(authName);
|
||||
}
|
||||
|
||||
|
||||
public applySecurityAuthentication(context: RequestContext) {
|
||||
if (this.keyLocation === "header") {
|
||||
context.setHeaderParam(this.paramName, this.apiKey);
|
||||
@ -48,10 +73,22 @@ export class APIKeyAuthentication extends SecurityAuthentication {
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO: guarantee that auth was configured properly
|
||||
|
||||
|
||||
/**
|
||||
* Applies basic http authentication to a request.
|
||||
*
|
||||
*/
|
||||
export class HttpBasicAuthentication extends SecurityAuthentication {
|
||||
|
||||
/**
|
||||
* Configures the http authentication with the required details.
|
||||
*
|
||||
*
|
||||
* @param authName name of the authentication scheme as defined in swagger json
|
||||
* @param username username for http basic authentication
|
||||
* @param password password for http basic authentication
|
||||
*/
|
||||
public constructor(authName: string, private username: string, private password: string) {
|
||||
super(authName);
|
||||
}
|
||||
@ -62,6 +99,7 @@ export class HttpBasicAuthentication extends SecurityAuthentication {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: How to handle oauth2 authentication!
|
||||
export class OAuth2Authentication extends SecurityAuthentication {
|
||||
public constructor(authName: string) {
|
||||
super(authName);
|
||||
@ -83,6 +121,10 @@ export type OAuth2Configuration = string;
|
||||
|
||||
export type AuthMethodsConfiguration = { "api_key"?:ApiKeyConfiguration, "petstore_auth"?:OAuth2Configuration, }
|
||||
|
||||
/**
|
||||
* Creates the authentication methods from a swagger description.
|
||||
*
|
||||
*/
|
||||
export function configureAuthMethods(conf: AuthMethodsConfiguration | undefined): AuthMethods {
|
||||
let authMethods: AuthMethods = {
|
||||
}
|
||||
|
@ -4,12 +4,30 @@ import {IsomorphicFetchHttpLibrary} from "./http/isomorphic-fetch";
|
||||
import {ServerConfiguration, server1} from './servers';
|
||||
import {configureAuthMethods, AuthMethods, AuthMethodsConfiguration} from './auth/auth';
|
||||
|
||||
|
||||
/**
|
||||
* Inetrface with which a configuration object can be configured.
|
||||
*
|
||||
*/
|
||||
export interface ConfigurationParameters {
|
||||
/**
|
||||
* Default server to use
|
||||
*/
|
||||
baseServer?: ServerConfiguration<any>;
|
||||
httpApi?: HttpLibrary; // override for fetch implementation
|
||||
/**
|
||||
* HTTP library to use e.g. IsomorphicFetch
|
||||
*/
|
||||
httpApi?: HttpLibrary;
|
||||
/**
|
||||
* The middlewares which will be applied to requests and responses
|
||||
*/
|
||||
middleware?: Middleware[]; // middleware to apply before/after fetch requests
|
||||
/**
|
||||
* configures all middlewares using the promise api instead of observables (which Middleware uses)
|
||||
*/
|
||||
promiseMiddleware?: PromiseMiddleware[];
|
||||
/**
|
||||
* Configuration for the available authentication methods
|
||||
*/
|
||||
authMethods?: AuthMethodsConfiguration
|
||||
}
|
||||
|
||||
@ -20,9 +38,19 @@ export class Configuration {
|
||||
middleware: Middleware[];
|
||||
authMethods: AuthMethods;
|
||||
|
||||
/**
|
||||
* Creates a new configuration object based on the given configuration.
|
||||
* If a property is not included in conf, a default is used:
|
||||
* - baseServer: server1
|
||||
* - httpApi: IsomorphicFetchHttpLibrary
|
||||
* - middleware: []
|
||||
* - promiseMiddleware: []
|
||||
* - authMethods: {}
|
||||
* @param conf particial configuration
|
||||
*/
|
||||
constructor(conf: ConfigurationParameters = {}) {
|
||||
this.baseServer = conf.baseServer !== undefined ? conf.baseServer : server1;
|
||||
this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch?
|
||||
this.httpApi = conf.httpApi || new IsomorphicFetchHttpLibrary(); // TODO: replace with window.fetch if available?
|
||||
this.middleware = conf.middleware || [];
|
||||
this.authMethods = configureAuthMethods(conf.authMethods);
|
||||
if (conf.promiseMiddleware) {
|
||||
|
@ -8,6 +8,9 @@ import { Observable } from 'rxjs';
|
||||
|
||||
export * from './isomorphic-fetch';
|
||||
|
||||
/**
|
||||
* Represents a HTTP Method.
|
||||
*/
|
||||
export enum HttpMethod {
|
||||
GET = "GET",
|
||||
HEAD = "HEAD",
|
||||
@ -19,16 +22,15 @@ export enum HttpMethod {
|
||||
TRACE = "TRACE",
|
||||
PATCH = "PATCH"
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a http file which will be uploaded to a server.
|
||||
*/
|
||||
export interface HttpFile {
|
||||
data: Buffer;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface FormEntry {
|
||||
contentDisposition: string;
|
||||
value: string | Blob;
|
||||
}
|
||||
|
||||
|
||||
export class HttpException extends Error {
|
||||
public constructor(msg: string) {
|
||||
@ -36,24 +38,49 @@ export class HttpException extends Error {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a HTTP request context
|
||||
*
|
||||
*/
|
||||
export class RequestContext {
|
||||
private headers: { [key: string]: string } = {};
|
||||
private body: string | FormData = "";
|
||||
private url: URLParse;
|
||||
|
||||
/**
|
||||
* Creates the request context using a http method and request resource url
|
||||
*
|
||||
* @param url url of the requested resource
|
||||
* @param httpMethod http method
|
||||
*/
|
||||
public constructor(url: string, private httpMethod: HttpMethod) {
|
||||
this.url = URLParse(url, true);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the url set in the constructor including the query string
|
||||
*
|
||||
*/
|
||||
public getUrl(): string {
|
||||
return this.url.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the url set in the constructor with this url.
|
||||
*
|
||||
*/
|
||||
public setUrl(url: string) {
|
||||
this.url = URLParse(url, true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the body of the http request either as a string or FormData
|
||||
* Setting a body on a HTTP GET request is disallowed under HTTP-Spec 1.1. Section
|
||||
* 4.3 and this method throws an HttpException accordingly.
|
||||
*
|
||||
* @param body the body of the request
|
||||
*/
|
||||
public setBody(body: string | FormData) {
|
||||
// HTTP-Spec 1.1 Section 4.3
|
||||
if (this.httpMethod === HttpMethod.GET) {
|
||||
@ -85,6 +112,10 @@ export class RequestContext {
|
||||
this.url.set("query", queryObj);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a cookie with the name and value. NO check for duplicate cookies is performed
|
||||
*
|
||||
*/
|
||||
public addCookie(name: string, value: string): void {
|
||||
if (!this.headers["Cookie"]) {
|
||||
this.headers["Cookie"] = "";
|
||||
|
@ -1,8 +1,27 @@
|
||||
import {RequestContext, ResponseContext} from './http/http';
|
||||
import { Observable, from } from 'rxjs';
|
||||
|
||||
/**
|
||||
* Defines the contract for a middleware intercepting requests before
|
||||
* they are sent (but after the RequestContext was created)
|
||||
* and before the ResponseContext is unwrapped.
|
||||
*
|
||||
*/
|
||||
export interface Middleware {
|
||||
/**
|
||||
* Modifies the request before the request is sent.
|
||||
*
|
||||
* @param context RequestContext of a request which is about to be sent to the server
|
||||
* @returns an observable of the updated request context
|
||||
*
|
||||
*/
|
||||
pre(context: RequestContext): Observable<RequestContext>;
|
||||
/**
|
||||
* Modifies the returned response before it is deserialized.
|
||||
*
|
||||
* @param context ResponseContext of a sent request
|
||||
* @returns an observable of the modified response context
|
||||
*/
|
||||
post(context: ResponseContext): Observable<ResponseContext>;
|
||||
}
|
||||
|
||||
@ -22,7 +41,26 @@ export class PromiseMiddlewareWrapper implements Middleware {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the contract for a middleware intercepting requests before
|
||||
* they are sent (but after the RequestContext was created)
|
||||
* and before the ResponseContext is unwrapped.
|
||||
*
|
||||
*/
|
||||
export interface PromiseMiddleware {
|
||||
/**
|
||||
* Modifies the request before the request is sent.
|
||||
*
|
||||
* @param context RequestContext of a request which is about to be sent to the server
|
||||
* @returns an observable of the updated request context
|
||||
*
|
||||
*/
|
||||
pre(context: RequestContext): Observable<RequestContext>;
|
||||
/**
|
||||
* Modifies the returned response before it is deserialized.
|
||||
*
|
||||
* @param context ResponseContext of a sent request
|
||||
* @returns an observable of the modified response context
|
||||
*/
|
||||
post(context: ResponseContext): Observable<ResponseContext>;
|
||||
}
|
@ -1,6 +1,15 @@
|
||||
/*
|
||||
TODO: LICENSE INFO
|
||||
*/
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
|
@ -1,6 +1,15 @@
|
||||
/*
|
||||
TODO: LICENSE INFO
|
||||
*/
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* A category for a pet
|
||||
|
@ -1,6 +1,15 @@
|
||||
/*
|
||||
TODO: LICENSE INFO
|
||||
*/
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* An order for a pets from the pet store
|
||||
|
@ -1,6 +1,15 @@
|
||||
/*
|
||||
TODO: LICENSE INFO
|
||||
*/
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
import { Category } from './Category';
|
||||
import { Tag } from './Tag';
|
||||
|
||||
|
@ -1,6 +1,15 @@
|
||||
/*
|
||||
TODO: LICENSE INFO
|
||||
*/
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* A tag for a pet
|
||||
|
@ -1,6 +1,15 @@
|
||||
/*
|
||||
TODO: LICENSE INFO
|
||||
*/
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
|
@ -1,10 +1,21 @@
|
||||
import {RequestContext, HttpMethod} from './http/http';
|
||||
|
||||
/**
|
||||
*
|
||||
* Represents the configuration of a server including its
|
||||
* url template and variable configuration based on the url.
|
||||
*
|
||||
*/
|
||||
export class ServerConfiguration<T> {
|
||||
|
||||
public constructor(private url: string, private variableConfiguration: T) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of the variables of this server.
|
||||
*
|
||||
* @param variableConfiguration a partial variable configuration for the variables contained in the url
|
||||
*/
|
||||
public setVariables(variableConfiguration: Partial<T>) {
|
||||
for (const key in variableConfiguration) {
|
||||
const val = variableConfiguration[key]
|
||||
@ -27,7 +38,15 @@ export class ServerConfiguration<T> {
|
||||
}
|
||||
return replacedUrl
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a new request context for this server using the url with variables
|
||||
* replaced with their respective values and the endpoint of the request appended.
|
||||
*
|
||||
* @param endpoint the endpoint to be queried on the server
|
||||
* @param httpMethod httpMethod to be used
|
||||
*
|
||||
*/
|
||||
public makeRequestContext(endpoint: string, httpMethod: HttpMethod): RequestContext {
|
||||
return new RequestContext(this.getUrl() + endpoint, httpMethod);
|
||||
}
|
||||
|
@ -23,6 +23,10 @@ export class ObservablePetApi {
|
||||
this.responseProcessor = responseProcessor || new PetApiResponseProcessor();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
* @param pet Pet object that needs to be added to the store
|
||||
*/
|
||||
public addPet(pet: Pet, options?: Configuration): Observable<void> {
|
||||
const requestContext = this.requestFactory.addPet(pet, options);
|
||||
|
||||
@ -42,6 +46,11 @@ export class ObservablePetApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
* @param petId Pet id to delete
|
||||
* @param apiKey
|
||||
*/
|
||||
public deletePet(petId: number, apiKey?: string, options?: Configuration): Observable<void> {
|
||||
const requestContext = this.requestFactory.deletePet(petId, apiKey, options);
|
||||
|
||||
@ -61,6 +70,11 @@ export class ObservablePetApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
* Finds Pets by status
|
||||
* @param status Status values that need to be considered for filter
|
||||
*/
|
||||
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Observable<Array<Pet>> {
|
||||
const requestContext = this.requestFactory.findPetsByStatus(status, options);
|
||||
|
||||
@ -80,6 +94,11 @@ export class ObservablePetApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
* Finds Pets by tags
|
||||
* @param tags Tags to filter by
|
||||
*/
|
||||
public findPetsByTags(tags: Array<string>, options?: Configuration): Observable<Array<Pet>> {
|
||||
const requestContext = this.requestFactory.findPetsByTags(tags, options);
|
||||
|
||||
@ -99,6 +118,11 @@ export class ObservablePetApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single pet
|
||||
* Find pet by ID
|
||||
* @param petId ID of pet to return
|
||||
*/
|
||||
public getPetById(petId: number, options?: Configuration): Observable<Pet> {
|
||||
const requestContext = this.requestFactory.getPetById(petId, options);
|
||||
|
||||
@ -118,6 +142,10 @@ export class ObservablePetApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
* @param pet Pet object that needs to be added to the store
|
||||
*/
|
||||
public updatePet(pet: Pet, options?: Configuration): Observable<void> {
|
||||
const requestContext = this.requestFactory.updatePet(pet, options);
|
||||
|
||||
@ -137,6 +165,12 @@ export class ObservablePetApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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: number, name?: string, status?: string, options?: Configuration): Observable<void> {
|
||||
const requestContext = this.requestFactory.updatePetWithForm(petId, name, status, options);
|
||||
|
||||
@ -156,6 +190,12 @@ export class ObservablePetApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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?: HttpFile, options?: Configuration): Observable<ApiResponse> {
|
||||
const requestContext = this.requestFactory.uploadFile(petId, additionalMetadata, file, options);
|
||||
|
||||
@ -193,6 +233,11 @@ export class ObservableStoreApi {
|
||||
this.responseProcessor = responseProcessor || new StoreApiResponseProcessor();
|
||||
}
|
||||
|
||||
/**
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
* Delete purchase order by ID
|
||||
* @param orderId ID of the order that needs to be deleted
|
||||
*/
|
||||
public deleteOrder(orderId: string, options?: Configuration): Observable<void> {
|
||||
const requestContext = this.requestFactory.deleteOrder(orderId, options);
|
||||
|
||||
@ -212,6 +257,10 @@ export class ObservableStoreApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a map of status codes to quantities
|
||||
* Returns pet inventories by status
|
||||
*/
|
||||
public getInventory(options?: Configuration): Observable<{ [key: string]: number; }> {
|
||||
const requestContext = this.requestFactory.getInventory(options);
|
||||
|
||||
@ -231,6 +280,11 @@ export class ObservableStoreApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
* Find purchase order by ID
|
||||
* @param orderId ID of pet that needs to be fetched
|
||||
*/
|
||||
public getOrderById(orderId: number, options?: Configuration): Observable<Order> {
|
||||
const requestContext = this.requestFactory.getOrderById(orderId, options);
|
||||
|
||||
@ -250,6 +304,10 @@ export class ObservableStoreApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Place an order for a pet
|
||||
* @param order order placed for purchasing the pet
|
||||
*/
|
||||
public placeOrder(order: Order, options?: Configuration): Observable<Order> {
|
||||
const requestContext = this.requestFactory.placeOrder(order, options);
|
||||
|
||||
@ -287,6 +345,11 @@ export class ObservableUserApi {
|
||||
this.responseProcessor = responseProcessor || new UserApiResponseProcessor();
|
||||
}
|
||||
|
||||
/**
|
||||
* This can only be done by the logged in user.
|
||||
* Create user
|
||||
* @param user Created user object
|
||||
*/
|
||||
public createUser(user: User, options?: Configuration): Observable<void> {
|
||||
const requestContext = this.requestFactory.createUser(user, options);
|
||||
|
||||
@ -306,6 +369,10 @@ export class ObservableUserApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param user List of user object
|
||||
*/
|
||||
public createUsersWithArrayInput(user: Array<User>, options?: Configuration): Observable<void> {
|
||||
const requestContext = this.requestFactory.createUsersWithArrayInput(user, options);
|
||||
|
||||
@ -325,6 +392,10 @@ export class ObservableUserApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param user List of user object
|
||||
*/
|
||||
public createUsersWithListInput(user: Array<User>, options?: Configuration): Observable<void> {
|
||||
const requestContext = this.requestFactory.createUsersWithListInput(user, options);
|
||||
|
||||
@ -344,6 +415,11 @@ export class ObservableUserApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* This can only be done by the logged in user.
|
||||
* Delete user
|
||||
* @param username The name that needs to be deleted
|
||||
*/
|
||||
public deleteUser(username: string, options?: Configuration): Observable<void> {
|
||||
const requestContext = this.requestFactory.deleteUser(username, options);
|
||||
|
||||
@ -363,6 +439,10 @@ export class ObservableUserApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user by user name
|
||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||
*/
|
||||
public getUserByName(username: string, options?: Configuration): Observable<User> {
|
||||
const requestContext = this.requestFactory.getUserByName(username, options);
|
||||
|
||||
@ -382,6 +462,11 @@ export class ObservableUserApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, options?: Configuration): Observable<string> {
|
||||
const requestContext = this.requestFactory.loginUser(username, password, options);
|
||||
|
||||
@ -401,6 +486,9 @@ export class ObservableUserApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
*/
|
||||
public logoutUser(options?: Configuration): Observable<void> {
|
||||
const requestContext = this.requestFactory.logoutUser(options);
|
||||
|
||||
@ -420,6 +508,12 @@ export class ObservableUserApi {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* This can only be done by the logged in user.
|
||||
* Updated user
|
||||
* @param username name that need to be deleted
|
||||
* @param user Updated user object
|
||||
*/
|
||||
public updateUser(username: string, user: User, options?: Configuration): Observable<void> {
|
||||
const requestContext = this.requestFactory.updateUser(username, user, options);
|
||||
|
||||
|
@ -19,41 +19,81 @@ export class PromisePetApi {
|
||||
this.api = new ObservablePetApi(configuration, requestFactory, responseProcessor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
* @param pet Pet object that needs to be added to the store
|
||||
*/
|
||||
public addPet(pet: Pet, options?: Configuration): Promise<void> {
|
||||
const result = this.api.addPet(pet, options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
* @param petId Pet id to delete
|
||||
* @param apiKey
|
||||
*/
|
||||
public deletePet(petId: number, apiKey?: string, options?: Configuration): Promise<void> {
|
||||
const result = this.api.deletePet(petId, apiKey, options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
* Finds Pets by status
|
||||
* @param status Status values that need to be considered for filter
|
||||
*/
|
||||
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, options?: Configuration): Promise<Array<Pet>> {
|
||||
const result = this.api.findPetsByStatus(status, options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
* Finds Pets by tags
|
||||
* @param tags Tags to filter by
|
||||
*/
|
||||
public findPetsByTags(tags: Array<string>, options?: Configuration): Promise<Array<Pet>> {
|
||||
const result = this.api.findPetsByTags(tags, options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single pet
|
||||
* Find pet by ID
|
||||
* @param petId ID of pet to return
|
||||
*/
|
||||
public getPetById(petId: number, options?: Configuration): Promise<Pet> {
|
||||
const result = this.api.getPetById(petId, options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
* @param pet Pet object that needs to be added to the store
|
||||
*/
|
||||
public updatePet(pet: Pet, options?: Configuration): Promise<void> {
|
||||
const result = this.api.updatePet(pet, options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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: number, name?: string, status?: string, options?: Configuration): Promise<void> {
|
||||
const result = this.api.updatePetWithForm(petId, name, status, options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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?: HttpFile, options?: Configuration): Promise<ApiResponse> {
|
||||
const result = this.api.uploadFile(petId, additionalMetadata, file, options);
|
||||
return result.toPromise();
|
||||
@ -75,21 +115,39 @@ export class PromiseStoreApi {
|
||||
this.api = new ObservableStoreApi(configuration, requestFactory, responseProcessor);
|
||||
}
|
||||
|
||||
/**
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
* Delete purchase order by ID
|
||||
* @param orderId ID of the order that needs to be deleted
|
||||
*/
|
||||
public deleteOrder(orderId: string, options?: Configuration): Promise<void> {
|
||||
const result = this.api.deleteOrder(orderId, options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a map of status codes to quantities
|
||||
* Returns pet inventories by status
|
||||
*/
|
||||
public getInventory(options?: Configuration): Promise<{ [key: string]: number; }> {
|
||||
const result = this.api.getInventory(options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
* Find purchase order by ID
|
||||
* @param orderId ID of pet that needs to be fetched
|
||||
*/
|
||||
public getOrderById(orderId: number, options?: Configuration): Promise<Order> {
|
||||
const result = this.api.getOrderById(orderId, options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Place an order for a pet
|
||||
* @param order order placed for purchasing the pet
|
||||
*/
|
||||
public placeOrder(order: Order, options?: Configuration): Promise<Order> {
|
||||
const result = this.api.placeOrder(order, options);
|
||||
return result.toPromise();
|
||||
@ -111,41 +169,77 @@ export class PromiseUserApi {
|
||||
this.api = new ObservableUserApi(configuration, requestFactory, responseProcessor);
|
||||
}
|
||||
|
||||
/**
|
||||
* This can only be done by the logged in user.
|
||||
* Create user
|
||||
* @param user Created user object
|
||||
*/
|
||||
public createUser(user: User, options?: Configuration): Promise<void> {
|
||||
const result = this.api.createUser(user, options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param user List of user object
|
||||
*/
|
||||
public createUsersWithArrayInput(user: Array<User>, options?: Configuration): Promise<void> {
|
||||
const result = this.api.createUsersWithArrayInput(user, options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
* @param user List of user object
|
||||
*/
|
||||
public createUsersWithListInput(user: Array<User>, options?: Configuration): Promise<void> {
|
||||
const result = this.api.createUsersWithListInput(user, options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* This can only be done by the logged in user.
|
||||
* Delete user
|
||||
* @param username The name that needs to be deleted
|
||||
*/
|
||||
public deleteUser(username: string, options?: Configuration): Promise<void> {
|
||||
const result = this.api.deleteUser(username, options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user by user name
|
||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||
*/
|
||||
public getUserByName(username: string, options?: Configuration): Promise<User> {
|
||||
const result = this.api.getUserByName(username, options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, options?: Configuration): Promise<string> {
|
||||
const result = this.api.loginUser(username, password, options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
*/
|
||||
public logoutUser(options?: Configuration): Promise<void> {
|
||||
const result = this.api.logoutUser(options);
|
||||
return result.toPromise();
|
||||
}
|
||||
|
||||
/**
|
||||
* This can only be done by the logged in user.
|
||||
* Updated user
|
||||
* @param username name that need to be deleted
|
||||
* @param user Updated user object
|
||||
*/
|
||||
public updateUser(username: string, user: User, options?: Configuration): Promise<void> {
|
||||
const result = this.api.updateUser(username, user, options);
|
||||
return result.toPromise();
|
||||
|
@ -1,3 +1,11 @@
|
||||
/**
|
||||
* Returns if a specific http code is in a given code range
|
||||
* where the code range is defined as a combination of digits
|
||||
* and "X" (the letter X) with a length of 3
|
||||
*
|
||||
* @param codeRange string with length 3 consisting of digits and "X" (the letter X)
|
||||
* @param code the http status code to be checked against the code range
|
||||
*/
|
||||
export function isCodeInRange(codeRange: string, code: number): boolean {
|
||||
// This is how the default value is encoded in OAG
|
||||
if (codeRange === "0") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user