Skip to content

Support 202 Accepted as a valid success response code - #31

Merged
sinan-ozel merged 2 commits into
mainfrom
fix-202-response-support
Apr 10, 2026
Merged

Support 202 Accepted as a valid success response code#31
sinan-ozel merged 2 commits into
mainfrom
fix-202-response-support

Conversation

@sinan-ozel

Copy link
Copy Markdown
Owner

Summary

  • Extends response-code handling in contract.py to recognise 202 Accepted alongside 200/201 in all four HTTP methods (GET, POST, PUT, DELETE)
  • expected_status is now derived from the spec (202 > 201 > 200) instead of being hardcoded
  • Status validation now intersects against documented_statuses, so a server returning 200 when the spec only documents 202 is caught as a contract violation
  • Adds two test servers: post_202_accepted (correct) and post_202_returns_200 (wrong status — should fail)
  • Integration and unit tests cover both scenarios

Test plan

  • test_post_202_accepted_passes — server documents and returns 202, expect pass
  • test_get_202_accepted_passes — GET endpoint with 202, expect pass
  • test_post_202_spec_but_server_returns_200_fails — spec says 202 but server returns 200, expect failure
  • Existing suite passes unchanged

🤖 Generated with Claude Code

sinan-ozel and others added 2 commits April 10, 2026 11:41
- contract.py: look up 200/201/202 examples in GET, POST, PUT, DELETE
- contract.py: derive expected_status from documented responses (202 > 201 > 200)
- contract.py: status check now uses documented_statuses so a server returning
  200 when the spec only documents 202 is caught as a contract violation
- Add test server post_202_accepted (documents and returns 202)
- Add test server post_202_returns_200 (documents 202, returns 200 – should fail)
- Integration tests for both scenarios
- Unit tests for 202 handling in test_post_endpoint_single and test_get_endpoint

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sinan-ozel
sinan-ozel merged commit 482cdd9 into main Apr 10, 2026
7 checks passed
@sinan-ozel
sinan-ozel deleted the fix-202-response-support branch April 10, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant