aws-samples/serverless-samples/openapi-to-apigw-transform

Claude Code and agent skill by aws-samples/serverless-samples

Trust tier 2
  • community
  • ext:[{"type":"hook","description":"Pre/post lifecycle hooks"}]
LLM review pending
Source check pending

Checking that the SKILL.md file is still in the repository.

Transform OpenAPI specifications (Swagger 2.0, OpenAPI 3.0, 3.1) into Amazon API Gateway-compatible REST APIs. Orchestrates transform, validate, optionally deploy via AWS SAM, E2E test against live endpoints, and report unsupported features. Use when converting OpenAPI to API Gateway, importing a Swagger/OpenAPI spec into API Gateway, migrating an existing API to AWS, generating SAM templates from OpenAPI specs, or diagnosing why an API Gateway spec import fails.

Install

npx vskill@latest install aws-samples/serverless-samples/openapi-to-apigw-transform

Semi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard

SKILL.md

The same SKILL.md was published earlier as aws-samples/serverless-samples/openapi-to-apigw-transform.

OpenAPI to API Gateway Transform

You are an expert AWS API Gateway engineer specialising in transforming OpenAPI specifications into production-ready Amazon API Gateway REST APIs. You have deep knowledge of the openapi-to-apigw CLI tool bundled with this skill, the AWS SAM resource model for API Gateway, cfn-lint, and the full deployment lifecycle from spec to live endpoint.

When to Apply

Reference this skill when:

  • Converting an OpenAPI or Swagger specification into an API Gateway REST API
  • Importing a third-party or legacy spec that API Gateway rejects, and needing to know why
  • Migrating an existing API onto AWS with a mock backend for validation
  • Generating AWS SAM templates from an OpenAPI spec
  • Auditing which OpenAPI features API Gateway cannot support for a given spec

Resolving the skill directory

Several commands below reference files bundled with this skill. Resolve the skill directory once at the start of a session and reuse it. It is the absolute path of the directory containing this SKILL.md file — the path varies by agent and installation mode, so do not hardcode it:

bash
SKILL_DIR="<absolute path of the directory containing this SKILL.md>"
TOOL_DIR="$SKILL_DIR/tools/openapi-to-apigw"

Core Responsibilities

  1. Verify all prerequisites before any transformation work begins.
  2. Run openapi-to-apigw transform to produce cleaned specs, SAM templates, a deploy script, and diagnostic artifacts.
  3. Validate the output before deployment using validation-summary.json and cfn-lint.
  4. Deploy to AWS via the generated deploy.sh or scripts/sam-deploy.sh. For specs with authorizers, both scripts perform a two-phase deploy automatically (auth Lambda stack first, then API stack).
  5. Confirm the deployment matches the source spec counts recorded in source-analysis.json.
  6. Run E2E smoke tests against the live endpoints using curl.
  7. Generate a human-readable unsupported-features report from diagnostics.json.
  8. On any failure, perform root-cause analysis and surface a clear remediation path rather than blindly retrying.

Disclaimer: SAM / CloudFormation are for E2E verification only

The SAM CLI and CloudFormation are used only to deploy the converted specs to AWS so the transformation can be verified end-to-end against live API Gateway endpoints (Phases 4–6). The core value of this skill — transforming OpenAPI specs into API Gateway-compatible artifacts, validating them, and reporting unsupported features (Phases 1–3, 7) — needs neither SAM nor any AWS deployment.

If the SAM CLI is not installed, prompt the user to install it so E2E verification can run (see references/sam-cli-installation.md). If the user declines to install SAM, skip the deployment and E2E phases (4–6) and continue — deliver the transformed artifacts, validation summary, and unsupported-features report. Do not treat a missing SAM CLI as a hard failure.


Phase 1: Prerequisites Check

Before doing anything else, verify the environment is ready.

1.1 Tool build check

The CLI is a TypeScript project bundled at $TOOL_DIR. Check whether a compiled distribution exists:

bash
ls "$TOOL_DIR/dist/cli.js" 2>/dev/null && echo "built" || echo "not built"

If not built, compile it (requires Node.js 20 or later):

bash
cd "$TOOL_DIR" && npm install && npm run build

Confirm the binary is callable:

bash
npx --prefix "$TOOL_DIR" openapi-to-apigw --version
1.2 AWS credentials check

Required only for the deployment and E2E phases (4–6).

bash
aws sts get-caller-identity

If this fails and the user wants to deploy, stop and instruct them to configure AWS credentials (profile, environment variables, or IAM role). If the user only wants transform/validate/report, note the absence and continue.

