rest-api-contract

Governs REST API contract design, compatibility, versioning, and OpenAPI documentation for Spring Boot services.

39|3|Updated Jul 28, 2025
One-click install
npx skills add https://github.com/mzivkovicdev/spring-crud-generator --skill rest-api-contract-mzivkovicdev
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: rest-api-contract
Source: https://github.com/mzivkovicdev/spring-crud-generator/tree/main/.agents/skills/rest-api-contract
Command: npx skills add https://github.com/mzivkovicdev/spring-crud-generator --skill rest-api-contract-mzivkovicdev

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Public REST APIs break consumers when endpoints, fields, status codes, or error contracts change without deliberate compatibility analysis, and teams lack a consistent way to decide whether a change is breaking, how to version or deprecate, and how to keep an OpenAPI document honest with the implementation. ## Core Features & Use Cases - Breaking-change judgement: Provides a request/response asymmetry model and a full breaking-change reference table covering fields, enums, constraints, statuses, headers, and defaults. - Contract document governance: Guides the decision between OpenAPI and no document, and between code-first and contract-first authoring, including generator configuration for Maven and Gradle on Spring Boot 3 and 4. - Versioning, deprecation, and drift gates: Defines whole-API versioning strategies, RFC 8594/9745 sunset headers, and a committed-document drift gate test that fails the build on unexplained contract diffs. - Use Case: When adding a required field to an existing endpoint, use this Skill to classify the change as breaking, choose between an optional-field alternative or a new API version, and update the OpenAPI document and contract test accordingly. ## Quick Start Use the rest-api-contract skill to review whether my planned endpoint change is breaking and update the OpenAPI document accordingly.

Frequently Asked Questions about rest-api-contract

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I know if a REST API change is breaking?▼

A change is breaking based on direction: in requests, tightening what the service accepts breaks callers, while in responses, removing or narrowing breaks them. Adding a required request field, renaming a field, changing a type, or removing an endpoint are all breaking changes.

Code-first vs contract-first OpenAPI: which should I choose?▼

Code-first generates the document from controllers via springdoc and suits a single team owning both sides. Contract-first hand-writes the document and generates interfaces, fitting multiple services, external consumers, or parallel teams. A project uses exactly one direction per deployable service.

Does adding an enum value to an API response break clients?▼

Yes, in practice. Generated clients commonly fail to deserialize unknown enum values, so treat new response enum values as breaking unless every consumer tolerates unknowns. Document that consumers must accept unknown values to design enums for extension.

How do I keep an OpenAPI document in sync with Spring Boot code?▼

Commit the generated document and add a drift-gate integration test that regenerates it via MockMvc and compares parsed trees against the committed copy, failing the build on unexplained differences. Contract-first projects instead validate the implementation against the committed document.

When should I not use this REST contract guidance?▼

This guidance does not apply to GraphQL, gRPC, event-driven contracts, or gateway configuration. It covers only public REST APIs on Java 21+ Spring Boot, including their OpenAPI documents, versioning, and deprecation.

How do I deprecate a REST API endpoint properly?▼

Mark the operation deprecated with a successor and retirement date in its description, send Deprecation and Sunset headers per RFC 9745 and RFC 8594, and announce directly to known consumers. Never remove before the sunset date and confirm disuse from access logs first.