惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

小众软件
小众软件
Security Archives - TechRepublic
Security Archives - TechRepublic
Security Latest
Security Latest
K
Kaspersky official blog
P
Palo Alto Networks Blog
T
Threat Research - Cisco Blogs
D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Tor Project blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
A
Arctic Wolf
NISL@THU
NISL@THU
GbyAI
GbyAI
腾讯CDC
罗磊的独立博客
Simon Willison's Weblog
Simon Willison's Weblog
Scott Helme
Scott Helme
S
SegmentFault 最新的问题
Cyberwarzone
Cyberwarzone
Jina AI
Jina AI
S
Schneier on Security
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
博客园 - 【当耐特】
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Spread Privacy
Spread Privacy
C
CXSECURITY Database RSS Feed - CXSecurity.com
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
The Register - Security
The Register - Security
C
Cybersecurity and Infrastructure Security Agency CISA
L
Lohrmann on Cybersecurity
V
Vulnerabilities – Threatpost
G
GRAHAM CLULEY
P
Proofpoint News Feed
Cisco Talos Blog
Cisco Talos Blog
博客园_首页
雷峰网
雷峰网
量子位
酷 壳 – CoolShell
酷 壳 – CoolShell
V2EX - 技术
V2EX - 技术
O
OpenAI News
博客园 - 司徒正美
S
Security @ Cisco Blogs
Last Week in AI
Last Week in AI
M
MIT News - Artificial intelligence
博客园 - 叶小钗
Vercel News
Vercel News
AI
AI
博客园 - 聂微东
Webroot Blog
Webroot Blog
J
Java Code Geeks

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant Common SOC 2 Failures (Real World) Stop Vibe-Checking Your AI App: A Practical Guide to Evals How to Use SonarQube and SonarScanner Locally to Level Up Your Code Quality Your Next To-Do App Is Dead — I Replaced Mine with an OpenClaw AI Sign a Nostr event in 60 lines of Python using coincurve — no nostr-sdk, no nbxplorer, no rust toolchain ITGC Audit Explained Like You’re in Big 4 Patch Tuesday abril 2026: Microsoft parcha 163 vulnerabilidades y un zero-day en SharePoint Stop scraping everything: a better way to track competitor price changes Listing on MCPize + the Official MCP Registry while routing payments OUTSIDE the marketplace — how I kept 100% of my x402 revenue Building an AI-Powered Risk Intelligence System Using Serverless Architecture Why We Ripped Function Overloading Out of Our AI Toolchain Testing AI-Generated Code: How to Actually Know If It Works SaaS Churn Is Killing Your Business. Here Is What to Do About It (Without a Support Team) The Speed of AI Is No Longer Linear - And Self-Improving Models Are Why How to Implement RBAC for MCP Tools: A Practical Guide for Engineering Teams From Standard Quote to Persuasive Proposal: AI Automation for Arborists I built a CLI that scaffolds complete multi-tenant SaaS apps Axios CVE-2025–62718: The Silent SSRF Bug That Could Be Hiding in Your Node.js App Right Now The dashboard that ended our friendship Data Pipelines Explained Simply (and How to Build Them with Python) The Hidden Cost of AI Systems Nobody Talks About. undefined vs undeclared, and how typeof behaves Switching from file-based jobs to NATS/Kafka in Rust without changing code io_uring Adventures: Rust Servers That Love Syscalls Why Agentic AI is Killing the Traditional Database The POUR principles of web accessibility for developers and designers Quantum Neural Network 3D — A Deep Dive into Interactive WebGL Visualization How To Install Caveman In Codex On macOS And Windows Automation Pipeline Reliability: Why Your Workflow Breaks When Nobody Is Watching I Built an 'Open World' AI Coding Agent — It Works From ANY Folder From Freelancing to Product: A Tech Service Company's SaaS Transformation China's AI Giants: Adding Tencent Hunyuan & ByteDance Doubao to AI University (74 Providers) On the Vibe Coders and Their Lies clerk: Auto-Summarize Your Claude Code Sessions AI Weekly — 2026/04/10–04/17 | The Model Lockdown Is Here, but the Toolchain Is the Real Battleground AI 週報 — 2026/04/10–2026/04/17 模型封鎖潮來了,但工具鏈才是真戰場 Maybe this is how Open-Source apps are born... 🚀 Fine-Tune LLMs with LoRA and QLoRA: 2026 Guide tRPC v11 + Next.js App Router: End-to-End Type Safety Without the Boilerplate ShadCN UI in 2026: Why I Stopped Installing Component Libraries and Started Owning My Components SaaS Billing in React Server Components: Stripe + Supabase Without a Single `useEffect` Join our DEV Weekend Challenge — $1,000 in Prizes Across TEN winners! Submissions Due April 20 at 6:59 AM UTC. Implementing FSRS Spaced Repetition in Flutter + Supabase — Adding Memory Science to an AI Learning App "I Texted My Localhost From the Train — Claude Code Fixed the Bug Before I Got Home" I Built a Sales Prep AI and It Went Deeper Than Expected Design to Code #2: One JSON, Eleven Outputs Solving the 100M-Row Problem: A Summary Table Pattern for High-Volume Push Notification Logs Flutter Web With Wasm: What Actually Changes For Developers I Built 50 Royalty-Free Soundtracks for My Side Project in a Weekend Using AI Music Generation The Vibe Coding Security Checklist: 7 Things to Check Before You Ship Stop Letting Googlebot Guess Fix Your React App's SEO Right Desconstruindo o Streaming do LinkedIn: Como Criar um Engine de Extração de Vídeo de Alta Performance com HLS e FFmpeg (EDA Part-1) EDA (Exploratory Data Analysis) Explained With Real Life — Why Looking at Your Data Is the Most Important Step in Machine Learning Brand Relationship Management at Scale: Our 4-Touch Outreach System for 200+ Brands Why String.fromEnvironment() Might Return an Empty String in Dart JGuardrails 1.0.0 — Hardening Java LLM Apps Against Jailbreaks, Toxicity, and Prompt Injection Plan and Schedule a Full Week of Threads Content From One Claude Conversation Coding Cat Oran Ep3, Five Tables Changed Everything Updated: BFF Pattern I'm done watching freelancers get buried by 200 proposals. So I'm building the alternative. This is my first post BFS Algorithm in Java Step by Step Tutorial with Examples Tracking LLM Pricing Monthly: An Open Dataset for 22 AI Models How We Measure Content ROI on a Comparison Site: Revenue Attribution Without Perfect Data Introducing Nova AI Ops: The AI-Native Operating System for SRE Teams I built a free desktop video downloader for Windows — Grabbit How Talkie OCR Helps Vision-Impaired & Dyslexic Users Read the World Around Them VRCFaceTracking安装和iPhone面捕配置教程,有bug Even CrowdStrike Can't See Your Agents The Automation Gold Rush: What n8n Workflows and Claude Are Opening Up for Developers Right Now
Your API contract belongs in CI
Allen McCabe · 2026-05-17 · via DEV Community

