Emanuele Saccomandi 9baf4988f3
Zapier generator (#15997)
* First version of Zapier Generator

* fixed zapier codegen

* added zapier templates

* added zapier sample

* added zapier doc

* added zapier generator form data management

* added samples generation

* updated docs

* fixed zapier api template

* fixed zapier samples export

* added zapier readme template

* fixed zapier readme template

* added petstore readme

* cleaned zapier generator

* updated samples

* fixed zapier enum label

* cleaned code

* updated samples

* improved zapier search actions

* updated samples

---------

Co-authored-by: Mauro Valota <maurovalota@fattureincloud.it>
Co-authored-by: William Cheng <wing328hk@gmail.com>
2023-07-09 21:52:04 +08:00

32 lines
1.7 KiB
JavaScript

const PetApi = require('../apis/PetApi');
const StoreApi = require('../apis/StoreApi');
const UserApi = require('../apis/UserApi');
const { searchMiddleware, hasSearchRequisites, isSearchAction } = require('../utils/utils');
const actions = {
[PetApi.addPet.key]: PetApi.addPet,
[PetApi.deletePet.key]: PetApi.deletePet,
[PetApi.findPetsByStatus.key]: PetApi.findPetsByStatus,
[PetApi.findPetsByTags.key]: PetApi.findPetsByTags,
[PetApi.getPetById.key]: PetApi.getPetById,
[PetApi.updatePet.key]: PetApi.updatePet,
[PetApi.updatePetWithForm.key]: PetApi.updatePetWithForm,
[PetApi.uploadFile.key]: PetApi.uploadFile,
[StoreApi.deleteOrder.key]: StoreApi.deleteOrder,
[StoreApi.getInventory.key]: StoreApi.getInventory,
[StoreApi.getOrderById.key]: StoreApi.getOrderById,
[StoreApi.placeOrder.key]: StoreApi.placeOrder,
[UserApi.createUser.key]: UserApi.createUser,
[UserApi.createUsersWithArrayInput.key]: UserApi.createUsersWithArrayInput,
[UserApi.createUsersWithListInput.key]: UserApi.createUsersWithListInput,
[UserApi.deleteUser.key]: UserApi.deleteUser,
[UserApi.getUserByName.key]: UserApi.getUserByName,
[UserApi.loginUser.key]: UserApi.loginUser,
[UserApi.logoutUser.key]: UserApi.logoutUser,
[UserApi.updateUser.key]: UserApi.updateUser,
}
module.exports = {
searchActions: () => Object.entries(actions).reduce((actions, [key, value]) => isSearchAction(key) && hasSearchRequisites(value) ? {...actions, [key]: searchMiddleware(value)} : actions, {}),
createActions: () => Object.entries(actions).reduce((actions, [key, value]) => !isSearchAction(key) ? {...actions, [key]: value} : actions, {}),
}