> For the complete documentation index, see [llms.txt](https://cortex-docs.paloaltonetworks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cortex-docs.paloaltonetworks.com/demisto-sdk-development-guide/demisto-sdk-guide/demisto-sdk-commands/openapi-codegen.md).

# openapi-codegen

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.

<details>

<summary>Generate the Integration</summary>

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.

</details>

<details>

<summary>Arguments</summary>

| `-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`.                                                   |

</details>

<details>

<summary>Examples</summary>

The examples below use the [Pet Store Swagger specification](https://petstore.swagger.io/).

`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.

</details>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://cortex-docs.paloaltonetworks.com/demisto-sdk-development-guide/demisto-sdk-guide/demisto-sdk-commands/openapi-codegen.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