Treating OpenAPI specs as build artifacts: a working pattern in Laravel with accord, forge, and drift.

You ship a Laravel API. You publish OpenAPI docs. The two are correct on the day you launch.

Three months later they aren't.

Maybe a nullable slipped into a response field and the iOS client started crashing on null pointer dereferences. Maybe a field got renamed in v1.2 and a partner integration silently broke for two weeks. Maybe an entire endpoint got added without a spec entry, and the docs page lies to every new developer who reads it.

The spec didn't lie when it was written. It just stopped being true.

The cost of catching that drift scales with how late you catch it: cheap in your editor, manageable in CI, expensive in staging, ruinous in production. The longer the contract goes unverified, the more confidently your team builds on top of a fiction.

The good news is that a contract is just a spec file. It can be checked. It can be a CI gate. The version of this checking that I've found practical is what this post is about.

What "API contract adherence" actually means

Two specific guarantees:

  1. Implementation matches spec. Every route the application actually serves is described by the spec. Every request and response shape that goes over the wire conforms to the schemas in the spec.
  2. Spec matches implementation. No spec entries describe routes the application no longer serves. No schemas in the spec describe shapes the application no longer produces. Both directions matter. If your spec says "/users supports DELETE" and your code removed DELETE last sprint, clients are going to call DELETE and you're going to wonder why they're seeing 405s.

