Support 202 Accepted as a valid success response code - #31
Merged
Conversation
- 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
contract.pyto recognise 202 Accepted alongside 200/201 in all four HTTP methods (GET, POST, PUT, DELETE)expected_statusis now derived from the spec (202 > 201 > 200) instead of being hardcodeddocumented_statuses, so a server returning 200 when the spec only documents 202 is caught as a contract violationpost_202_accepted(correct) andpost_202_returns_200(wrong status — should fail)Test plan
test_post_202_accepted_passes— server documents and returns 202, expect passtest_get_202_accepted_passes— GET endpoint with 202, expect passtest_post_202_spec_but_server_returns_200_fails— spec says 202 but server returns 200, expect failure🤖 Generated with Claude Code