Bird
0
0

You have an API with versions /v1 and /v2. Version 2 changes the user object by renaming 'username' to 'user_name'. How can you design the API to avoid breaking clients using /v1?

hard📝 Application Q8 of 15
Rest API - Versioning Strategies
You have an API with versions /v1 and /v2. Version 2 changes the user object by renaming 'username' to 'user_name'. How can you design the API to avoid breaking clients using /v1?
ARename the field in /v1 and /v2 simultaneously
BKeep /v1 unchanged and implement the rename only in /v2
CRemove /v1 and force all clients to use /v2
DUse a query parameter to switch field names dynamically
Step-by-Step Solution
Solution:
  1. Step 1: Understand version isolation for field changes

    Changing field names in a new version should not affect old versions to avoid breaking clients.
  2. Step 2: Apply change only in new version

    Keep /v1 with 'username' and rename to 'user_name' only in /v2 to maintain compatibility.
  3. Final Answer:

    Keep /v1 unchanged and implement the rename only in /v2 -> Option B
  4. Quick Check:

    Change fields only in new version = B [OK]
Quick Trick: Apply breaking changes only in new API versions [OK]
Common Mistakes:
  • Changing old versions simultaneously
  • Removing old versions abruptly
  • Using query parameters for field renaming

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Rest API Quizzes