Skip to content

criteo/criteo-api-sdk-generator

Repository files navigation

Generate Java Sources Generate PHP Sources Generate Python Sources Generate Postman Collections

Criteo API - Clients

This project generates code for the client libraries for Criteo's API

In addition it generates Postman API documentation and publishes it to the Criteo's Postman space. If you are a user looking for more information about Criteo API on Postman please check this guide.

Generate the clients

To generate the Java code, run:

./gradlew :generator:java:generateClient

The generated code can be found under generated-sources/java folder.

To generate the Python code, run:

./gradlew :generator:python:generateClient

The generated code can be found under generated-sources/python folder.

To generate the PHP code, run:

./gradlew :generator:php:generateClient

The generated code can be found under generated-sources/php folder.

Modify templates

You can modify the generated code by changing the templates. For example, the authentication token auto refresh feature is implemented in generator/{language}/resources/templates/rest.mustache.

If a template is missing, for example for python sdk, you can copy it from the original repository Python templates.

Build Process

The generation of the clients is wrapped in a buid.gradle file. The specific options for each language are defined in other build.gradle files (python, java and php).

This script uses https://api.criteo.com public API.

A clean step has been added to the build process in order to delete the folder of previous generated code. Otherwise some changes will not be applied by openapi-generator.

Github Actions

Each time a push is done, three separate actions for each of the languages are fired :

  • Generate Java Sources
  • Generate PHP Sources
  • Generate Python Sources

Each of workflows generates output for a respective language.

There is also Generate All Sources action that is runnable on demand from Actions tab.

After running a workflow:

  • artefacts will be generated and available for download.
  • Postman collections will be generated and published.

Postman collections

Postman collections are generated only within Github Actions.

The Postman generation workflow doesn't save artifacts, but instead publishes them directly to the Criteo space on Postman. If you would like to run Postman workflow generation locally you can also use nektos/act to ease automation and testing.

To generate the Postman generation GitHub Action locally make sure Docker is installed and run:

act -W .github/workflows/generate_and_push_postman.yml

Disclaimer

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.