forked from loafle/openapi-generator-original
Support language N4JS (#15089)
* n4js initial commit * incorporate feedback from user * add tests * fix media type in case of DELETE method * fix media type * some minor fixes * options fix for booleans * small fixes * generated files by ./bin/utils/ensure-up-to-date * remove String::toLowerCase due to de.thetaphi:forbiddenapis * adjust test expectation * fix test expectations * fix test expectation * add note to section 'Languages/Generators' * remove file according to review
This commit is contained in:
113
samples/client/petstore/n4js/api/ApiHelper.n4js
Normal file
113
samples/client/petstore/n4js/api/ApiHelper.n4js
Normal file
@@ -0,0 +1,113 @@
|
||||
|
||||
/**
|
||||
* Implemented by client
|
||||
*/
|
||||
export public interface ~ApiExecuterI {
|
||||
public <R, E> async exec(
|
||||
method: string,
|
||||
path: string,
|
||||
pathParams: ~Object+,
|
||||
queryParams: ~Object+,
|
||||
headerParams: ~Object+,
|
||||
payloadContentType: string,
|
||||
body: any+) : Promise<R, Object|ApiError<E>>;
|
||||
}
|
||||
|
||||
export public interface ~ApiError<T> {
|
||||
public resultBody?: T;
|
||||
}
|
||||
|
||||
export public function checkRequiredParams(apiName: string, params: ~Object+) : void {
|
||||
for (const key of Object.keys(params)) {
|
||||
const arg = params[key];
|
||||
if (arg == null) {
|
||||
throw new Error('Required parameter ' + key + ' was null or undefined when calling ' + apiName + '.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export public function <T> cleanCopyBody(t : T+, ...properties: string) : ~T {
|
||||
const copy : ~T+ = {};
|
||||
for (const prop in properties) {
|
||||
copy[prop] = t.prop;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation of ApiExecuterI
|
||||
*
|
||||
* The following dependencies are necessary:
|
||||
* - n4js-runtime-esnext
|
||||
* - n4js-runtime-es2015
|
||||
* - n4js-runtime-html5
|
||||
*/
|
||||
export public class FetchApiExec implements ApiExecuterI {
|
||||
public apiOrigin: string;
|
||||
const jsonTypes = ["application/json", "application/problem+json"];
|
||||
|
||||
@Override
|
||||
public <R, E> async exec(
|
||||
method: string,
|
||||
path: string,
|
||||
pathParams: ~Object+,
|
||||
queryParams: ~Object+,
|
||||
headerParams: ~Object+,
|
||||
payloadContentType: string,
|
||||
body: any+
|
||||
): Promise<R, Object|ApiError<E>> {
|
||||
|
||||
if (pathParams) {
|
||||
for (const [k, v] of Object.entries(pathParams)) {
|
||||
path = path.replace(`{${k}}`, encodeURIComponent(String(v)));
|
||||
}
|
||||
}
|
||||
const query: string[] = [];
|
||||
if (queryParams) {
|
||||
for (const [k, v] of Object.entries(queryParams)) {
|
||||
query.push(`${k}=${encodeURIComponent(String(v))}`);
|
||||
}
|
||||
}
|
||||
|
||||
let url = `${this.apiOrigin}${path}`;
|
||||
if (query.length) {
|
||||
url += `?${query.join("&")}`;
|
||||
}
|
||||
|
||||
const headers: Object+ = {};
|
||||
if (payloadContentType) {
|
||||
headers["content-type"] = payloadContentType;
|
||||
if (this.constructor.jsonTypes.includes(payloadContentType)) {
|
||||
body = JSON.stringify(body);
|
||||
}
|
||||
}
|
||||
Object.assign(headers, headerParams);
|
||||
|
||||
return await this.<R,E>fetchExec(url, {
|
||||
method,
|
||||
headers,
|
||||
body,
|
||||
});
|
||||
}
|
||||
|
||||
protected <R, E> async fetchExec(url: string, reqInit: RequestInit): Promise<R, Object|ApiError<E>> {
|
||||
const resp = await fetch(url, reqInit);
|
||||
|
||||
if (resp.status !== 204) {
|
||||
const contentType = (resp.headers.get("content-type") || "").split(";")[0];
|
||||
const body = this.constructor.jsonTypes.includes(contentType)
|
||||
? await resp.json()
|
||||
: await resp.text();
|
||||
|
||||
if (!resp.ok) {
|
||||
await this.handleError(resp, body);
|
||||
}
|
||||
return body as R;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected <E> async handleError(resp: Response, body): Promise<undefined, ApiError<E>> {
|
||||
throw {body: body};
|
||||
}
|
||||
}
|
||||
223
samples/client/petstore/n4js/api/PetApi.n4js
Normal file
223
samples/client/petstore/n4js/api/PetApi.n4js
Normal file
@@ -0,0 +1,223 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* The version of the OpenAPI document: 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 { ApiExecuterI, ApiError, checkRequiredParams, cleanCopyBody } from "api/ApiHelper"
|
||||
import { ApiResponse } from 'model/ApiResponse';
|
||||
import { Pet } from 'model/Pet';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary Add a new pet to the store
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param pet Pet object that needs to be added to the store
|
||||
* @response 200 [Pet] successful operation
|
||||
* @response 405 [undefined] Invalid input
|
||||
*/
|
||||
export public async function PetApi__addPet(fe : ApiExecuterI, pet: Pet) : Promise<Pet, Object | ApiError<>> {
|
||||
checkRequiredParams('addPet', { 'pet': pet });
|
||||
|
||||
const _pathParams = { };
|
||||
const _queryParams = { };
|
||||
const _headerParams = { };
|
||||
const _body = cleanCopyBody(pet, 'id', 'category', 'name', 'photoUrls', 'tags', 'status');
|
||||
|
||||
return await fe.<Pet, >exec(
|
||||
'POST', '/v2' + '/pet',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary Deletes a pet
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param petId Pet id to delete
|
||||
* @param apiKey
|
||||
* @response 400 [undefined] Invalid pet value
|
||||
*/
|
||||
export public async function PetApi__deletePet(fe : ApiExecuterI, petId: int, apiKey: string=) : Promise<undefined, Object | ApiError<>> {
|
||||
checkRequiredParams('deletePet', { 'petId': petId, });
|
||||
|
||||
const _pathParams = {
|
||||
'petId': petId };
|
||||
const _queryParams = { };
|
||||
const _headerParams = {
|
||||
'api_key': apiKey };
|
||||
const _body = undefined;
|
||||
|
||||
await fe.exec(
|
||||
'DELETE', '/v2' + '/pet/{petId}',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
* @summary Finds Pets by status
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param status Status values that need to be considered for filter
|
||||
* @response 200 [Pet[]] successful operation
|
||||
* @response 400 [undefined] Invalid status value
|
||||
*/
|
||||
export public async function PetApi__findPetsByStatus(fe : ApiExecuterI, status: "available" | "pending" | "sold"[]) : Promise<Pet[], Object | ApiError<>> {
|
||||
checkRequiredParams('findPetsByStatus', { 'status': status });
|
||||
|
||||
const _pathParams = { };
|
||||
const _queryParams = {
|
||||
'status': status };
|
||||
const _headerParams = { };
|
||||
const _body = undefined;
|
||||
|
||||
return await fe.<Pet[], >exec(
|
||||
'GET', '/v2' + '/pet/findByStatus',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
* @summary Finds Pets by tags
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param tags Tags to filter by
|
||||
* @response 200 [Pet[]] successful operation
|
||||
* @response 400 [undefined] Invalid tag value
|
||||
*/
|
||||
export public async function PetApi__findPetsByTags(fe : ApiExecuterI, tags: string[]) : Promise<Pet[], Object | ApiError<>> {
|
||||
checkRequiredParams('findPetsByTags', { 'tags': tags });
|
||||
|
||||
const _pathParams = { };
|
||||
const _queryParams = {
|
||||
'tags': tags };
|
||||
const _headerParams = { };
|
||||
const _body = undefined;
|
||||
|
||||
return await fe.<Pet[], >exec(
|
||||
'GET', '/v2' + '/pet/findByTags',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single pet
|
||||
* @summary Find pet by ID
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param petId ID of pet to return
|
||||
* @response 200 [Pet] successful operation
|
||||
* @response 400 [undefined] Invalid ID supplied
|
||||
* @response 404 [undefined] Pet not found
|
||||
*/
|
||||
export public async function PetApi__getPetById(fe : ApiExecuterI, petId: int) : Promise<Pet, Object | ApiError<>> {
|
||||
checkRequiredParams('getPetById', { 'petId': petId });
|
||||
|
||||
const _pathParams = {
|
||||
'petId': petId };
|
||||
const _queryParams = { };
|
||||
const _headerParams = { };
|
||||
const _body = undefined;
|
||||
|
||||
return await fe.<Pet, >exec(
|
||||
'GET', '/v2' + '/pet/{petId}',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary Update an existing pet
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param pet Pet object that needs to be added to the store
|
||||
* @response 200 [Pet] successful operation
|
||||
* @response 400 [undefined] Invalid ID supplied
|
||||
* @response 404 [undefined] Pet not found
|
||||
* @response 405 [undefined] Validation exception
|
||||
*/
|
||||
export public async function PetApi__updatePet(fe : ApiExecuterI, pet: Pet) : Promise<Pet, Object | ApiError<>> {
|
||||
checkRequiredParams('updatePet', { 'pet': pet });
|
||||
|
||||
const _pathParams = { };
|
||||
const _queryParams = { };
|
||||
const _headerParams = { };
|
||||
const _body = cleanCopyBody(pet, 'id', 'category', 'name', 'photoUrls', 'tags', 'status');
|
||||
|
||||
return await fe.<Pet, >exec(
|
||||
'PUT', '/v2' + '/pet',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary Updates a pet in the store with form data
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param petId ID of pet that needs to be updated
|
||||
* @param name Updated name of the pet
|
||||
* @param status Updated status of the pet
|
||||
* @response 405 [undefined] Invalid input
|
||||
*/
|
||||
export public async function PetApi__updatePetWithForm(fe : ApiExecuterI, petId: int, name: string=, status: string=) : Promise<undefined, Object | ApiError<>> {
|
||||
checkRequiredParams('updatePetWithForm', { 'petId': petId, });
|
||||
|
||||
const _pathParams = {
|
||||
'petId': petId };
|
||||
const _queryParams = { };
|
||||
const _headerParams = { };
|
||||
const _body = undefined;
|
||||
|
||||
await fe.exec(
|
||||
'POST', '/v2' + '/pet/{petId}',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary uploads an image
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param petId ID of pet to update
|
||||
* @param additionalMetadata Additional data to pass to server
|
||||
* @param file file to upload
|
||||
* @response 200 [ApiResponse] successful operation
|
||||
*/
|
||||
export public async function PetApi__uploadFile(fe : ApiExecuterI, petId: int, additionalMetadata: string=, file: any=) : Promise<ApiResponse, Object> {
|
||||
checkRequiredParams('uploadFile', { 'petId': petId, });
|
||||
|
||||
const _pathParams = {
|
||||
'petId': petId };
|
||||
const _queryParams = { };
|
||||
const _headerParams = { };
|
||||
const _body = undefined;
|
||||
|
||||
return await fe.<ApiResponse, undefined>exec(
|
||||
'POST', '/v2' + '/pet/{petId}/uploadImage',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
115
samples/client/petstore/n4js/api/StoreApi.n4js
Normal file
115
samples/client/petstore/n4js/api/StoreApi.n4js
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* The version of the OpenAPI document: 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 { ApiExecuterI, ApiError, checkRequiredParams, cleanCopyBody } from "api/ApiHelper"
|
||||
import { Order } from 'model/Order';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
* @summary Delete purchase order by ID
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param orderId ID of the order that needs to be deleted
|
||||
* @response 400 [undefined] Invalid ID supplied
|
||||
* @response 404 [undefined] Order not found
|
||||
*/
|
||||
export public async function StoreApi__deleteOrder(fe : ApiExecuterI, orderId: string) : Promise<undefined, Object | ApiError<>> {
|
||||
checkRequiredParams('deleteOrder', { 'orderId': orderId });
|
||||
|
||||
const _pathParams = {
|
||||
'orderId': orderId };
|
||||
const _queryParams = { };
|
||||
const _headerParams = { };
|
||||
const _body = undefined;
|
||||
|
||||
await fe.exec(
|
||||
'DELETE', '/v2' + '/store/order/{orderId}',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a map of status codes to quantities
|
||||
* @summary Returns pet inventories by status
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @response 200 [~Object+] successful operation
|
||||
*/
|
||||
export public async function StoreApi__getInventory(fe : ApiExecuterI, ) : Promise<~Object+, Object> {
|
||||
checkRequiredParams('getInventory', { });
|
||||
|
||||
const _pathParams = { };
|
||||
const _queryParams = { };
|
||||
const _headerParams = { };
|
||||
const _body = undefined;
|
||||
|
||||
return await fe.<~Object+, undefined>exec(
|
||||
'GET', '/v2' + '/store/inventory',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||
* @summary Find purchase order by ID
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param orderId ID of pet that needs to be fetched
|
||||
* @response 200 [Order] successful operation
|
||||
* @response 400 [undefined] Invalid ID supplied
|
||||
* @response 404 [undefined] Order not found
|
||||
*/
|
||||
export public async function StoreApi__getOrderById(fe : ApiExecuterI, orderId: int) : Promise<Order, Object | ApiError<>> {
|
||||
checkRequiredParams('getOrderById', { 'orderId': orderId });
|
||||
|
||||
const _pathParams = {
|
||||
'orderId': orderId };
|
||||
const _queryParams = { };
|
||||
const _headerParams = { };
|
||||
const _body = undefined;
|
||||
|
||||
return await fe.<Order, >exec(
|
||||
'GET', '/v2' + '/store/order/{orderId}',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary Place an order for a pet
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param order order placed for purchasing the pet
|
||||
* @response 200 [Order] successful operation
|
||||
* @response 400 [undefined] Invalid Order
|
||||
*/
|
||||
export public async function StoreApi__placeOrder(fe : ApiExecuterI, order: Order) : Promise<Order, Object | ApiError<>> {
|
||||
checkRequiredParams('placeOrder', { 'order': order });
|
||||
|
||||
const _pathParams = { };
|
||||
const _queryParams = { };
|
||||
const _headerParams = { };
|
||||
const _body = cleanCopyBody(order, 'id', 'petId', 'quantity', 'shipDate', 'status', 'complete');
|
||||
|
||||
return await fe.<Order, >exec(
|
||||
'POST', '/v2' + '/store/order',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
213
samples/client/petstore/n4js/api/UserApi.n4js
Normal file
213
samples/client/petstore/n4js/api/UserApi.n4js
Normal file
@@ -0,0 +1,213 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* The version of the OpenAPI document: 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 { ApiExecuterI, ApiError, checkRequiredParams, cleanCopyBody } from "api/ApiHelper"
|
||||
import { User } from 'model/User';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* This can only be done by the logged in user.
|
||||
* @summary Create user
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param user Created user object
|
||||
* @response 0 [undefined] successful operation
|
||||
*/
|
||||
export public async function UserApi__createUser(fe : ApiExecuterI, user: User) : Promise<undefined, Object> {
|
||||
checkRequiredParams('createUser', { 'user': user });
|
||||
|
||||
const _pathParams = { };
|
||||
const _queryParams = { };
|
||||
const _headerParams = { };
|
||||
const _body = cleanCopyBody(user, 'id', 'username', 'firstName', 'lastName', 'email', 'password', 'phone', 'userStatus');
|
||||
|
||||
await fe.exec(
|
||||
'POST', '/v2' + '/user',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary Creates list of users with given input array
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param user List of user object
|
||||
* @response 0 [undefined] successful operation
|
||||
*/
|
||||
export public async function UserApi__createUsersWithArrayInput(fe : ApiExecuterI, user: User[]) : Promise<undefined, Object> {
|
||||
checkRequiredParams('createUsersWithArrayInput', { 'user': user });
|
||||
|
||||
const _pathParams = { };
|
||||
const _queryParams = { };
|
||||
const _headerParams = { };
|
||||
const _body = user;
|
||||
|
||||
await fe.exec(
|
||||
'POST', '/v2' + '/user/createWithArray',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary Creates list of users with given input array
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param user List of user object
|
||||
* @response 0 [undefined] successful operation
|
||||
*/
|
||||
export public async function UserApi__createUsersWithListInput(fe : ApiExecuterI, user: User[]) : Promise<undefined, Object> {
|
||||
checkRequiredParams('createUsersWithListInput', { 'user': user });
|
||||
|
||||
const _pathParams = { };
|
||||
const _queryParams = { };
|
||||
const _headerParams = { };
|
||||
const _body = user;
|
||||
|
||||
await fe.exec(
|
||||
'POST', '/v2' + '/user/createWithList',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This can only be done by the logged in user.
|
||||
* @summary Delete user
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param username The name that needs to be deleted
|
||||
* @response 400 [undefined] Invalid username supplied
|
||||
* @response 404 [undefined] User not found
|
||||
*/
|
||||
export public async function UserApi__deleteUser(fe : ApiExecuterI, username: string) : Promise<undefined, Object | ApiError<>> {
|
||||
checkRequiredParams('deleteUser', { 'username': username });
|
||||
|
||||
const _pathParams = {
|
||||
'username': username };
|
||||
const _queryParams = { };
|
||||
const _headerParams = { };
|
||||
const _body = undefined;
|
||||
|
||||
await fe.exec(
|
||||
'DELETE', '/v2' + '/user/{username}',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary Get user by user name
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||
* @response 200 [User] successful operation
|
||||
* @response 400 [undefined] Invalid username supplied
|
||||
* @response 404 [undefined] User not found
|
||||
*/
|
||||
export public async function UserApi__getUserByName(fe : ApiExecuterI, username: string) : Promise<User, Object | ApiError<>> {
|
||||
checkRequiredParams('getUserByName', { 'username': username });
|
||||
|
||||
const _pathParams = {
|
||||
'username': username };
|
||||
const _queryParams = { };
|
||||
const _headerParams = { };
|
||||
const _body = undefined;
|
||||
|
||||
return await fe.<User, >exec(
|
||||
'GET', '/v2' + '/user/{username}',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary Logs user into the system
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param username The user name for login
|
||||
* @param password The password for login in clear text
|
||||
* @response 200 [string] successful operation
|
||||
* @response 400 [undefined] Invalid username/password supplied
|
||||
*/
|
||||
export public async function UserApi__loginUser(fe : ApiExecuterI, username: string, password: string) : Promise<string, Object | ApiError<>> {
|
||||
checkRequiredParams('loginUser', { 'username': username, 'password': password });
|
||||
|
||||
const _pathParams = { };
|
||||
const _queryParams = {
|
||||
'username': username,
|
||||
'password': password };
|
||||
const _headerParams = { };
|
||||
const _body = undefined;
|
||||
|
||||
return await fe.<string, >exec(
|
||||
'GET', '/v2' + '/user/login',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @summary Logs out current logged in user session
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @response 0 [undefined] successful operation
|
||||
*/
|
||||
export public async function UserApi__logoutUser(fe : ApiExecuterI, ) : Promise<undefined, Object> {
|
||||
checkRequiredParams('logoutUser', { });
|
||||
|
||||
const _pathParams = { };
|
||||
const _queryParams = { };
|
||||
const _headerParams = { };
|
||||
const _body = undefined;
|
||||
|
||||
await fe.exec(
|
||||
'GET', '/v2' + '/user/logout',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* This can only be done by the logged in user.
|
||||
* @summary Updated user
|
||||
* @param fe Callback interface that runs the fetch query
|
||||
* @param username name that need to be deleted
|
||||
* @param user Updated user object
|
||||
* @response 400 [undefined] Invalid user supplied
|
||||
* @response 404 [undefined] User not found
|
||||
*/
|
||||
export public async function UserApi__updateUser(fe : ApiExecuterI, username: string, user: User) : Promise<undefined, Object | ApiError<>> {
|
||||
checkRequiredParams('updateUser', { 'username': username, 'user': user });
|
||||
|
||||
const _pathParams = {
|
||||
'username': username };
|
||||
const _queryParams = { };
|
||||
const _headerParams = { };
|
||||
const _body = cleanCopyBody(user, 'id', 'username', 'firstName', 'lastName', 'email', 'password', 'phone', 'userStatus');
|
||||
|
||||
await fe.exec(
|
||||
'PUT', '/v2' + '/user/{username}',
|
||||
_pathParams, _queryParams, _headerParams,
|
||||
undefined,
|
||||
_body
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user