Openapi analyze

From segmentio/action-destinations · View interactive version

Openapi analyze is an AI agent skill from the GitHub repository segmentio/action-destinations. Analyze an OpenAPI specification and generate a destination implementation plan with action recommendations

How to use this skill

Skill file

OpenAPI Destination Analyzer

This skill analyzes OpenAPI specifications (2.0/3.x) and generates comprehensive implementation plans for Segment action-destinations.

Instructions

Step 1: Gather OpenAPI Specification

Ask the user where their OpenAPI spec is located (URL or file path). If URL, use WebFetch to retrieve it. If file path, use Read to load it.

Validate that the content is a valid OpenAPI/Swagger specification by checking for:

Step 2: Parse OpenAPI Structure

Extract these key sections:

Step 3: Analyze Authentication

Map OpenAPI security schemes to Segment authentication schemes:

OpenAPI → Segment Mapping:

Extract required credential field names and descriptions.

Find Test Endpoint:

Look for authentication test endpoints in paths:

Step 4: Identify Action Candidates

Scan all endpoints in paths and prioritize using these heuristics:

Priority: HIGH

Priority: MEDIUM

Priority: LOW

Batch Support Detection:

For each recommended action, note:

Step 5: Extract Field Mappings

For each action's request body schema, map OpenAPI types to Segment field types:

Type Mapping:

Required Fields:

Default Value Suggestions:

Suggest Segment default paths based on field names:

Step 6: Generate Analysis Document

Create a markdown document at: packages/destination-actions/.claude/openapi-analyses/[api-slug]-analysis.md

The API slug should be derived from the API name (lowercase, hyphens instead of spaces).

IMPORTANT: Follow the Standard Analysis Format defined in .claude/skills/implement-destination/analysis-format.md to ensure compatibility with implement-destination. The format below is the OpenAPI-specific implementation of that standard.

Document Structure:

# OpenAPI Destination Analysis: [API Name]

## Summary

- **API Name:** [from info.title]
- **Version:** [from info.version]
- **Base URL:** [from servers[0].url or host+basePath]
- **Authentication:** [recommended Segment scheme]
- **Analysis Date:** [current date]
- **Analysis Source:** OpenAPI Specification

## Authentication Setup

### Recommended Scheme: [custom|basic|oauth2|oauth-managed]

**OpenAPI Security Scheme:** [name and type from spec]

**Required Settings:**

1. **[fieldName]** (type: [string|password])
   - Description: [from security scheme description]
   - Where to find: [instructions for user]
   - Applied as: [header/query parameter details]

**Test Authentication Endpoint:**

- Endpoint: `GET [endpoint]`
- Purpose: [what it returns]
- Fallback: TODO - Manual identification needed

## Recommended Actions

### Priority: High

#### 1. [Action Name] - [One-line summary]

- **Endpoint:** `[METHOD] [path]`
- **Operation ID:** [operationId]
- **Purpose:** [description from OpenAPI]
- **Segment Event Type:** [track|identify|group]
- **Default Subscription:** `type = "[track|identify|group]"` [and additional filters if applicable]
- **Batch Support:** [Yes/No]
- **Reasoning:** [Why this is high priority]

**Field Mappings:**

| Field Name | Type   | Required | Description   | Suggested Default Path |
| ---------- | ------ | -------- | ------------- | ---------------------- |
| [field]    | [type] | [Yes/No] | [description] | [$.path]               |

**Request Body Schema:**

[Pretty-printed JSON schema from OpenAPI]

Additional Notes:

[Repeat for each high-priority action]

Priority: Medium

[Medium-priority actions with same structure]

Priority: Low

[Low-priority actions with same structure]

Global Settings

[If there are common parameters across actions that should be destination-level settings]

Recommended destination-level settings:

  1. [settingName]

Regional Endpoints

[If multiple servers are detected or regions mentioned]

The API supports multiple regions:

Recommendation: Add a region selector field in authentication.

Rate Limits

[If rate limit information is available in OpenAPI extensions or descriptions]

Implementation Notes

Next Steps

  1. Review the recommended actions above
  2. Shortlist 3-5 actions for initial implementation
  3. Run /implement-destination skill with your selections to generate the destination code
  4. The generated code will be ~70-80% complete with clear TODOs for remaining work

### Step 7: Present Results

After generating the analysis document, show the user:

1. A summary of findings:
   - Authentication method
   - Number of actions found (by priority)
   - Base URL and API name

2. Where the analysis was saved

3. Next steps:
   - Review the analysis document
   - Shortlist actions to implement
   - Run `/implement-destination` to generate code

## Tips

- If the OpenAPI spec is malformed or unclear, ask the user for clarification
- When suggesting default paths, consider both track and identify event structures
- For complex nested schemas, flatten them into dot-notation fields where possible
- If you can't determine a good test authentication endpoint, explicitly mark it as TODO
- Prioritize actions that align with common Segment use cases (tracking events, updating user profiles)
- Look for batch endpoints specifically - they're valuable for high-volume use cases
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.