Add Schemathesis for checking APIs against their OpenAPI specs - #38101
Add Schemathesis for checking APIs against their OpenAPI specs#38101aaronvanderlip wants to merge 1 commit into
Conversation
Schemathesis generates requests from an OpenAPI spec and reports where the responses disagree with it. Updated DEV_SETUP.md with instructions for running schemathesis and configuring schemathesis.toml to run against the future commcare-hq spec.
|
The comments and questions I posted on the previous PR also apply here. |
In the current configuration it is only testing the endpoints described in the spec and not performing any fuzz testing or testing undocumented HTTP methods. In that configuration, the cost of running it in a testing pipeline would be the network and app overhead per request X the number of endpoints to be tested. The tool also supports multithreading so a pool of workers could be setup. It is TBD what the overhead for write operations would be, but simple GET requests I would expect to resolve quickly.
I would expect the flake to come from the target app or network.
Yes. This would require the spec generation tool output link information which it currently does not.
Probably not.
The goal for this PR is to install a tool that can be used while the tooling to generate the spec is being developed to help ensure the correctness of the final spec. The current configuration is lenient and those decisions are documented in Longer term, the tool should run automatically to ensure there is no drift in the spec and the endpoints are operating as expected.
Schemathesis is a wrapper around one of those dependencies, https://hypothesis.readthedocs.io/en/latest, which might prove to have some use in testing outside of API code. |
| 'psutil>5.1.3', # for memory profiling | ||
| 'wheel', | ||
| 'ruff', # linting, formatting, and import sorting | ||
| 'schemathesis', # API conformance checks, see DEV_SETUP.md |
There was a problem hiding this comment.
Wondering if it would make sense to remove the new dependency from dev requirements "while the tooling to generate the spec is being developed?"
| 'schemathesis', # API conformance checks, see DEV_SETUP.md |
Users who want to test it can run a command to install it locally:
uv pip install schemathesisThis install command could be added to the new section of DEV_SETUP.md
That way we can defer the dependency maintenance burden until later, presumably when API checks are automated.
Schemathesis generates requests from an OpenAPI spec and reports where the responses disagree with it.
Updated DEV_SETUP.md with instructions for running schemathesis and configuring schemathesis.toml to run against the future commcare-hq spec.