Skip to content

feat: add OpenAPI and Smithy model gateway target types#516

Merged
aidandaly24 merged 2 commits intomainfrom
feat/openapi-smithy-targets
Mar 9, 2026
Merged

feat: add OpenAPI and Smithy model gateway target types#516
aidandaly24 merged 2 commits intomainfrom
feat/openapi-smithy-targets

Conversation

@tejaskash
Copy link
Contributor

Summary

  • Add openApiSchema and smithyModel as new gateway target types, enabling users to auto-derive tools from an OpenAPI JSON spec or Smithy JSON model
  • Add --schema flag (accepts local .json file path or s3:// URI) and --schema-s3-account flag for cross-account S3 access
  • Add SchemaSourceSchema Zod type, SchemaBasedTargetConfig discriminated union variant, createSchemaBasedGatewayTarget() primitive method, and CLI validation

Changes

  • Schema (src/schema/schemas/mcp.ts): SchemaSourceSchema (inline/S3), schemaSource field on AgentCoreGatewayTargetSchema, superRefine rules
  • CLI validation (src/cli/commands/add/validate.ts): JSON-only enforcement, file existence check, S3 URI format validation
  • CLI primitive (src/cli/primitives/GatewayTargetPrimitive.ts): --schema/--schema-s3-account flags, createSchemaBasedGatewayTarget() method
  • TUI types (src/cli/tui/screens/mcp/types.ts): SchemaBasedTargetConfig in discriminated union, new TARGET_TYPE_OPTIONS
  • TUI flow (AddGatewayTargetFlow.tsx): Branch for schema-based targets
  • Tests: 15 schema tests, 3 discriminated union tests, 17 integration tests (lifecycle, S3, cross-account, validation)

Usage

# OpenAPI (local file)
agentcore add gateway-target --name petstore --type open-api-schema \
  --schema ./specs/petstore.json --gateway my-gw

# Smithy (S3 URI)
agentcore add gateway-target --name my-svc --type smithy-model \
  --schema s3://my-bucket/models/service.json --gateway my-gw

# Cross-account S3
agentcore add gateway-target --name petstore --type open-api-schema \
  --schema s3://my-bucket/specs/petstore.json --schema-s3-account 123456789012 --gateway my-gw

Test plan

  • Schema unit tests pass (SchemaSourceSchema validation, AgentCoreGatewayTargetSchema superRefine)
  • Discriminated union type narrowing tests pass
  • Integration tests pass (OpenAPI local file, S3 URI, cross-account, Smithy, validation errors)
  • TypeScript compiles cleanly
  • Pre-commit hooks (eslint, prettier, secretlint) pass

Related

  • CDK PR: aws/agentcore-l3-cdk-constructs (feat/openapi-smithy-targets)

Add support for openApiSchema and smithyModel as new gateway target types, enabling
users to auto-derive tools from an OpenAPI JSON spec or Smithy JSON model.

Schema:
- Add SchemaSourceSchema Zod type (inline local file or S3 URI)
- Add schemaSource field to AgentCoreGatewayTargetSchema with superRefine validation
- Update LLM-compacted schema

CLI:
- Add --schema and --schema-s3-account flags to add gateway-target command
- Add validation for schema-based targets (JSON-only, file existence, S3 URI format)
- Add createSchemaBasedGatewayTarget() primitive method
- Add SchemaBasedTargetConfig to discriminated union type

TUI:
- Add SchemaBasedTargetConfig to AddGatewayTargetConfig union
- Add openApiSchema/smithyModel to TARGET_TYPE_OPTIONS
- Add schema-based branch in AddGatewayTargetFlow

Tests:
- Add SchemaSourceSchema and AgentCoreGatewayTargetSchema unit tests
- Add discriminated union narrowing tests for SchemaBasedTargetConfig
- Add integration tests for OpenAPI/Smithy lifecycle, S3 URI, cross-account, and validation errors
@tejaskash tejaskash requested a review from a team March 9, 2026 15:32
@github-actions github-actions bot added the size/l PR size: L label Mar 9, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 9, 2026

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 42.61% 3739 / 8774
🔵 Statements 42.2% 3944 / 9345
🔵 Functions 44.27% 738 / 1667
🔵 Branches 44.45% 2443 / 5495
Generated in workflow #909 for commit d9101fe by the Vitest Coverage Report Action

aidandaly24
aidandaly24 previously approved these changes Mar 9, 2026
Copy link
Contributor

@aidandaly24 aidandaly24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two nit comments but other than that I think this looks clean and good to me.

…rgets

Mirror CDK schema validation: openApiSchema/smithyModel targets should reject
toolDefinitions (tools are auto-derived) and apiGateway config.
Copy link
Contributor

@aidandaly24 aidandaly24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for making the updates approved

@aidandaly24 aidandaly24 merged commit 0d1021d into main Mar 9, 2026
20 of 21 checks passed
@aidandaly24 aidandaly24 deleted the feat/openapi-smithy-targets branch March 9, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/l PR size: L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants