Bird
Raised Fist0

To add a new optional field in version 3 of an API while ensuring existing clients remain unaffected, which strategy is best?

hard🚀 Application Q9 of Q15
Rest API - Versioning Strategies
To add a new optional field in version 3 of an API while ensuring existing clients remain unaffected, which strategy is best?
AAdd the optional field only in version 3 without changing previous versions
BAdd the field to all versions and mark it as required
CRemove the field from version 2 to avoid confusion
DMake the field mandatory in version 1 to prepare clients
Step-by-Step Solution
Solution:
  1. Step 1: Understand optional field addition

    Optional fields do not break clients if added properly.
  2. Step 2: Use versioning to isolate changes

    Add the new optional field only in version 3 to keep older versions stable.
  3. Final Answer:

    Add the optional field only in version 3 without changing previous versions -> Option A
  4. Quick Check:

    Optional fields in new versions preserve backward compatibility [OK]
Quick Trick: Add optional fields only in new versions [OK]
Common Mistakes:
MISTAKES
  • Making new fields required in all versions
  • Removing fields from older versions unnecessarily
  • Forcing mandatory changes on old versions

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes