The openapi-codegen command generates an integration package (YAML and Python files).
You can generate a Cortex XSIAM or Cortex XSOAR integration package (YAML and Python files) with a dedicated tool in the Demisto SDK. The integration can be used immediately after after you generate it.
To generate an integration package, you need to have an OpenAPI (Swagger) specification file (v2.0 is recommended) in JSON format and the Demisto SDK.
Install the Demisto SDK.
pip3 install demisto-sdk
Run the
demisto-sdk openapi-codegen
command.Refer to the command instructions and examples below for more details.
Follow the instructions to generate the integration files.
Use
demisto-sdk unify
to create a unified integration YAML file from the integration files.Use
demisto-sdk upload
to upload the generated integration to .Set up a tenant and run the integration commands.
Argument | Description |
---|---|
-h, --help | Shows command help. |
-i, --input_file | The Swagger file to load in JSON format. |
-cf, --config_file | The integration configuration file. The file is created in the first run of the command. |
-n, --base_name | The base filename to use for the generated files. |
-o, --output_dir | Directory to store the output in (default is current working directory). |
-pr, --command_prefix | Adds a prefix to each command in the code. |
-c, --context_path | Context output path. |
-u, --unique_keys | Comma-separated unique keys to use in context paths (case sensitive). |
-r, --root_objects | Comma-separated JSON root objects to use in command outputs (case sensitive). |
-f, --fix_code | Fixes the Python code using autopep8. |
-a, --use_default | Use the automatically generated integration configuration (skip the second run). |
-clt, --console-log-threshold | Minimum logging threshold for the console logger. Default value is |
-flt, --file-log-threshold | Minimum logging threshold for the file logger. Default value is |
-lp, --log-file-path | The path to the log file. Default path is |
The examples below use the Pet Store Swagger specification.
demisto-sdk openapi-codegen -i pet_swagger.json -n PetStore -o PetStoreIntegration -u "id" -r "Pet"
This creates an integration configuration for the PetStore swagger file in the PetStoreIntegration
directory. It uses id
to identify unique properties in outputs and Pet
to identify root objects in the outputs. That configuration can be modified and is used in a second run of the command.
demisto-sdk openapi-codegen -i pet_swagger.json -n PetStore -o PetStoreIntegration -u "id" -r "Pet" -cf "PetStoreIntegration/PetStore.json"
This creates the integration for the PetStore swagger file using the configuration file located in PetStoreIntegration/PetStore.json
.
demisto-sdk openapi-codegen -i pet_swagger.json -n PetStore -o PetStoreIntegration -u "id" -r "Pet" -a
This creates the integration for the PetStore swagger file using the generated configuration file, thus skipping the second run of the command.