From PRD to OpenAPI: A Continuous Pipeline to Keep Specs, Tests, and Feature Cards in Sync
Written by AppWispr editorial
Return to blogFROM PRD TO OPENAPI: A CONTINUOUS PIPELINE TO KEEP SPECS, TESTS, AND FEATURE CARDS IN SYNC
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.
Section 1
Why make the PRD the single source and how to frame it
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
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
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
Sources used in this section
Section 5
CI pattern, file templates, and developer ergonomics
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.
spec-coding.dev
How to Convert PRDs to Specs (Step-by-Step) | Spec Coding
https://spec-coding.dev/guides/prd-to-spec-guide
api-portal.io
Spec-First API Development: A Practical Guide for Modern API Teams
https://www.api-portal.io/en/resources/articles/spec-first-api-development
Swagger
Swagger Editor Documentation
https://swagger.io/docs/open-source-tools/swagger-editor/
dredd.org
Dredd — HTTP API Testing Framework
https://dredd.org/en/latest/
Specmatic
Contract Driven Development | Specmatic
https://docs.specmatic.io/contract_driven_development
Postman
Design API specifications in Postman | Postman Docs
https://learning.postman.com/docs/design-apis/specifications/overview/
codeables.dev
Tools for a spec-first GitHub + CI workflow that keeps OpenAPI, docs, snippets, and SDKs in sync
https://codeables.dev/article/tools-for-a-spec-first-github-ci-workflow-that-keeps-openapi-docs
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.