For the complete documentation index, see llms.txt. This page is also available as Markdown.
Cortex XSOAR 6.xCortex XSOAR 8 (SaaS)Cortex XSOAR 8.x (On-premCortex XSIAM

openapi-codegen

Generate Cortex XSOAR integration code and configuration from an OpenAPI specification.

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.

Generate the Integration

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.

  1. Install the Demisto SDK.

    pip3 install demisto-sdk

  2. Run the demisto-sdk openapi-codegen command.

    Refer to the command instructions and examples below for more details.

  3. Follow the instructions to generate the integration files.

  4. Use demisto-sdk unify to create a unified integration YAML file from the integration files.

  5. Use demisto-sdk upload to upload the generated integration to .

  6. Set up a tenant and run the integration commands.

Arguments

-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 INFO. Possible values are DEBUG, INFO, WARNING, ERROR.

-flt, --file-log-threshold

Minimum logging threshold for the file logger. Default value is DEBUG. Possible values are DEBUG, INFO, WARNING, ERROR.

-lp, --log-file-path

The path to the log file. Default path is <CONTENT_PATH>/demisto_sdk_debug.log.

Examples

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.

Last updated

Was this helpful?