Answer to the Core Question
Re‑adding a property that was previously marked deprecated and then removed will preserve compatibility with clients that were generated from the pre‑removal spec, as long as those clients have not been updated to treat the property’s absence as a new contract. If a client has already been modified to drop all references to the field, the rollback can become a breaking change for that client.
Confirmed Facts
- Rolling back to a prior OpenAPI document restores the exact contract that existed before the deprecation.
- Clients generated from that earlier spec will still deserialize and validate responses containing the re‑added property without modification.
- Different OpenAPI generators treat the
deprecated flag in varied ways: some ignore it, some add a comment or warning, and a few generate runtime checks.
Likely Explanation
The compatibility guarantee comes from the fact that the rolled‑back spec is a superset (or identical) of the deprecated version. A client that ignores unknown properties will happily accept the extra field, while a client that expects the exact schema will continue to work because the field is back in place. The only risk is when a client has been explicitly refactored to remove the field or to treat its absence as a feature flag.
Practical Steps to Verify Compatibility
- Check the source control history. Identify the commit that introduced the deprecation and the one that removed the property. Verify that the rolled‑back file matches the pre‑removal version.
- Regenerate artifacts. Run
openapi-generator generate (or your preferred tool) against the rolled‑back spec and compare the generated client SDK or server stubs with those produced from the original spec.
- Deploy the API. Use the rolled‑back spec to generate server code or update the existing server to expose the property again.
- Run contract tests. Execute Pact, Dredd, or similar tests against the deployed API using the existing client binaries to ensure no validation errors occur.
- Review client code. Search the client codebase for any explicit removal or handling of the deprecated property. If found, adjust the client or maintain the old contract via versioning.
What to Verify About Clients
Before concluding that the rollback is safe, confirm whether any client has been updated to:
- Remove the property entirely from request/response models.
- Use the absence of the property as a feature flag or control flow.
- Implement custom validation that fails when the property is present.
Missing Diagnostic Detail
Does any existing client codebase already exclude the deprecated property or treat its absence as a signal? If so, the rollback may introduce a breaking change for those clients and you should consider maintaining a separate API version instead.
Safe Commands (if you need to check the spec in Git)
git checkout <commit-before-deprecation> -- path/to/openapi.yaml
# Compare with current spec
git diff HEAD path/to/openapi.yaml
Bottom Line
Re‑adding a deprecated property preserves backward compatibility for clients that were generated before the property’s removal, provided those clients have not been altered to treat the property’s absence as a new contract. Verification through source control checks, regeneration, and contract testing is essential to ensure the rollback behaves as intended.