Convert OpenAPI specs
Convert OpenAPI specs to Tracecat Action Templates.
Tracecat has a tool that converts OpenAPI 3.0 specifications into action templates. This utility allows you to quickly generate HTTP actions for any API that has an OpenAPI (formerly Swagger) specification, making integration with external services easier and more consistent.
Support Notice
The generator currently only supports OpenAPI Specification (OAS) 3.0. If you need to generate templates from OpenAPI 2.0 (Swagger) or OAS 3.1 specifications, please reach out to the Tracecat support team via our Discord channel.
Overview
The generator creates a template action for each operation defined in an OpenAPI specification. Each generated action includes:
- Appropriate input schemas based on API parameters
- HTTP request steps with proper configuration
- Documentation links from the OpenAPI spec
- Authentication configuration
Getting Started
To use the OpenAPI to Action Generator, you’ll need:
- An OpenAPI 3.0 specification file (JSON or YAML format)
- Python 3.12 or later
- The Tracecat package installed
Basic Usage
Run the generator script with the following command:
For example:
This will process the OpenAPI specification and generate action template YAML files in the specified output directory.
Configuration
For more advanced control over the generation process, you can provide a configuration file using the --config
parameter:
Configuration Options
The configuration file follows this structure:
Configuration Details
Endpoints Filtering
Use the endpoints
section to control which API endpoints are processed:
include.like
: Glob patterns to include paths (e.g.,/users/*
)include.exact
: Exact paths to include (e.g.,/users/profile
)exclude.like
: Glob patterns to exclude paths (e.g.,/internal/*
)exclude.exact
: Exact paths to exclude (e.g.,/users/admin
)
Definition Overrides
The definition_overrides
section allows you to customize the generated action definitions. The supported fields are:
display_group
: Sets the display group for the action (e.g., “PetStore”)namespace
: Sets the namespace for the action (e.g., “the.pet.store”)author
: Sets the author of the action (e.g., “OpenAPI Generator”)doc_url_prefix
: Sets a prefix for documentation URLs (e.g., “https://petstore.swagger.io/docs”)name
: Overrides the action name (e.g., “delete_pet”)title
: Overrides the action title (e.g., “Deletes a pet”)description
: Overrides the action description (e.g., “HTTP DELETE request to /pet/”)doc_url
: Overrides the documentation URL (e.g., “https://petstore.swagger.io/v2”)deprecated
: Sets a deprecation message or flag (e.g., “This action is deprecated.”)
The generator also supports additional custom fields that will be passed through to the template definition.
Authentication
The auth
section configures authentication for the generated actions:
secrets
: Defines required secrets with name and keysinjection
: Specifies how to inject authentication into requests via headers or query parametersexpects
: Defines expected input fields for authentication
Output Organization
The use_namespace_directories
option controls how the generated files are organized:
- When
true
(default): Creates subdirectories based on the action namespace (e.g.,api/pets/action.yml
) - When
false
: Places all actions directly in the output directory