You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In web APIs, users often use regular expressions syntax supported by their backend, and sometimes it is not compatible (in some areas) with the one supported by JSON Schema.
For example, this AWS API uses character classes that are supported by Java, for example, \p{Alpha}. It is not supported in Python stdlib re module, and currently hypothesis-jsonschemausesst.nothing() for such cases. In the simplest case, it leads to Unsatisfiable as there are no values in this strategy.
Even though we don't support generating strings for such regular expressions in the schema above, we still can generate an empty array that will match the schema. The same could be applied to optional properties, etc.
The current error output for the schema above:
hypothesis.errors.InvalidArgument: Cannot create a collection of max_size=50, because no elements can be drawn from the element strategy nothing()
From the user perspective, it will be nice to expose some information about why it happens (the unsupported regex syntax). For cases when we still can generate data without those items/properties, it might be a warning, and for cases when we can't, a better error message will be great (e.g., if there is minItems: 1)
What do you think?
P.S. I am pretty sure that I saw a different InvalidArgument error that was also connected to drawing from nothing() - I will post an update once I find it
The text was updated successfully, but these errors were encountered:
In web APIs, users often use regular expressions syntax supported by their backend, and sometimes it is not compatible (in some areas) with the one supported by JSON Schema.
For example, this AWS API uses character classes that are supported by Java, for example,
\p{Alpha}
. It is not supported in Python stdlibre
module, and currentlyhypothesis-jsonschema
usesst.nothing()
for such cases. In the simplest case, it leads toUnsatisfiable
as there are no values in this strategy.But consider an array:
Even though we don't support generating strings for such regular expressions in the schema above, we still can generate an empty array that will match the schema. The same could be applied to optional properties, etc.
The current error output for the schema above:
From the user perspective, it will be nice to expose some information about why it happens (the unsupported regex syntax). For cases when we still can generate data without those items/properties, it might be a warning, and for cases when we can't, a better error message will be great (e.g., if there is
minItems: 1
)What do you think?
P.S. I am pretty sure that I saw a different
InvalidArgument
error that was also connected to drawing fromnothing()
- I will post an update once I find itThe text was updated successfully, but these errors were encountered: