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

2.0 KiB

Documentation for zapier generator

This generator generates a partial implementation of a zapier integration from an openapi specification.

Why is it partial?

It's a partial integration because you have to put in some code for it to be 100% complete, code that depends only on how your api is structured.

Here there are all the parts you need to complete by yourself:

1) utils/utils.js isSearchAction method

This method has to return either true or false if a method is a zapier search action.

const isSearchAction = (key) => {
    // TODO: custom logic
    return false
}

2) utils/utils.js searchMiddleware method

This method has to return an array of resources (searches must return an array), if you have pagination or you api returns an array inside nested fields, here you have to extract the array.

const searchMiddleware = (action) => {
    // TODO: custom logic
    return action
}

3) authentication.js

This file must be written completely according to your api authentication, you can get it generated automatically by creating the integration on the zapier website and filling the requested data, or you can build it yourself following this guide.

Samples

To get your app made public on zapier you must provide a sample (json example response) for each of your actions, these samples get automatically generated by this generator but you have to have actual response examples in you openapi file.

For example:

CreateUserResponse:
    description: Example response
    content:
        application/json:
            schema:
                $ref: ./models/responses/CreateUserResponse.yaml
                examples:
                    example-1:
                        value:
                        data:
                            id: 12345
                            name: user1