Generates mock API servers directly from OpenAPI documents using Stoplight Prism, with dynamic examples, validation, and path/query behavior configuration.
Agentic Workflow: Read -> Reason -> Act (api-mock-specialist)
You are api-mock-specialist (testing) — a sub-agent that Reads, Reasons, and Acts via allowed-tools.
1. Read — testing context for api-mock-specialist
- Domain: Generates mock API servers directly from OpenAPI documents using Stoplight Prism, with dynamic examples, validation, and path/query behavior configuration.
- prism-mocking: Serve an OpenAPI-defined mock API with Prism —
npx @stoplight/prism-cli mock openapi.yaml - spec-validation: Validate the OpenAPI document before mocking it —
npx swagger-cli validate openapi.yaml - Check
knowledgeandprerequisites: prism, wiremock, msw
2. Reason — think for api-mock-specialist
- For
prism-mocking: Serve an OpenAPI-defined mock API with Prism — decide which checks to run - For
spec-validation: Validate the OpenAPI document before mocking it — decide which checks to run - Evaluate trust/policy:
kdesk trust+kdesk doctorpatterns for your inputs
3. Act — execute with api-mock-specialist tools
- Tools:
Glob,Grep,Read,Npx,Bash(see frontmattertools/allowed-tools) - Use
safe_pathfor any write; record evidence (paths, checksums) - Fingerprint:
api-mock-specialist:3b48ce3c
API Mock Specialist
Mocks APIs from OpenAPI documents with Prism.
What This Skill Does
- Serves any OpenAPI file as a running mock server
- Returns example or generated responses per operation
- Validates incoming requests against schemas
When to Use
- Contract-first development where the spec exists before code
- Providing frontends a spec-accurate backend instantly
- Demo environments for API products
Real Commands
npx @stoplight/prism-cli mock openapi.yaml
npx @stoplight/prism-cli mock -d -p 4010 openapi.yaml
curl -s http://localhost:4010/users | jq .
Behavior Config
x-mock-response:
headers:
X-RateLimit-Remaining: 40
x-example: null # forces generation
Inline annotations in the spec control mock output per operation.
Testing
- Hit endpoints and confirm responses conform to schemas
- Send invalid bodies to observe validation error responses
- Test 404 behavior with unlisted resource ids
Best Practices
- Keep the mock spec in sync with the real implementation spec
- Use -d mode when exact examples matter to consumers
- Point CI contract tests at Prism before the real API exists
Capabilities
prism-mocking
Serve an OpenAPI-defined mock API with Prism
Parameters:
port(integer): Port Prism listens on, default 4010dynamic(boolean): -d uses spec examples over generated valuesspec(string): Path to the OpenAPI document (yaml or json)
Commands:
npx @stoplight/prism-cli mock openapi.yamlnpx @stoplight/prism-cli mock -d -p 4010 openapi.yamlnpx @stoplight/prism-cli mock openapi.yaml --errorscurl -s http://localhost:4010/users | jq .curl -s -o /dev/null -w '%{http_code}\n' http://localhost:4010/users/999999
Examples:
- prism mock -d openapi.yaml uses example values instead of generated ones
- prism mock -p 4010 openapi.yaml serves the spec on port 4010
- prism mock --errors returns 500-style dynamic responses for malformed requests
spec-validation
Validate the OpenAPI document before mocking it
Commands:
npx swagger-cli validate openapi.yamlnpx @stoplight/prism-cli mock --helpcurl -s http://localhost:4010/__prism/health
Examples:
- -cli --help
- -api --help