OpenAPI 3.0 is the standard format for writing this contract down. It's a YAML or JSON document describing paths, operations, parameters, request bodies, and response shapes. The format is mature enough that I'm going to skip describing it in this post. If you're working on a JSON HTTP API, you've seen OpenAPI before; if you haven't, the spec docs are short.

The interesting question isn't "what does OpenAPI look like." The interesting question is: how do you keep your spec honest?

Three classes of drift

When your spec and your implementation get out of sync, the drift falls into roughly three buckets.

Structural drift. Routes added, removed, or moved. The spec says /v1/posts exists; your code doesn't have it. Or your code has /v1/posts/{id}/restore; the spec doesn't.

Shape drift. Request or response bodies that no longer match the schema. The spec says name is required and a string; your code is now accepting an array, or making it optional, or removing the field entirely.

Semantic drift. The route exists and the shape matches, but the meaning has changed. Same field name, different units. Same status code, different conditions for returning it. This is the hardest class to catch programmatically and the most expensive when it happens.

The first two classes are mechanizable. The third is mostly about reviewer discipline. The pattern I'll describe handles the first two well enough that the third is the only thing humans still need to look for.

Contract adherence as a CI/CD gate

The pattern I want to talk about is treating contract adherence as a build gate. Not a soft expectation, not a documentation chore, but a hard CI check that exits non-zero when violated.

This is more useful than runtime-only validation, for one reason: by the time a contract violation hits production, the cost is already incurred. Catching it at build time means the version of the code that violates the contract literally cannot merge. The drift doesn't ship.

A CI gate has three components:

  1. A spec file that's authoritative (committed to the repo, reviewed in PRs, treated as code).
  2. A runtime validator that checks live requests and responses against the spec.
  3. A drift detector that runs in CI, compares the routes the app actually exposes against the routes the spec describes, and fails the build on mismatch. You can build this yourself. You can also use existing tools. I built and maintain the toolchain I'm about to describe because the existing PHP options either didn't enforce both directions, didn't support multiple frameworks, or were heavy enough that adoption was a project unto itself.

The working pattern, in Laravel

The toolchain is called accord, and it's the foundation of a small family of Fissible packages that together cover the spec → validate → drift loop:

  • fissible/forge scaffolds an OpenAPI spec from your existing routes.
  • fissible/accord validates live traffic against the spec at runtime.
  • fissible/drift detects drift between routes and spec, and fails CI when it happens. Each piece is independently useful, and they snap together into the CI/CD gate.

Step 1: get a spec, even if it's empty

If your API has been running without a spec, the cheapest first step is to scaffold one from your existing routes:

composer require --dev fissible/forge
php artisan accord:generate --title="My API"

Enter fullscreen mode Exit fullscreen mode

forge walks your registered routes, infers request body schemas from your Laravel FormRequest classes, and writes a starting resources/openapi/v1.yaml with every endpoint accounted for. Response schemas are scaffolded as empty objects, and those are the ones you fill in to describe what your API actually returns.

The FormRequest inference is the one piece of forge that I want to call out. Laravel's validation rules are already a declarative description of an input contract, so lifting them into an OpenAPI request schema is mostly a translation problem rather than a generation problem. If your codebase uses FormRequest classes in a disciplined way, you get half of the spec for free.

Step 2: turn on runtime validation in log mode

Install accord and register the middleware:

composer require fissible/accord

Enter fullscreen mode Exit fullscreen mode

// bootstrap/app.php (Laravel 11+)
use Fissible\Accord\Drivers\Laravel\Http\Middleware\ValidateApiContract;

->withMiddleware(function (Middleware $middleware) {
    $middleware->appendToGroup('api', ValidateApiContract::class);
})

Enter fullscreen mode Exit fullscreen mode

Configure log mode initially:

ACCORD_FAILURE_MODE=log

Enter fullscreen mode Exit fullscreen mode

Log mode is the adoption trick. In log mode, accord still validates every request and response, but instead of throwing on violations it logs PSR-3 warnings and lets the request through. Your application keeps working, your logs start filling up with concrete violations, and you have a list of things to fix in your spec or your code before flipping to exception mode.