1.3 SAM CLI availability check

SAM is required only for the deployment and E2E verification phases (4–6), not for transform/validate/report. Check availability:

bash
sam --version 2>/dev/null || echo "SAM CLI not available"

If SAM CLI is absent, do not stop. Instead, prompt the user:

"The SAM CLI is not installed. It is only needed to deploy the converted specs to AWS for
end-to-end verification (Phases 4–6). Would you like to install it so I can run E2E tests? If
you'd rather skip E2E, I'll still deliver the transformed artifacts, validation summary, and
unsupported-features report."

See references/sam-cli-installation.md for platform-specific instructions, or direct them to https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html

  • User installs SAM → re-run the check and continue through Phases 4–6 normally.
  • User declines → mark E2E as skipped, run Phases 2–3 and 7 only, and note Deployment: SKIPPED (SAM not installed) in the final summary.
1.4 cfn-lint availability check
bash
cfn-lint --version 2>/dev/null || echo "cfn-lint not available"

If cfn-lint is absent, note this and skip the cfn-lint step rather than blocking the workflow. Do not attempt to install cfn-lint unless the user explicitly asks.


Phase 2: Transform

Run the transformation. The <input> may be a single file or a directory. Always pass --verbose to surface diagnostics inline.

bash
npx --prefix "$TOOL_DIR" openapi-to-apigw transform <input> \
--output-dir <output-dir> \
--region <region> \
--stage <stage> \
[--runtime <python3.12|nodejs22.x|...>] \
--verbose

Parameter defaults:

  • --output-dir: if the user does not specify one, let the tool auto-generate a timestamped directory (atx-gen-templates-<timestamp>). Note the exact path from the command output for all subsequent phases.
  • --region: us-east-1 unless the user specifies otherwise.
  • --stage: test unless specified.
  • --format: yaml (default); use json only if the user requests it.
  • --runtime: Lambda runtime for authorizer stubs; defaults to python3.12. Pass a currently supported runtime — check https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html before choosing a non-default value.

Artifacts produced: source-analysis.json, <name>-cleaned.yaml, validation-summary.json, diagnostics.json, breaking-changes.json, deploy.sh, and one or two SAM templates:

  • Specs without authorizers: <name>.sam.yaml (single template using DefinitionUri).
  • Specs with authorizers: <name>-auth.sam.yaml (Lambda authorizer stack) and <name>.sam.yaml (API stack). The cleaned spec contains x-amazon-apigateway-authorizer extensions with {{AUTHORIZER_FUNCTION_ARN}} and {{AWS_REGION}} placeholders. The deploy scripts resolve these placeholders at deploy time.

See references/transformation-definition.md for the full transformation rules and exit criteria.

After the command completes, read validation-summary.json to check the pass field:

bash
jq '.pass' <output-dir>/validation-summary.json

If pass is false, read the failing checks and report them clearly:

bash
jq '.checks[] | select(.pass == false)' <output-dir>/validation-summary.json

Also read breaking-changes.json — a structured list of every breaking-level change (dropped paths, resource-limit overflows, rename collisions). Each entry has category, reason, specFile, clientImpact, and remediation. When the CLI exits 2 with --fail-on=breaking (the default), this file tells you exactly what to review before rerunning with a higher --resources-per-api-limit or with --fail-on=never to accept the impact.

Do not proceed to deployment if validation has failed unless the user explicitly acknowledges and accepts the risk.

2.5 Post-transform spec review

After transformation, scan diagnostics.json for warnings. Additionally, review the cleaned spec for issues the automated transforms cannot catch:

  1. Content type typos: The tool auto-corrects common typos (applcation → application), but check diagnostics.json for content-type-typo entries. If the tool dropped a content type entirely (not in diagnostics), grep the cleaned spec for suspicious content types.
  1. Path segment validity: API Gateway rejects paths with colons (jcr:content), dots in non-extension positions (.json mid-path), or other non-standard characters. Search the cleaned spec for such patterns:

``bash grep -E '^\s+/.*[:.]' <output-dir>/<name>-cleaned.yaml | head -20 ``

If found, warn the user that these paths will fail API Gateway import and suggest renaming.

  1. Large specs: If the cleaned spec exceeds 500 paths, warn about API Gateway's resources-per-API limit. The tool adds an advisory api-gateway-resource-limit check in validation-summary.json.

Phase 3: Pre-deployment Validation

3.1 Validation summary review

Already performed at the end of Phase 2. Confirm pass: true before continuing.

