Tutorial · target: how to run openapi linter in ci
How to Generate Lint gate fixture Seed Data with One Command
User wants spec linting and seed regeneration in the same pull-request gate.
Direct answer
Generating a seed and a negative fixture set for Lint gate fixture takes one generate command and produces a set of committed files, with no hand-written INSERT statement in between.
The steps assume Node.js 22.6 or newer and the schema document that ships with this page; a schema with remote $ref URLs needs the files downloaded first.
One generate command writes 1 tables in dependency order into ./seed/sql/seed.sql, and the negative cases go to ./seed/sql/negatives.sql beside it; the same run also writes the pytest suite in ./seed/pytest, where each negative case is asserted against the schema keyword it breaks.
Data as of 2026-11-18 · source: 0 Stack Overflow questions, openapi-typescript at 61,064,985 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
Prerequisites — Lint gate
You need a schema document for Lint gate fixture and a Node.js runtime. The Lint gate fixture fixture used here has 1 tables, and the commands below assume the file is at openapi/file that ships with this page. Nothing else is required: no database connection, no API key, no network access at generation time.
The steps
One command does the work. The generate command reads the schema, writes the seed and the negative cases in a single pass, and prints what it produced: the tables it wrote, the rows per table and the number of negative cases. For Lint gate fixture that is 1 tables in dependency order, with 6 constraints carried into the DDL. Two read-only commands sit next to it for checking instead of writing: validate reports the $ref chains that cannot be resolved and exits non-zero when one is broken, and inspect prints the tables, columns, primary keys and foreign keys the tool derived.
What you end up with
A set of committed artefacts: the PostgreSQL seed script, the negative SQL cases and the pytest suite. The seed for Lint gate fixture contains 1 table definitions and their rows in dependency order. The negative file holds the instances the API must reject, one per constraint class that the fixture declares, and the pytest suite carries both the valid rows and the negative ones. All of them are text, all of them diff in review, and all of them are regenerated by re-running the same command.
Wiring it into CI
The CI step is a diff, not a test. Regenerate the seed and fail the build if the committed file differs from the regenerated one. That single check catches the case where Lint gate fixture changed shape and the fixture did not, which is the failure that a hand-maintained seed produces silently for months.
Troubleshooting
If the generator warns about a schema it skipped, the warning names the construct. For Lint gate fixture, the constructs worth knowing about are the range declaration on specs.rule_failures and the table references. A skipped construct is reported, never silently dropped, which is the behaviour to insist on from any tool in this position.
| Failure class | Column | SQLSTATE | Error name | Engine message (verbatim) |
|---|---|---|---|---|
| Missing required field | specs.name | 23502 | not_null_violation | NOT NULL constraint failed: specs.name |
| Out-of-contract value | specs.rule_failures | 23514 | check_violation | CHECK constraint failed: specs_rule_failures_check |
| Table | Referenced by | Written |
|---|---|---|
| specs | — | first, no dependencies |
npx --yes @wenlu8848/schemaseed generate --input ./tut_lint.openapi.yaml --out ./seed --formats sql --count 10 --seed 42
Download tut_lint.openapi.yaml
-- Generated by schemaseed.
-- seed: 42
-- rows per table: 10
-- Foreign key values are taken from the rows of the referenced table.
BEGIN;
CREATE TABLE IF NOT EXISTS "specs" (
"id" UUID,
"name" TEXT NOT NULL,
"version" TEXT NOT NULL,
"rule_failures" INTEGER NOT NULL,
"linted_at" TIMESTAMPTZ NOT NULL,
CONSTRAINT "specs_pkey" PRIMARY KEY ("id"),
CONSTRAINT "specs_rule_failures_check" CHECK ("rule_failures" >= 0)
);
INSERT INTO "specs" ("id", "name", "version", "rule_failures", "linted_at")
VALUES ('0ac05e90-e144-4473-a1ff-9ac0b4f3e1a4', 'kelp umbra', 'Lisbon, Maple Street 93', 838, '2025-03-12T19:32:48.000Z')
ON CONFLICT DO NOTHING;
INSERT INTO "specs" ("id", "name", "version", "rule_failures", "linted_at")
VALUES ('38573d15-badb-4609-a1a9-9ae13b3cbb18', 'Milo Adler', 'eli.duarte@mail.example', 175, '2026-06-05T01:44:33.000Z')
ON CONFLICT DO NOTHING;
INSERT INTO "specs" ("id", "name", "version", "rule_failures", "linted_at")
VALUES ('4d212f34-dc6e-4d33-815e-3a15b200f8fc', 'indigo lumen', 'zephyr-pebble-990', 198, '2021-06-12T03:56:20.000Z')
ON CONFLICT DO NOTHING;
INSERT INTO "specs" ("id", "name", "version", "rule_failures", "linted_at")
VALUES ('793f37d7-2d4f-44c0-b9f0-6d4edd41a940', 'milo.duarte@example.com', 'Rosa Duarte', 272, '2023-07-28T22:52:14.000Z')
ON CONFLICT DO NOTHING;
INSERT INTO "specs" ("id", "name", "version", "rule_failures", "linted_at")
VALUES ('c1fd5142-07b0-4c96-9e6d-c464846790b6', 'Nia Holt', 'quartz summit', 842, '2024-04-17T17:56:20.000Z')
ON CONFLICT DO NOTHING;
INSERT INTO "specs" ("id", "name", "version", "rule_failures", "linted_at")
VALUES ('0c3cdf96-bfe9-427b-aae4-2ff93fdc2644', 'Eli Duarte', 'Chen Ibarra', 900, '2020-12-07T03:17:29.000Z')
ON CONFLICT DO NOTHING;
INSERT INTO "specs" ("id", "name", "version", "rule_failures", "linted_at")
VALUES ('41accaf9-f962-41a6-97ab-08222666b00d', 'alpha-indigo-107', 'Lena Jansen', 111, '2022-11-08T01:27:15.000Z')
ON CONFLICT DO NOTHING;
INSERT INTO "specs" ("id", "name", "version", "rule_failures", "linted_at")
VALUES ('c4f2cf3d-22fc-47cd-a59c-b3423cc1bc51', 'zephyr umbra', 'delta quartz', 98, '2023-11-09T16:32:06.000Z')
ON CONFLICT DO NOTHING;
INSERT INTO "specs" ("id", "name", "version", "rule_failures", "linted_at")
VALUES ('a445fbd2-3110-47aa-a735-1086d2c36a8a', 'river delta', 'onyx-kelp-266', 622, '2025-04-17T10:15:42.000Z')
ON CONFLICT DO NOTHING;
INSERT INTO "specs" ("id", "name", "version", "rule_failures", "linted_at")
VALUES ('3938a918-fa24-497d-8dce-562a2cb56957', 'Toronto, Riverside Lane 205', 'Jun Moreau', 480, '2023-03-06T19:25:12.000Z')
ON CONFLICT DO NOTHING;
-- (no foreign keys)
COMMIT;
Frequently asked questions
- How long does the whole workflow take?
- One generate command and a moment on the Lint gate fixture of 1 tables; the slow part is deciding the row order, which is exactly what the generator removes.
- What do I commit to the repository?
- The generated files, all as text: the PostgreSQL seed script, the negative SQL cases and the pytest suite. Re-running with the same seed reproduces them byte for byte on the Lint gate fixture schema.
- Does the CI step need a database?
- The drift check does not: it regenerates and fails if the committed file differs. Add a database service only if you also load the 1 tables.
- What happens if my schema changes?
- The regenerated file differs, CI fails with the diff attached, and every declaration in the schema is re-read, so a new one appears in the negative set immediately.
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