Documentation
¶
Overview ¶
Package mock turns an OpenAPI spec into a running, STATEFUL mock server:
optictrace mock -spec openapi.yaml -listen :7070
Three layers, in order of preference per request:
- State: collection/item routes (POST /cart then GET /cart/{id} returns what you posted) backed by an in-memory store. This is what makes the mock believable for frontend flows — state, not canned JSON.
- AI (optional, -ai + ANTHROPIC_API_KEY): non-CRUD operations ask Claude for a context-aware response conforming to the response schema.
- Deterministic generation: realistic values from schema + field-name heuristics (emails look like emails, prices look like prices).
Any failure in layer 2 falls back to layer 3 — the mock never depends on network access to function.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Options ¶
type Options struct {
AI bool // enable Claude-generated responses when ANTHROPIC_API_KEY is set
}
Click to show internal directories.
Click to hide internal directories.