New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FEATURE] Rework checks API #1689
Comments
Hi, I've arrived here from the #1147 thread as we're currently experiencing the same false-positive valdiation results when migrating from Dredd to Schemathesis. We're using Schemathesis to only validate the schema of the responses and as such CLI-based usage is more than enough for us. Is the new Checks API going to be usable/configurable via CLI or perhaps some custom OpenAPI schema tags? |
Hi! I was thinking about exposing some checks in the contrib sub package, so it is available from CLI, additionally I want to make some current checks configurable (eg status codes to ignore). Could you briefly describe what kind of problem you’d like to solve with configurable Schemathesis checks? |
As mentioned, we're using Schemathesis to validate response schema correctness based on the OpenAPI document. In the OpenAPI document we include examples that generally illustrate the "happy path" (2XX) responses but we document some of the possible failure response codes. We are not interested in triggering those failures codes - they are there purely for documentation purposes. Assuming we can achieve that somehow, we would want to treat every non-2XX response as a test failure (even though it may be one of the documented response codes for the endpoint). |
Thank you! I will take it into account :) likely I’ll work on it in January |
Also it seems that currently checks ( |
Oh, these ones should be passed explicitly at the moment, but I think it should not be an issue to use all registered checks there if no explicit set of check is provided. Id say it is an oversight, I’ll take a look at it during this week |
@IvanRibakov Can you, please, show how have you discovered such behavior? I can not reproduce it with CLI or
import schemathesis
SHOWN = False
@schemathesis.check
def my_check(response, case) -> None:
global SHOWN
if not SHOWN:
SHOWN = True
print("CUSTOM CHECK") Running against the built-in test app (
Running import schemathesis
SHOWN = False
@schemathesis.check
def my_check(response, case) -> None:
global SHOWN
if not SHOWN:
SHOWN = True
print("CUSTOM CHECK")
schema = schemathesis.from_uri("http://0.0.0.0:8081/schema.yaml")
APIWorkflow = schema.as_state_machine()
TestAPI = APIWorkflow.TestCase |
Please, disregard the code samples I provided in the previous comment,the check does not really show if the cases are coming from stateful transitions |
Not sure if it was something you've observed, but in CLI all |
There were some ideas on how checks API could look in order to allow the user to build much more flexible checks.
The first change is to introduce a way to run checks not only in the scope of a single case & response but also in the scope of all cases & responses.
Then add
context
as it is in hooks, targets, etc.And filters - so checks could be applied to specific endpoints only. It could also be possible to filter by response status / some other properties.
Based on this comment:
The text was updated successfully, but these errors were encountered: