Alternative · target: openapi sample generator alternative
openapi-sampler Alternative for Webhook sample payloads Seed Data
User wants example payloads from a spec but also needs the invalid ones that must be rejected.
Direct answer
SchemaSeed reads the Webhook sample payloads schema and writes loadable rows; openapi-sampler generates values for one document, with no SQL and no invalid instances. The gap appears with cross-table references.
That gap only matters once the fixture has two or more tables that reference each other, or once a test suite must assert the API rejects malformed input; for one flat schema openapi-sampler is usually sufficient.
The same Webhook sample payloads schema run through openapi-sampler yields a JSON document whose sample_payloads.subscription_id reference values that match no parent row; the reference engine rejected that shape with "FOREIGN KEY constraint failed".
Data as of 2026-11-18 · source: 0 Stack Overflow questions, 1 Hacker News stories, @scalar/openapi-types at 44,250,681 monthly downloads · negative-case messages reproduced by executing the fixture against a local SQL engine (Node.js v24.22.0, engine 3.53.4) at 2026-11-18T11:53:54.233Z
What the incumbent does well — Webhook sample
openapi-sampler is a mature tool and it is not going away. For a single flat schema it produces valid JSON faster than anything else, and its API surface is small enough to learn in an afternoon. If your Webhook sample payloads fixture is one table with no cross-table references, the honest answer is that openapi-sampler is enough and this page will not change your mind.
The gap that matters for relational seeds
The gap appears the moment the fixture stops being one table. openapi-sampler reads one schema and produces one document; it has no second schema to read, so it cannot know that sample_payloads.subscription_id must point at a row in subscriptions. The result is values that are individually plausible and collectively unloadable. The reference engine rejected exactly that shape with "FOREIGN KEY constraint failed".
Side by side on the same fixture
The table below scores the two approaches against the identical Webhook sample payloads fixture. The rows are not opinions about architecture; each one is a property of the fixture that the reference engine can verify. The decisive row is the foreign key row, because a JSON document can carry a dangling reference without any tool complaining until the moment it is loaded.
Migrating an existing fixture
You do not have to rewrite your fixture. Keep the schema file, run the generator against it, and diff the output against the rows you already have. For Webhook sample payloads the diff is usually small: 2 tables, and the changes are the constrained columns, which are the ones a hand-written seed gets wrong most often. The negative case set is additive, so nothing you already depend on is lost.
How to decide in under a minute
Two questions decide it. Does your schema have more than one table that reference each other? Does your test suite need to prove the API rejects malformed input? If both answers are no, stay on openapi-sampler. If either is yes, the missing piece is the same in both cases: a generator that reads the whole document and treats the constraints as part of the contract rather than as decoration.
| Criterion | SchemaSeed | openapi-sampler | What decided it |
|---|---|---|---|
| Reads a multi-file OpenAPI document | yes | yes | both resolve local $ref chains |
| Honours NOT NULL | yes | partial | both read the required array |
| Honours enum, range and length declarations | yes | partial | the fixture declares sample_payloads.valid with "valid" IN (0,1); the declaration is read out of the schema, the DDL carries it as a CHECK constraint and the value that breaks it ships as a negative case |
| Honours enum members | yes | yes | the enum array is copied verbatim |
| Produces SQL, not just JSON | yes | no | output format is the difference |
| Resolves foreign keys across schemas | yes | no | the fixture has sample_payloads.subscription_id pointing at subscriptions, and the second tool never reads that table |
| Emits deliberately invalid instances | yes | no | negative cases are a separate output |
| Same seed produces the same bytes | yes | yes | both are seedable |
| Failure class | Column | SQLSTATE | Error name | Engine message (verbatim) |
|---|---|---|---|---|
| Missing required field | subscriptions.url | 23502 | not_null_violation | NOT NULL constraint failed: subscriptions.url |
| Out-of-contract value | sample_payloads.valid | 23514 | check_violation | CHECK constraint failed: sample_payloads_valid_check |
| Dangling foreign key | sample_payloads.subscription_id | 23503 | foreign_key_violation | FOREIGN KEY constraint failed |
| Check | Result on this fixture | Consequence |
|---|---|---|
| More than one table references another | yes — sample_payloads → subscriptions | the generator must resolve cross-table references |
| Output has to be SQL, not JSON | yes — the target is PostgreSQL | a document generator produces the wrong artefact |
| Tests must assert the API rejects bad input | yes — a negative case for every declaration in the schema | negative instances have to be generated separately |
| Same seed must reproduce the same bytes | yes — seed 42 is fixed | fixtures can be committed and diffed |
npx --yes @wenlu8848/schemaseed validate --input ./alt_webhook_samples.openapi.yaml
Download alt_webhook_samples.openapi.yaml
openapi: "3.0.3"
info:
title: "Webhook sample payloads"
version: "1.0.0"
description: "The valid flag is what separates the positive sample from the deliberately broken one. Every sample payload row has to reference a subscription, so the negative samples still need a valid parent. The comparison is between a tool that only samples valid payloads and one that emits both. The body column is json, so a payload written as a quoted string is stored as a JSON string rather than an object."
paths: {}
x-domain-id: "alt_webhook_samples"
x-dialect: "postgres"
components:
schemas:
subscriptions:
type: "object"
x-primary-key: "id"
required: ["id", "url", "secret"]
properties:
id:
type: "string"
format: "uuid"
url:
type: "string"
format: "uri"
secret:
type: "string"
sample_payloads:
type: "object"
x-primary-key: "id"
required: ["id", "subscription_id", "event_type", "body", "valid"]
properties:
id:
type: "string"
format: "uuid"
subscription_id:
$ref: "#/components/schemas/subscriptions"
event_type:
type: "string"
body:
type: "object"
valid:
type: "integer"
minimum: 0
maximum: 1
Frequently asked questions
- Is openapi-sampler still worth using?
- For one flat schema, yes. The gap opens on Webhook sample payloads: openapi-sampler produces values for a single schema, while this fixture has 2 related tables that have to load together.
- Can I keep the fixtures I already wrote?
- Yes. Regenerate against the same Webhook sample payloads schema and diff. On this fixture only the constrained columns move, and the negative cases are additive.
- Does SchemaSeed replace openapi-sampler entirely?
- No. It is a different artefact: openapi-sampler produces values for one schema, SchemaSeed produces JSON fixture files plus invalid instances for 2 related tables.
- Is there a paid version?
- No. The CLI is MIT licensed and free: unlimited local generation, no account, no telemetry and no usage limit, and it runs on your own machine. Sponsorship is what keeps it maintained.
Run it against your own schema
SchemaSeed is MIT licensed and free: unlimited local generation, no account, no telemetry and no usage limit. It reads your schema file on your own machine, so nothing is uploaded anywhere. If it saves you time, you can support the project.
Get SchemaSeed — free Support the project
Questions: support@schemaseed.drz8848.win