A sad path is an API execution path where an error or exceptional condition produces an unsuccessful response. Testing it checks whether the API handles invalid conditions consistently with its published contract. section 7.4 section 7.8
Use sad paths in two complementary ways:
- Generate happy- and sad-path schema tests from an OpenAPI definition, then run them against the API gateway or service. section 7.4
- Write a sad-path test for a custom linting rule and assert the expected diagnostic, location, and severity. section 10.1.2
- Prefer generated tests when endpoint changes make hand-maintained response scenarios costly; retain code-based tests for multi-call workflows and complex application states. section 7.3
Invalid operation identifier
A linting-rule test supplies a GET operation with operationId "listUsers" even though the convention requires a prefix such as "retrieve" or "download". The sad path expects an error diagnostic at paths → /v1/users → get → operationId, with error severity. section 10.1.2
Figure 7.3 Generating schema tests from an OpenAPI definition
Follow the flow from an OpenAPI definition to generated happy- and sad-path schema tests executed against an API service. section 7.4
