platform-api-contract

Enforce OpenAPI as the single source of truth for the AgentHub Platform HTTP API contract.

Updated May 19, 2026
One-click install
npx skills add https://github.com/zxc1a1a1/Multi_Agent-AgentHub --skill platform-api-contract
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: platform-api-contract
Source: https://github.com/zxc1a1a1/Multi_Agent-AgentHub/tree/main/.agents/skills/platform-api-contract
Command: npx skills add https://github.com/zxc1a1a1/Multi_Agent-AgentHub --skill platform-api-contract

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

It prevents frontend/backend/API drift by making the AgentHub Platform HTTP API contract explicit, discoverable, and enforceable through OpenAPI as the single source of truth.

Core Features & Use Cases

  • OpenAPI 事实源: 强制使用 docs/contracts/openapi.yaml 作为唯一事实源,并要求稳定 operationId、schema 可复用、securitySchemes 完整。
  • 公开/内部边界隔离: 规范公开的 /api/,禁止把 /internal/、/orchestrator/、/a2a/ 等内部接口泄漏到公开 OpenAPI。
  • 统一响应与错误体系: 规定成功与错误 envelope、错误码域与 HTTP status 策略,保证鉴权与对象级权限的一致性。
  • 资源化与可扩展策略: 给出 Conversation/Message/Agent/Artifact/Run 等平台资源的字段形态、分页排序搜索、以及 Run.status 枚举约束。
  • 前端类型与 Handler 一致性: 要求前端 API client 与类型由 OpenAPI 生成,并通过 contract test 校验不返回 OpenAPI 未定义字段。

Quick Start

Update docs/contracts/openapi.yaml first, then implement Gateway Handlers to match the schema, using mocks and contract tests to verify auth, permission, success, and error responses.

Frequently Asked Questions about platform-api-contract

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I enforce a single OpenAPI contract for frontend and gateway APIs?

To enforce a single OpenAPI contract, you must use docs/contracts/openapi.yaml as the single source of truth, requiring stable operationIds and reusable schemas. This prevents frontend, backend, and API drift by making the Platform HTTP API contract explicit and enforceable.

What is the best way to isolate internal endpoints from public OpenAPI definitions?

Isolating internal endpoints from public OpenAPI definitions requires defining strict boundaries for public /api/** resources. You must prevent /internal/**, /orchestrator/**, and /a2a/** endpoints from leaking into the public OpenAPI contract to maintain secure API separation.

How do I standardize error envelopes and HTTP status codes in API contract testing?

Standardizing error envelopes and HTTP status codes in API contract testing involves defining strict success and error response structures. The contract enforces specific error code domains and HTTP status strategies to guarantee authentication and object-level permission consistency across the gateway.

Can I generate frontend API client types directly from an OpenAPI contract?

Yes, you can generate frontend API client types directly from the OpenAPI contract. The contract specifies that frontend API clients and types must be OpenAPI-generated, ensuring strict consistency between the gateway handlers and the frontend models.

How do I verify gateway handler responses match OpenAPI schemas using contract tests?

Verifying gateway handler responses with contract tests involves using mocks to validate authentication, permissions, and error responses. Contract tests strictly check that handlers do not return any fields undefined by the OpenAPI schema, ensuring output consistency.

Why do contract tests fail when API responses return undefined OpenAPI fields?

Contract tests fail when API responses return undefined OpenAPI fields because the contract enforces strict handler output consistency. This mechanism ensures the gateway only returns data explicitly defined in the OpenAPI schema, preventing unexpected frontend type mismatches and drift.