AppWispr

Find what to build

From PRD to OpenAPI: A Continuous Pipeline to Keep Specs, Tests, and Feature Cards in Sync

AW

Written by AppWispr editorial

Return to blog
AI
SD
AW

FROM PRD TO OPENAPI: A CONTINUOUS PIPELINE TO KEEP SPECS, TESTS, AND FEATURE CARDS IN SYNC

App IdeasJuly 25, 20265 min read996 words

Founders and product operators waste time when PRDs, API contracts, and feature cards diverge. This post gives an executable recipe — plus file templates and CI hooks — to convert a PRD into an OpenAPI stub, generate acceptance tests and mock servers, and emit machine-readable JSON‑LD feature cards so contractors, automated agents, and reviewers all read the same spec.

prd-to-openapi-continuous-pipelinespec-driven-developmentopenapiacceptance-testsjson-ldfeature-cardscontract-testing

Section 1

Why make the PRD the single source and how to frame it

Link section

Treat the PRD as the canonical intent document, but written to be translatable. That means each feature entry should include: goal, user journey, explicit acceptance criteria, expected API surface (endpoints + important fields), and non-functional constraints (rate limits, auth). If a PRD lacks this structure, converting it will produce tests that check the wrong things.

For practical hygiene, keep each feature in its own folder (e.g., features/checkout/README.prd.md) and link a short machine‑readable metadata block at the top. That header will be the input for the generator that emits an OpenAPI stub, acceptance tests, and a JSON‑LD feature card.

  • PRD section must include: purpose, actors, acceptance criteria (GIVEN/WHEN/THEN), intended endpoints, and owner
  • Store features in features/<feature-slug>/ with a single README.prd.md and a small front-matter block

Section 2

Recipe: PRD → OpenAPI stub → mock server

Link section

Convert the structured PRD header into an OpenAPI skeleton using a small generator script. The generator maps fields from the PRD front-matter to OpenAPI: title, paths (with method, path, summary), request/response schemas (minimal types), security (e.g., bearerAuth), and examples derived from acceptance criteria. Keep the generated file in the same feature folder as openapi.yaml so it’s obvious where the contract lives.

Run a lightweight linter (Spectral) and a mock server (Prism or Postman/Stoplight mock) in CI. The mock server provides a stable sandbox for frontend contractors or agent-based code generators while backend work proceeds. Tools like Prism or Postman support OpenAPI‑based mocking and let you iterate against a predictable contract.

  • Generator inputs: PRD front-matter → map to OpenAPI fields (paths, methods, schemas, examples)
  • CI step: lint (Spectral) → validate OpenAPI → spin mock (Prism/Postman) for integration tests or demos

Section 3

Executable acceptance tests and contract checks

Link section

Use your OpenAPI file to generate executable acceptance tests. There are two pragmatic approaches: (1) generate test cases directly from OpenAPI examples/schemas (many tools produce Jest/Cypress/Postman tests), or (2) run a contract validator against a running implementation. Tools like Dredd validate a live API against an OpenAPI spec and fail CI on mismatches — that’s the simplest way to ensure the implementation meets the contract.

For deeper contract-driven workflows, use tools that treat the spec as an executable contract (Specmatic or similar). These tools can spin up smart stubs and run contract tests during CI so integration failures are caught early. Add a breaking-change gate in CI to prevent accidental incompatible edits.

  • Choice A: Generate tests from OpenAPI and run in CI (unit/contract level)
  • Choice B: Run live validation (Dredd) against a deployed test instance
  • Always include a breaking-change check on the OpenAPI file in pull requests

Section 4

Emit JSON‑LD feature cards so humans and agents share the same feature surface

Link section

A JSON‑LD feature card is a compact, typed artifact that summarizes the canonical PRD + contract for downstream consumers: contractors, reviewers, CI agents, or code generators. The generator produces a small JSON‑LD file (features/<slug>/feature-card.jsonld) containing: id, title, short description, endpoints (with OpenAPI pointer), acceptanceCriteria (array of GIVEN/WHEN/THEN), owner, and relevant tags.

Keep the feature card intentionally minimal and machine-readable. Store pointers to the OpenAPI fragment using JSON Pointer or a documented path so consumers can dereference the exact schema. Agents or contractor scripts can read feature-card.jsonld to configure scaffolding, tests, or even generate task checklists automatically.

  • Feature card fields: @id, title, description, owner, acceptanceCriteria[], openapiPointers[]
  • Store feature-card.jsonld alongside the PRD and openapi.yaml for single-location truth

Section 5

CI pattern, file templates, and developer ergonomics

Link section

Add a lightweight CI pipeline that runs on PRs touching features/: steps: validate PRD front-matter, generate openapi.yaml, lint OpenAPI (Spectral), run contract tests or Dredd against a test instance, and produce the feature-card.jsonld artifact. If any step fails, block the PR. For iterative speed, run the generator locally via a dedicated NPM/Python script so engineers can preview outputs before committing.

Provide starter templates and a CLI command (e.g., appwispr spec:init <feature-slug>) that scaffolds the feature folder: README.prd.md with front-matter, openapi.yaml stub, and feature-card.jsonld template. Keep the templates minimal to avoid friction but explicit enough that acceptance criteria are testable.

  • CI steps: prd-lint → generate openapi → spectral lint → run contract tests (Dredd/Specmatic) → publish artifacts
  • Developer command: spec:init to scaffold README.prd.md, openapi.yaml, feature-card.jsonld

FAQ

Common follow-up questions

How do I map ambiguous PRD language into types for OpenAPI?

Capture ambiguity as explicit open questions in the PRD front-matter. For the generator, default to permissive types (string/nullable) or use examples in acceptance criteria to infer types. Mark inferred fields with an x-inferred: true extension in OpenAPI so reviewers know to confirm them.

Can this pipeline work with agent-based code generators?

Yes. The JSON‑LD feature card plus OpenAPI pointer is an ideal contract for agents: the card gives the intent and acceptance criteria, the OpenAPI gives exact request/response shapes. Agents can read both to scaffold code, tests, or tasks without guessing from prose.

What tools should I start with in a greenfield repo?

Start small: Spectral for linting, a simple PRD front-matter generator script, Prism/Postman for mocks, and Dredd for live contract validation. Add Specmatic or similar only if you need executable contract stubs beyond basic mocking.

How do I prevent breaking changes to the OpenAPI file?

Add a CI gate that compares the proposed OpenAPI to the canonical file and runs a breaking-change detector (Spectral rules or custom script). Require maintainers to approve breaking changes and update feature cards and PRDs at the same time.

Sources

Research used in this article

Each generated article keeps its own linked source list so the underlying reporting is visible and easy to verify.

Next step

Turn the idea into a build-ready plan.

AppWispr takes the research and packages it into a product brief, mockups, screenshots, and launch copy you can use right away.