Without this mode, adopting accord on a live API is a "stop everything" project. With it, adoption is "run it for a week, fix what surfaces, then flip the switch."

Step 3: add the CI gate

Once you trust the spec, add drift's accord:validate command to CI:

- name: Check API contract (drift)
  run: php artisan accord:validate

- name: Check implementation coverage
  run: php artisan drift:coverage

Enter fullscreen mode Exit fullscreen mode

accord:validate exits non-zero if the spec and the implementation have drifted in either direction. drift:coverage is an optional second check that catches routes that exist in the codebase but are wired to nothing (skeleton routes, a real production hazard).

With this gate in place, the only way to merge a route change is to update the spec to match. The spec stops being a documentation artifact and becomes part of the codebase under the same review discipline as any other change.

What's technically interesting under the hood

Most of what makes accord work is unglamorous: parse the OpenAPI document, build a route lookup, hand each request through a validator that knows about JSON schemas. Three pieces are worth pulling out.

PSR-7/15 core, framework drivers

The validator and middleware in src/ have no Laravel dependency, no Slim dependency, no Mezzio dependency. Framework integration lives entirely in src/Drivers/{Framework}/. The Laravel driver is a thin service provider plus a middleware wrapper that adapts Laravel's request/response objects into PSR-7 messages.

The boundary is enforced architecturally: anything outside src/Drivers/ is forbidden from importing framework-specific code. Adding a new framework driver is implementing DriverInterface and writing a glue middleware. The cleanliness of this boundary is the kind of thing that doesn't matter the day you build it and matters every day after.

FailureMode as an enum, not a flag

I wanted three behaviours for contract violations: throw, log, or hand the result to a user-provided callable. The naive way is to thread booleans and special config values through the validator. The honest way is a single enum:

enum FailureMode: string
{
    case Exception = 'exception';
    case Log       = 'log';
    case Callable  = 'callable';
}

Enter fullscreen mode Exit fullscreen mode

The validator produces an immutable ValidationResult:

final class ValidationResult
{
    private function __construct(
        public readonly bool $valid,
        public readonly string $version,
        public readonly array $errors = [],
    ) {}

    public static function valid(string $version): self    { /* ... */ }
    public static function invalid(array $errors, string $version): self { /* ... */ }
}

Enter fullscreen mode Exit fullscreen mode

The failure mode decides what to do with the result. The benefit shows up when you go to extend: adding a fourth behaviour (queued reporting, for example) is a new enum case and a new branch, not a new flag and a new conditional everywhere.

Pluggable spec sources

A spec doesn't have to be a local file. The SpecSourceInterface abstraction lets accord load specs from anywhere:

interface SpecSourceInterface
{
    public function load(string $version): ?OpenApi;
    public function exists(string $version): bool;
}

Enter fullscreen mode Exit fullscreen mode

The default file source loads YAML or JSON from disk. A URL source fetches from a remote endpoint with optional PSR-16 caching, which is useful when multiple services validate against a shared central spec. A custom source lets you load specs from a database, a registry, or a tenant-specific lookup in a multi-tenant API. The interface is intentionally small: two methods, and you can validate against specs from anywhere.

Where this fits in Fissible's larger picture

I run a company called Fissible and build a product called Station, a self-hosted Laravel CMS and workflow platform. Station ships with a Platform Core that lets focused modules (CMS, Flow, Forms, an API module, more on the way) dock in and share auth, navigation, search, and admin UI.

The API module is where accord becomes load-bearing. Station's API surface is contract-validated end to end: forge scaffolds the spec from the routes the modules expose, accord validates live traffic, drift fails CI when the spec and the implementation diverge. Treating the contract as code isn't an aspirational team policy in Station. It's mechanically enforced.

If you want to see this pattern running end-to-end on a real product, Station is where to look. If you just want the validator and the CI gate for your own Laravel API, accord and drift are the two packages to install.

The short version

API contract adherence is a CI/CD problem more than a documentation problem. You write the contract once. You validate against it at runtime. You fail the build when it drifts. After that, the spec is honest because the build won't pass otherwise, and the cost of a contract violation collapses from "found in production" to "found in the PR that introduced it."

The earlier a breach is caught, the cheaper it is to fix. Treating the spec as a build gate makes catching it the default.