API Contract Test

Generate contract tests validating API endpoints against OpenAPI and TypeScript types.

1|1|Updated Mar 31, 2026
One-click install
npx skills add https://github.com/btabaska/simpler-grants-documentation-automation --skill api-contract-test
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: API Contract Test
Source: https://github.com/btabaska/simpler-grants-documentation-automation/tree/main/.cursor/skills/skill-api-contract-test
Command: npx skills add https://github.com/btabaska/simpler-grants-documentation-automation --skill api-contract-test

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill automates the generation of deterministic API contract tests to validate API endpoints against the OpenAPI spec and frontend TypeScript types, reducing drift and speeding up integration readiness.

Core Features & Use Cases

  • Automated contract test generation: Create pytest tests for API endpoints or Vitest tests for frontend calls that verify request/response shapes against the OpenAPI schema and generated clients.
  • Drift detection and fast feedback: Compare implementation, OpenAPI, and frontend types to fail early on mismatches.
  • End-to-end workflow: Reads handlers, OpenAPI spec, and client models to produce test files under api/tests/contracts/ or frontend/tests/contracts/.

Quick Start

Provide an endpoint (e.g., GET /v1/opportunities/search) and the target side (api or frontend) to generate the corresponding contract test file.

Frequently Asked Questions about API Contract Test

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

FAQPage Schema
How do I automate API contract tests against an OpenAPI spec?

Automating API contract tests involves generating pytest or Vitest files that validate endpoint request and response shapes against your OpenAPI schema. This skill reads API handlers and OpenAPI schemas to output deterministic test files under your tests/contracts/ directories.

What is API contract testing for frontend and backend drift detection?

API contract testing for drift detection compares API implementations, OpenAPI specs, and frontend TypeScript types to fail early on mismatches. It generates synthetic fixtures to verify that backend response shapes and frontend client models remain aligned.

How do I generate Vitest contract tests for frontend API clients?

Generating Vitest contract tests for frontend API clients requires providing an endpoint and specifying the frontend target. The skill reads frontend TS scaffolding and OpenAPI schemas to produce test files validating request and response shapes under frontend/tests/contracts/.

Can I use pytest to validate API endpoint response shapes against OpenAPI?

Yes, you can use pytest to validate API endpoint response shapes against OpenAPI by providing an endpoint and targeting the api side. The skill reads API handlers and OpenAPI schemas to output test files under api/tests/contracts/.

Do I need to provide secrets or real data for API contract test generation?

No, you do not need to provide secrets or real data for API contract test generation. The skill preserves safety by using synthetic fixtures and avoiding secrets entirely when validating request and response shapes.

When should I run API contract tests in my development workflow?

You should run API contract tests when endpoints are added or modified, the OpenAPI spec is regenerated, or frontend clients are extended. This ensures deterministic tests live alongside API and frontend code to catch drift early.