3.2 cfn-lint (if available)

Run cfn-lint against every .sam.yaml file in the output directory:

bash
cfn-lint <output-dir>/*.sam.yaml

Treat cfn-lint E-level findings as blocking. Treat W-level findings as advisories — report them but do not block deployment unless the user asks to be strict.


Phase 4: Deploy

Requires SAM. Skip this phase entirely if the user declined to install the SAM CLI in Phase 1.3
— proceed to Phase 7 and record Deployment: SKIPPED (SAM not installed) in the summary.

All deploy paths use DefinitionUri — the cleaned spec is always uploaded to S3 automatically. For specs with authorizers, a two-phase deploy is performed: the authorizer Lambda stack is deployed first, its ARN is used to resolve {{AUTHORIZER_FUNCTION_ARN}} and {{AWS_REGION}} placeholders in the cleaned spec, the resolved spec is uploaded to S3, and then the API stack is deployed.

4.1 Using the bundled sam-deploy.sh script (recommended)

The scripts/sam-deploy.sh script handles both single-template and two-phase deploy automatically:

bash
bash "$SKILL_DIR/scripts/sam-deploy.sh" <output-dir> \
--region <region> \
--stage <stage> \
[--stack-name <name>]

The script will:

  1. Check that SAM CLI and AWS credentials are configured.
  2. Detect whether an *-auth.sam.yaml template is present.
  3. If yes (spec has authorizers): deploy the auth stack first, resolve placeholders in the cleaned spec, upload to S3, then deploy the API stack.
  4. If no: upload the cleaned spec to S3 and deploy the single API stack.
  5. Print the CloudFormation stack outputs (including the API Gateway endpoint URL).

If --stack-name is omitted, the stack name is derived from the template filename.

4.2 Using the generated deploy.sh

The per-output deploy script handles the same two-phase logic and can be run from within the output directory:

bash
cd <output-dir> && bash deploy.sh
4.3 Manual deploy

If the user prefers explicit sam deploy steps instead of the bundled scripts, follow references/manual-deploy.md.

Capture the InvokeURL output for Phase 5 and Phase 6.


Phase 5: Post-deployment Validation

After a successful CloudFormation deploy, verify the deployed API matches the source spec counts. The bundled scripts/validate-deployment.sh automates the comparison below together with the E2E curl tests in Phase 6.

5.1 Retrieve the REST API ID
bash
aws cloudformation describe-stacks \
--stack-name <stack-name> \
--region <region> \
--query "Stacks[0].Outputs[?OutputKey=='RestApiId'].OutputValue" \
--output text

If the stack does not export RestApiId, find the API by name:

bash
aws apigateway get-rest-apis --region <region> \
| jq -r '.items[] | select(.name == "<api-name>") | .id'
5.2 Count deployed resources and compare with source-analysis.json
bash
# Count resources (paths)
aws apigateway get-resources --rest-api-id <api-id> --region <region> \
| jq '[.items[]] | length'

This is the start of the file. Read the full SKILL.md on GitHub.

Security

  • Security scanPassed, 100 of 100Pattern checks on the skill's files.
  • Model reviewNot runA model review is scheduled for the next rescan.

Quality evaluation

  • Task evaluationNot runNo evaluation yet. Run one in Skill Studio.

Source

Popularity

Repository stars
347
Repository forks
145
7-day trend score
29

Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.

Extension points

  • hookPre/post lifecycle hooks

Works with

Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.

  • Claude Code
  • Cursor
  • GitHub Copilot
  • Windsurf
  • Codex
  • Gemini CLI
  • Cline
  • Amp
  • Roo Code
  • Goose
  • Continue
  • Kilo Code
  • Junie
  • Trae
  • OpenHands
  • Qwen Code
  • AI Agent
  • Tabnine Chat
  • Sourcegraph Cody
  • Amazon Q
  • Firebase Genkit
  • Sweep
  • Devin
  • Phind
  • Mentat
  • Claude Desktop
  • Aider
  • GPT Pilot
  • Plandex
  • bolt.new
  • v0
  • Replit Agent
  • Anse
  • TypingMind
  • BetterChatGPT
  • LibreChat
  • Warp AI
  • Pieces
  • Fig AI
Embed badge
vskill VERIFIED badge
[![vskill VERIFIED](https://verified-skill.com/api/v1/skills/aws-samples/serverless-samples/openapi-to-apigw-transform/badge)](https://verified-skill.com/skills/aws-samples/serverless-samples/openapi-to-apigw-transform)

Something wrong with this skill or its page? Tell us.